• 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

42.5
/src/DataManager/utils/TableView/computers/IntervalOverlapComputer.cpp
1
#include "IntervalOverlapComputer.h"
2

3
#include <algorithm>
4
#include <limits>
5
#include <stdexcept>
6
#include <iostream> // Added for debug output
7

8

9
bool intervalsOverlap(const TimeFrameInterval& a, const TimeFrameInterval& b) {
3✔
10
    // Two intervals overlap if: a.start <= b.end && b.start <= a.end
11
    return a.start.getValue() <= b.end.getValue() && b.start.getValue() <= a.end.getValue();
3✔
12
}
13

14
int64_t findContainingInterval(const TimeFrameInterval& rowInterval,
1✔
15
                              const std::vector<Interval>& columnIntervals) {
16
    for (size_t i = 0; i < columnIntervals.size(); ++i) {
2✔
17
        const auto& colInterval = columnIntervals[i];
2✔
18
        
19
        // Check if column interval contains the row interval
20
        // Column interval contains row interval if: colInterval.start <= rowInterval.start && rowInterval.end <= colInterval.end
21
        if (colInterval.start <= rowInterval.start.getValue() && rowInterval.end.getValue() <= colInterval.end) {
2✔
22
            return static_cast<int64_t>(i);
1✔
23
        }
24
    }
25
    return -1; // No containing interval found
×
26
}
27

28
int64_t countOverlappingIntervals(const TimeFrameInterval& rowInterval,
39✔
29
                                 const std::vector<Interval>& columnIntervals,
30
                                 const TimeFrame* sourceTimeFrame,
31
                                 const TimeFrame* destinationTimeFrame) {
32
    int64_t count = 0;
39✔
33
    
34
    // Convert row interval to absolute time coordinates
35
    auto destination_start = destinationTimeFrame->getTimeAtIndex(rowInterval.start);
39✔
36
    auto destination_end = destinationTimeFrame->getTimeAtIndex(rowInterval.end);
39✔
37
    
38
    for (const auto& colInterval : columnIntervals) {
80✔
39
        // Convert column interval to absolute time coordinates
40
        auto source_start = sourceTimeFrame->getTimeAtIndex(TimeFrameIndex(colInterval.start));
41✔
41
        auto source_end = sourceTimeFrame->getTimeAtIndex(TimeFrameIndex(colInterval.end));
41✔
42
        
43
        // Check overlap using absolute time coordinates
44
        // Two intervals overlap if: source_start <= destination_end && destination_start <= source_end
45
        if (source_start <= destination_end && destination_start <= source_end) {
41✔
46
            ++count;
40✔
47
        }
48
    }
49
    
50
    return count;
39✔
51
}
52

53
// Template specialization for size_t
54
template<>
UNCOV
55
auto IntervalOverlapComputer<size_t>::compute(const ExecutionPlan& plan) const -> std::vector<size_t> {
×
UNCOV
56
    if (m_operation != IntervalOverlapOperation::CountOverlaps) {
×
UNCOV
57
        throw std::runtime_error("IntervalOverlapComputer<size_t> can only be used with CountOverlaps operation");
×
58
    }
59
    
UNCOV
60
    if (!plan.hasIntervals()) {
×
UNCOV
61
        throw std::runtime_error("IntervalOverlapComputer requires an ExecutionPlan with intervals");
×
62
    }
63
    
64
    auto rowIntervals = plan.getIntervals();
×
65
    auto destinationTimeFrame = plan.getTimeFrame();
×
NEW
66
    auto sourceTimeFrame = m_source->getTimeFrame();
×
67
    
UNCOV
68
    std::vector<size_t> results;
×
UNCOV
69
    results.reserve(rowIntervals.size());
×
70
    
71
    // Get all column intervals from the source
72
    // Use a reasonable range that covers the entire time frame
UNCOV
73
    auto columnIntervals = m_source->getIntervalsInRange(
×
74
        TimeFrameIndex(0),
75
        TimeFrameIndex(1000000), // Use a large but reasonable upper bound
76
        destinationTimeFrame.get()
×
UNCOV
77
    );
×
78
    
79
    std::cout << "DEBUG: Retrieved " << columnIntervals.size() << " column intervals" << std::endl;
×
UNCOV
80
    for (size_t i = 0; i < columnIntervals.size(); ++i) {
×
UNCOV
81
        const auto& interval = columnIntervals[i];
×
UNCOV
82
        std::cout << "DEBUG: Column interval " << i << ": [" << interval.start << ", " << interval.end << "]" << std::endl;
×
83
    }
84
    
UNCOV
85
    for (const auto& rowInterval : rowIntervals) {
×
NEW
86
        int64_t count = countOverlappingIntervals(rowInterval, columnIntervals, sourceTimeFrame.get(), destinationTimeFrame.get());
×
87
        results.push_back(static_cast<size_t>(count));
×
88
    }
89
    
90
    return results;
×
91
}
×
92

93
// Template specializations for different data types
94
template std::vector<int64_t> IntervalOverlapComputer<int64_t>::compute(ExecutionPlan const & plan) const;
95
template std::vector<size_t> IntervalOverlapComputer<size_t>::compute(ExecutionPlan const & plan) const;
96
template std::vector<double> IntervalOverlapComputer<double>::compute(ExecutionPlan const & plan) const;
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