Repository navigation
Commit 27348a2
committed
fix(interval): intersect overlapping and touching intervals correctly
QwtInterval.intersect (and the `&` operator) returned an invalid interval
for partially overlapping intervals, e.g. QwtInterval(0, 2) &
QwtInterval(1, 3), and for intervals sharing an included bound: after
ordering the intervals by their minimum, it tested
`i1.maxValue() < i2.maxValue()` instead of `i1.maxValue() < i2.minValue()`
(Qwt C++).
QwtInterval.intersects gave the opposite result for intervals sharing a
bound: `[0, 1]` and `[1, 2]` did not intersect, while `[0, 1)` and
`(1, 2]` did. Qwt C++ returns
`!(i1 excludes its maximum || i2 excludes its minimum)`.
- Restore the Qwt C++ conditions; intersects now always returns a bool.
- Results which were already valid are unchanged: checked on all the
4096 pairs of intervals with bounds in 0..3 and any border flags
(including invalid intervals), both methods now match a direct
transcription of the Qwt C++ code.
- Regression tests: table of overlapping, nested, equal, disjoint and
touching intervals with various border flags, in both orders, with
`intersect` and `&`; `intersects` cases; invalid intervals.
- Changelog entry.
Refs #115
Assisted-by: Claude Opus 5.51 parent 36285dc commit 27348a2
3 files changed
Lines changed: 81 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
299 | | - | |
| 299 | + | |
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
| |||
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
349 | | - | |
| 349 | + | |
350 | 350 | | |
351 | | - | |
| 351 | + | |
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
663 | 664 | | |
664 | 665 | | |
665 | 666 | | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
666 | 739 | | |
667 | 740 | | |
668 | 741 | | |
| |||
686 | 759 | | |
687 | 760 | | |
688 | 761 | | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
689 | 766 | | |
0 commit comments