• 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

57.14
/src/DataManager/utils/map_timeseries.hpp
1
#ifndef MAP_TIMESERIES_HPP
2
#define MAP_TIMESERIES_HPP
3

4
#include "TimeFrame/TimeFrame.hpp"
5

6
#include <map>
7
#include <vector>
8
#include <algorithm>
9
#include <ranges>
10

11
template<typename T>
UNCOV
12
[[nodiscard]] bool clear_at_time(TimeFrameIndex const time, T & data) {
×
UNCOV
13
    auto it = data.find(time);
×
UNCOV
14
    if (it != data.end()) {
×
UNCOV
15
        data.erase(it);
×
UNCOV
16
        return true;
×
17
    }
UNCOV
18
    return false;
×
19
}
20

21
template<typename T>
22
[[nodiscard]] bool clear_at_time(TimeFrameIndex const time, size_t const index, T & data) {
23
    auto it = data.find(time);
24
    if (it != data.end()) {
25
        if (index >= it->second.size()) {
26
            return false;
27
        }
28
        it->second.erase(it->second.begin() + static_cast<std::ptrdiff_t>(index));
29
        return true;
30
    }
31
    return false;
32
}
33

34
template<typename T, typename M> 
35
void add_at_time(TimeFrameIndex const time, T const & data, M & data_map) {
36
    data_map[time].push_back(data);
37
}
38

39
template<typename T, typename M>
40
[[nodiscard]] std::vector<T> const & get_at_time(TimeFrameIndex const time, M const & data, std::vector<T> const & empty) {
41
    auto it = data.find(time);
42
    if (it != data.end()) {
43
        return it->second;
44
    }
45
    return empty;
46
}
47

48
template<typename T, typename M>
49
[[nodiscard]] std::vector<T> const & get_at_time(TimeFrameIndex const time, 
50
                                                M const & data, 
51
                                                std::vector<T> const & empty, 
52
                                                TimeFrame const * source_timeframe, 
53
                                                TimeFrame const * target_timeframe) {
54

55
    // If the timeframes are the same object, no conversion is needed
56
    if (source_timeframe == target_timeframe) {
57
        return get_at_time(time, data, empty);
58
    }
59

60
    // If either timeframe is null, fall back to original behavior
61
    if (!source_timeframe || !target_timeframe) {
62
        return get_at_time(time, data, empty);
63
    }
64

65
    // Convert the time index from source timeframe to target timeframe
66
    // 1. Get the time value from the source timeframe
67
    auto time_value = source_timeframe->getTimeAtIndex(time);
68
    
69
    // 2. Convert that time value to an index in the target timeframe  
70
    auto target_index = target_timeframe->getIndexAtTime(static_cast<float>(time_value));
71

72
    return get_at_time(target_index, data, empty);
73
}
74

75

76
// Convert a time index between timeframes; falls back to original when null/equal
77
inline TimeFrameIndex convert_time_index(TimeFrameIndex const time,
25✔
78
                                         TimeFrame const * source_timeframe,
79
                                         TimeFrame const * target_timeframe) {
80
    if (source_timeframe == target_timeframe) {
25✔
81
        return time;
22✔
82
    }
83
    if (!source_timeframe || !target_timeframe) {
3✔
84
        return time;
1✔
85
    }
86
    auto const time_value = source_timeframe->getTimeAtIndex(time);
2✔
87
    auto const target_index = target_timeframe->getIndexAtTime(static_cast<float>(time_value));
2✔
88
    return target_index;
2✔
89
}
90

91
// Fill an output vector by extracting a field from a vector of entries
92
template <typename Entry, typename Out, typename Extractor>
93
inline void fill_extracted_vector(std::vector<Entry> const & entries,
94
                                  std::vector<Out> & out,
95
                                  Extractor extractor) {
96
    out.clear();
97
    out.reserve(entries.size());
98
    for (auto const & entry : entries) {
99
        out.push_back(extractor(entry));
100
    }
101
}
102

103
#endif // MAP_TIMESERIES_HPP
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