Skip to content

Commit

Permalink
Patching segmentlists in pycbc.workflow module (gwastro#5008)
Browse files Browse the repository at this point in the history
* Applying the patch from issue 5004 for segmentlists

* Reimplementing first isinstance checks for segmentlists

---------

Co-authored-by: jacquot <jacquot@>
  • Loading branch information
Thomas-JACQUOT authored Jan 20, 2025
1 parent ebbafae commit 52034ec
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions pycbc/workflow/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1164,12 +1164,20 @@ def __init__(self, ifos, exe_name, segs, file_url=None,

if isinstance(segs, segments.segment):
self.segment_list = segments.segmentlist([segs])
elif isinstance(segs, (segments.segmentlist)):
elif isinstance(segs, segments.segmentlist):
self.segment_list = segs
else:
err = "segs input must be either igwn_segments.segment or "
err += "igwn_segments.segmentlist. Got %s." %(str(type(segs)),)
raise ValueError(err)
if not isinstance(segs, list):
segs = [segs]
try:
self.segment_list = segments.segmentlist(map(segments.segment, segs))
except ValueError as exc:
exc.args = (
"segs input must be either igwn_segments.segment or "
f"igwn_segments.segmentlist. Got {type(segs).__name__}.",
)
raise

if tags is None:
tags = []
if '' in tags:
Expand Down

0 comments on commit 52034ec

Please sign in to comment.