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

paulmthompson / WhiskerToolbox / 18389801194

09 Oct 2025 09:35PM UTC coverage: 71.943% (+0.1%) from 71.826%
18389801194

push

github

paulmthompson
add correlation matrix to filtering interface

207 of 337 new or added lines in 5 files covered. (61.42%)

867 existing lines in 31 files now uncovered.

49964 of 69449 relevant lines covered (71.94%)

1103.53 hits per line

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

46.27
/src/DataManager/utils/TableView/adapters/PointComponentAdapter.cpp
1
#include "PointComponentAdapter.h"
2

3
#include "Points/Point_Data.hpp"
4

5
#include <algorithm>
6
#include <stdexcept>
7

8
PointComponentAdapter::PointComponentAdapter(std::shared_ptr<PointData> pointData,
13✔
9
                                             Component component,
10
                                             std::shared_ptr<TimeFrame> timeFrame,
11
                                             std::string name)
13✔
12
    : m_pointData(std::move(pointData)),
13✔
13
      m_component(component),
13✔
14
      m_timeFrame(std::move(timeFrame)),
13✔
15
      m_name(std::move(name)) {
26✔
16
    if (!m_pointData) {
13✔
17
        throw std::invalid_argument("PointData cannot be null");
×
18
    }
19
}
13✔
20

21
std::string const & PointComponentAdapter::getName() const {
17✔
22
    return m_name;
17✔
23
}
24

25
std::shared_ptr<TimeFrame> PointComponentAdapter::getTimeFrame() const {
×
26
    return m_timeFrame;
×
27
}
28

29
size_t PointComponentAdapter::size() const {
×
30
    if (!m_isMaterialized) {
×
31
        // Calculate size without materializing
32
        size_t totalPoints = 0;
×
33
        for (auto const & [time, points]: m_pointData->GetAllPointsAsRange()) {
×
34
            totalPoints += points.size();
×
UNCOV
35
        }
×
36
        return totalPoints;
×
37
    }
38
    return m_materializedData.size();
×
39
}
40

41
std::vector<float> PointComponentAdapter::getDataInRange(TimeFrameIndex start,
35✔
42
                                                         TimeFrameIndex end,
43
                                                         TimeFrame const * target_timeFrame) {
44
    // Special case: if start == end, we're looking for points at exactly one time frame
45
    if (start == end) {
35✔
46
        auto points = m_pointData->getAtTime(start, target_timeFrame, m_timeFrame.get());
13✔
47
        std::vector<float> componentValues;
13✔
48
        componentValues.reserve(points.size());
13✔
49
        
50
        for (auto const & point: points) {
26✔
51
            float componentValue = (m_component == Component::X) ? point.x : point.y;
13✔
52
            componentValues.push_back(componentValue);
13✔
53
        }
54
        return componentValues;
13✔
55
    }
13✔
56
    
57
    // For ranges with different start and end, use the range view
58
    auto point_range = m_pointData->GetPointsInRange(TimeFrameInterval(start, end),
44✔
59
                                                     target_timeFrame,
60
                                                     m_timeFrame.get());
22✔
61
    
62
    auto componentValues = std::vector<float>();
22✔
63

64
    for (auto const & time_point_pair: point_range) {
114✔
65
        // Check if there are points at this time
66
        if (time_point_pair.points.empty()) {
46✔
67
            continue;
×
68
        }
69
        
70
        // Add all points at this time frame
71
        for (auto const & point: time_point_pair.points) {
92✔
72
            float componentValue = (m_component == Component::X) ? point.x : point.y;
46✔
73
            componentValues.push_back(componentValue);
46✔
74
        }
75
    }
46✔
76
    
77
    return componentValues;
22✔
78
}
22✔
79

80
bool PointComponentAdapter::hasMultiSamples() const {
×
81
    for (auto const & [time, points] : m_pointData->GetAllPointsAsRange()) {
×
82
        if (points.size() > 1) {
×
83
            return true;
×
84
        }
UNCOV
85
    }
×
86
    return false;
×
87
}
88

89
void PointComponentAdapter::materializeData() {
×
90
    if (m_isMaterialized) {
×
91
        return;
×
92
    }
93

94
    // Reserve space for efficiency
95
    m_materializedData.clear();
×
96
    m_materializedData.reserve(size());
×
97

98
    // Collect all points in time order and extract the specified component
99
    std::vector<std::pair<TimeFrameIndex, std::vector<Point2D<float>> const *>> timePointPairs;
×
100

101
    for (auto const & [time, points]: m_pointData->GetAllPointsAsRange()) {
×
102
        timePointPairs.emplace_back(time, &points);
×
UNCOV
103
    }
×
104

105
    // Sort by time to ensure consistent ordering
106
    std::sort(timePointPairs.begin(), timePointPairs.end(),
×
107
              [](auto const & a, auto const & b) {
×
108
                  return a.first < b.first;
×
109
              });
110

111
    // Extract the component values
112
    for (auto const & [time, points]: timePointPairs) {
×
113
        for (auto const & point: *points) {
×
114
            double componentValue = (m_component == Component::X) ? static_cast<double>(point.x) : static_cast<double>(point.y);
×
115
            m_materializedData.push_back(componentValue);
×
116
        }
117
    }
118

119
    m_isMaterialized = true;
×
120
}
×
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