Registry / data / igwn-segments

igwn-segments

JSON →
library2.1.1pypypi✓ verified 82d ago

IGWN Segments (igwn-segments) provides a robust Pythonic representation of half-open intervals and lists of such intervals. It offers tools for creating, manipulating, and performing set-like operations (union, intersection, subtraction) on time segments, crucial for gravitational-wave data analysis and other scientific applications. Currently at version 2.1.1, the library follows an irregular release cadence, driven by the needs of the IGWN collaboration.

pip install igwn-segments
INSTALL
IMPORT
SIG · IGWN-SEGMENTS
I
igwn-segments
datapythonv2.1.1
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.1MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.6s · import 0.000s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

segment
from igwn_segments import segment
from segments import Segment
segmentlist
from igwn_segments import segmentlist
segmentlistdict
from igwn_segments import segmentlistdict

This quickstart demonstrates how to create `Segment` and `SegmentList` objects, calculate durations, check for intersections, and perform union operations. It also shows how to create a `SegmentList` from a string representation.

from segments import Segment, SegmentList # Create individual segments s1 = Segment(100.0, 200.0) s2 = Segment(150.0, 250.0) s3 = Segment(300.0, 350.0) print(f"Segment 1: {s1}") print(f"Segment 2: {s2}") print(f"Duration of s1: {s1.duration}") print(f"s1 intersects s2: {s1.intersects(s2)}") # Create a list of segments sl = SegmentList([s1, s2, s3]) print(f"Initial SegmentList: {sl}") # Perform union operation union_sl = sl.union() print(f"Union of SegmentList: {union_sl}") # Add a segment to a SegmentList sl_plus_s4 = sl.union(Segment(0, 50)) print(f"SegmentList with an added segment: {sl_plus_s4}") # Create from string representation sl_from_str = SegmentList.from_str('[[10, 20), [30, 40))') print(f"SegmentList from string: {sl_from_str}")
Debug
Known issues
breakingAs of v2.0.0, `Segment` and `SegmentList` objects strictly represent half-open intervals `[start, end)`. The `segments.Segment.is_right_open` parameter has been removed, and intervals are always right-open.
fix
Review code that assumed or explicitly set `is_right_open`. Adjust interval definitions if previous code relied on closed or open intervals in different ways. Ensure all custom interval parsing aligns with the `[start, end)` convention.
affects: >=2.0.0
gotchaIndividual `Segment` objects are immutable. Operations like `union()`, `intersection()`, or `subtraction()` on a `SegmentList` return a *new* `SegmentList` object. Attempting to modify a `Segment` in place will fail.
fix
Always assign the result of `SegmentList` operations to a new variable or reassign to the original variable. For example: `my_segment_list = my_segment_list.union(new_segment)`.
affects: All versions
gotchaDirect arithmetic operators (`+`, `-`, `*`, `/`) are not defined for `Segment` objects or for performing set-like operations on `SegmentList` objects. Instead, use explicit methods like `.union()`, `.intersection()`, `.subtraction()`.
fix
Replace `segment1 + segment2` with `SegmentList([segment1, segment2]).union()` (or similar for other operations and existing `SegmentList` objects). For example, `segment_list.union(other_segment_list)`.
affects: All versions
Upgrade
Version history
2.1.1latest on PyPI · released Jan 19, 2026
Audit
Dependencies
numpyrequiredFundamental array operations and data structures.
larkrequiredUsed for parsing segment strings.
scipyrequiredUsed for advanced segment list operations.
Agent activity
20 hits · last 30 days
node
18
OpenAI (training)
1
Resources
igwn-segments — pip install igwn-segments · libregistry