TimeSeriesDict.crop() with copy=True does not make a copy
Created by: myNameIsPatrick
I expected that TimeSeriesDict.copy().crop(...)
and TimeSeriesDict.crop(..., copy=True)
would be equivalent, but the latter modifies the existing dictionary in-place.
Example:
$ python
Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:56:21)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from numpy.random import random
>>> import gwpy
>>> from gwpy.timeseries import TimeSeries, TimeSeriesDict
>>> gwpy.__version__
'2.1.3'
>>> t = TimeSeries(random(1000))
>>> t.span
Segment(0.0, 1000.0)
>>> tdict = TimeSeriesDict({"t": t})
>>> tdict.span
Segment(0.0, 1000.0)
>>> tdict_cropped = tdict.crop(10, 20, copy=True)
>>> tdict_cropped.span
Segment(10.0, 20.0)
>>> tdict.span
Segment(10.0, 20.0)
>>> t.span
Segment(0.0, 1000.0)
>>> tdict = TimeSeriesDict({"t": t})
>>> tdict_cropped = tdict.copy().crop(10, 20)
>>> tdict_cropped.span
Segment(10.0, 20.0)
>>> tdict.span
Segment(0.0, 1000.0)