• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

paulmthompson / WhiskerToolbox / 17270491352

27 Aug 2025 02:57PM UTC coverage: 65.333%. Remained the same
17270491352

push

github

paulmthompson
Merge branch 'main' of https://github.com/paulmthompson/WhiskerToolbox

352 of 628 new or added lines in 92 files covered. (56.05%)

357 existing lines in 24 files now uncovered.

26429 of 40453 relevant lines covered (65.33%)

1119.34 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.5
/src/DataManager/DigitalTimeSeries/Digital_Event_Series.cpp
1
#include "Digital_Event_Series.hpp"
2

3
#include "TimeFrame/TimeFrame.hpp"
4
#include "Entity/EntityRegistry.hpp"
5

6
#include <algorithm> // std::sort
7

8
DigitalEventSeries::DigitalEventSeries(std::vector<float> event_vector) {
52✔
9
    setData(std::move(event_vector));
52✔
10
}
52✔
11

12
void DigitalEventSeries::setData(std::vector<float> event_vector) {
68✔
13
    _data = std::move(event_vector);
68✔
14
    _sortEvents();
68✔
15
    notifyObservers();
68✔
16
    // Rebuild IDs if identity context present
17
    if (_identity_registry) {
68✔
18
        rebuildAllEntityIds();
×
19
    }
20
}
68✔
21

22
std::vector<float> const & DigitalEventSeries::getEventSeries() const {
25✔
23
    return _data;
25✔
24
}
25

26
void DigitalEventSeries::addEvent(float const event_time) {
14✔
27

28
    if (std::find(_data.begin(), _data.end(), event_time) != _data.end()) {
14✔
29
        return;
2✔
30
    }
31

32
    _data.push_back(event_time);
12✔
33

34
    _sortEvents();
12✔
35

36
    notifyObservers();
12✔
37
    if (_identity_registry) {
12✔
38
        // Rebuild to ensure order alignment
39
        rebuildAllEntityIds();
×
40
    }
41
}
42

43
bool DigitalEventSeries::removeEvent(float const event_time) {
5✔
44
    auto it = std::find(_data.begin(), _data.end(), event_time);
5✔
45
    if (it != _data.end()) {
5✔
46
        _data.erase(it);
3✔
47
        notifyObservers();
3✔
48
        if (_identity_registry) {
3✔
49
            rebuildAllEntityIds();
×
50
        }
51
        return true;
3✔
52
    }
53
    return false;
2✔
54
}
55

56
void DigitalEventSeries::_sortEvents() {
80✔
57
    std::sort(_data.begin(), _data.end());
80✔
58
}
80✔
59

60
void DigitalEventSeries::rebuildAllEntityIds() {
×
61
    if (!_identity_registry) {
×
62
        _entity_ids.assign(_data.size(), 0);
×
63
        return;
×
64
    }
65
    _entity_ids.clear();
×
66
    _entity_ids.reserve(_data.size());
×
67
    for (int i = 0; i < static_cast<int>(_data.size()); ++i) {
×
68
        // Use time index = i (since data is float times, but consistent order gives stable local index)
NEW
69
        _entity_ids.push_back(_identity_registry->ensureId(_identity_data_key, EntityKind::EventEntity, TimeFrameIndex{i}, i));
×
70
    }
71
}
72

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc