gwpy 3.0.9__py3-none-any.whl → 3.0.11__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of gwpy might be problematic. Click here for more details.
- gwpy/_version.py +2 -2
- gwpy/cli/gwpy_plot.py +1 -1
- gwpy/cli/tests/base.py +11 -1
- gwpy/detector/units.py +1 -1
- gwpy/frequencyseries/tests/test_hist.py +4 -3
- gwpy/io/datafind.py +2 -2
- gwpy/io/ffldatafind.py +1 -1
- gwpy/io/tests/test_datafind.py +0 -53
- gwpy/plot/axes.py +6 -2
- gwpy/plot/plot.py +12 -2
- gwpy/plot/segments.py +8 -8
- gwpy/plot/tests/test_axes.py +4 -2
- gwpy/plot/tests/test_segments.py +1 -1
- gwpy/segments/__init__.py +1 -1
- gwpy/segments/flag.py +13 -11
- gwpy/segments/io/hdf5.py +1 -1
- gwpy/segments/segments.py +1 -1
- gwpy/signal/filter_design.py +1 -1
- gwpy/signal/tests/test_coherence.py +31 -10
- gwpy/table/io/ligolw.py +1 -1
- gwpy/table/tests/test_io_ligolw.py +1 -1
- gwpy/testing/errors.py +1 -0
- gwpy/testing/marks.py +1 -1
- gwpy/timeseries/core.py +0 -1
- gwpy/timeseries/io/gwf/__init__.py +1 -1
- gwpy/timeseries/statevector.py +4 -2
- gwpy/timeseries/tests/test_core.py +7 -13
- gwpy/timeseries/tests/test_io_gwf_framecpp.py +1 -1
- gwpy/timeseries/tests/test_statevector.py +29 -17
- gwpy/timeseries/tests/test_timeseries.py +10 -14
- gwpy/types/tests/test_array.py +12 -10
- gwpy/types/tests/test_array2d.py +5 -9
- gwpy/types/tests/test_series.py +5 -5
- gwpy/utils/sphinx/zenodo.py +5 -1
- gwpy/utils/tests/test_sphinx_zenodo.py +10 -5
- gwpy-3.0.11.dist-info/METADATA +125 -0
- {gwpy-3.0.9.dist-info → gwpy-3.0.11.dist-info}/RECORD +41 -41
- {gwpy-3.0.9.dist-info → gwpy-3.0.11.dist-info}/WHEEL +1 -1
- gwpy-3.0.9.dist-info/METADATA +0 -124
- {gwpy-3.0.9.dist-info → gwpy-3.0.11.dist-info}/LICENSE +0 -0
- {gwpy-3.0.9.dist-info → gwpy-3.0.11.dist-info}/entry_points.txt +0 -0
- {gwpy-3.0.9.dist-info → gwpy-3.0.11.dist-info}/top_level.txt +0 -0
gwpy/_version.py
CHANGED
gwpy/cli/gwpy_plot.py
CHANGED
|
@@ -55,7 +55,7 @@ Examples:
|
|
|
55
55
|
$ gwpy-plot coherencegram --chan H1:GDS-CALIB_STRAIN H1:PEM-CS_ACC_PSL_PERISCOPE_X_DQ --start 1126260017 --duration 600
|
|
56
56
|
|
|
57
57
|
Written by {__author__}.
|
|
58
|
-
Report bugs to https://
|
|
58
|
+
Report bugs to https://gitlab.com/gwpy/gwpy/-/issues/.
|
|
59
59
|
""" # noqa: E501
|
|
60
60
|
|
|
61
61
|
|
gwpy/cli/tests/base.py
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"""Unit tests for :mod:`gwpy.cli`
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
|
+
import warnings
|
|
22
23
|
from argparse import ArgumentParser
|
|
23
24
|
from unittest import mock
|
|
24
25
|
|
|
@@ -237,7 +238,16 @@ class _TestCliProduct(object):
|
|
|
237
238
|
xmin = min(series.xspan[0] for series in data)
|
|
238
239
|
xmax = max(series.xspan[1] for series in data)
|
|
239
240
|
|
|
240
|
-
|
|
241
|
+
# ignore warnings from matplotlib about having no labels
|
|
242
|
+
# (because we have cut some corners in preparing this test)
|
|
243
|
+
with warnings.catch_warnings():
|
|
244
|
+
warnings.filterwarnings(
|
|
245
|
+
"ignore",
|
|
246
|
+
message="No artists with labels found to put in legend",
|
|
247
|
+
category=UserWarning,
|
|
248
|
+
)
|
|
249
|
+
plotprod.set_plot_properties()
|
|
250
|
+
|
|
241
251
|
ax = plotprod.ax
|
|
242
252
|
|
|
243
253
|
ymin, ymax = ax.get_ylim()
|
gwpy/detector/units.py
CHANGED
|
@@ -187,7 +187,7 @@ units.def_unit(['NONE', 'undef'], namespace=_ns,
|
|
|
187
187
|
|
|
188
188
|
# other dimenionless units
|
|
189
189
|
units.def_unit('strain', namespace=_ns)
|
|
190
|
-
units.def_unit('coherence', namespace=_ns)
|
|
190
|
+
units.def_unit('coherence', represents=units.dimensionless_unscaled, namespace=_ns)
|
|
191
191
|
|
|
192
192
|
# alias for 'second' but with prefices
|
|
193
193
|
units.def_unit((['sec'], ['sec']), represents=units.second, prefixes=True,
|
|
@@ -77,7 +77,8 @@ class TestSpectralVariance(_TestArray2D):
|
|
|
77
77
|
utils.assert_array_equal(array.yindex, array.bins[:-1])
|
|
78
78
|
|
|
79
79
|
def test_transpose(self, array):
|
|
80
|
-
|
|
80
|
+
with pytest.raises(NotImplementedError):
|
|
81
|
+
array.T
|
|
81
82
|
|
|
82
83
|
# -- test utilities -------------------------
|
|
83
84
|
|
|
@@ -110,10 +111,10 @@ class TestSpectralVariance(_TestArray2D):
|
|
|
110
111
|
pytest.skip("float precision test not supported for SpectralVariance")
|
|
111
112
|
|
|
112
113
|
def test_is_compatible_yindex(self, array):
|
|
113
|
-
|
|
114
|
+
pytest.skip(f"not implemented for {type(self).__name__}")
|
|
114
115
|
|
|
115
116
|
def test_is_compatible_error_yindex(self, array):
|
|
116
|
-
|
|
117
|
+
pytest.skip(f"not implemented for {type(self).__name__}")
|
|
117
118
|
|
|
118
119
|
def test_plot(self, array):
|
|
119
120
|
with rc_context(rc={'text.usetex': False}):
|
gwpy/io/datafind.py
CHANGED
|
@@ -22,7 +22,7 @@ Automatic discovery of file paths for both LIGO and Virgo index solutions
|
|
|
22
22
|
(``gwdatafind`` or ``ffl``, respectvely) is supported.
|
|
23
23
|
|
|
24
24
|
The functions in this module are highly reliant on having local access to
|
|
25
|
-
files (either directly, or via NFS
|
|
25
|
+
files (either directly, or via NFS/fuse).
|
|
26
26
|
|
|
27
27
|
Data discovery using the DataFind service requires the `gwdatafind` Python
|
|
28
28
|
package (a dependency of ``gwpy``), and either the ``GW_DATAFIND_SERVER``
|
|
@@ -45,7 +45,7 @@ from unittest import mock
|
|
|
45
45
|
|
|
46
46
|
import gwdatafind
|
|
47
47
|
|
|
48
|
-
from
|
|
48
|
+
from igwn_segments import segment as LigoSegment
|
|
49
49
|
|
|
50
50
|
from ..time import to_gps
|
|
51
51
|
from . import ffldatafind
|
gwpy/io/ffldatafind.py
CHANGED
gwpy/io/tests/test_datafind.py
CHANGED
|
@@ -27,7 +27,6 @@ import pytest
|
|
|
27
27
|
import gwdatafind
|
|
28
28
|
|
|
29
29
|
from ...testing.errors import (
|
|
30
|
-
pytest_skip_cvmfs_read_error,
|
|
31
30
|
pytest_skip_network_error,
|
|
32
31
|
)
|
|
33
32
|
from ...testing.utils import (
|
|
@@ -76,30 +75,6 @@ def _mock_gwdatafind(func):
|
|
|
76
75
|
return wrapper
|
|
77
76
|
|
|
78
77
|
|
|
79
|
-
def _gwosc_gwdatafind(func):
|
|
80
|
-
"""Decorate a function to use the GWOSC GWDataFind server.
|
|
81
|
-
|
|
82
|
-
That server returns paths from CVMFS (``/cvmfs/gwosc.osgstorage.org``) so
|
|
83
|
-
we need to add various protections.
|
|
84
|
-
"""
|
|
85
|
-
@mock.patch.dict( # point GWDataFind at GWOSC server
|
|
86
|
-
"os.environ",
|
|
87
|
-
{"GWDATAFIND_SERVER": "datafind.gwosc.org:80"},
|
|
88
|
-
)
|
|
89
|
-
@pytest_skip_cvmfs_read_error # skip CVMFS problems
|
|
90
|
-
@pytest_skip_network_error # skip network problems
|
|
91
|
-
@pytest.mark.skipif( # skip missing CVMFS repo
|
|
92
|
-
not os.path.isdir('/cvmfs/gwosc.osgstorage.org/'),
|
|
93
|
-
reason="GWOSC CVMFS repository not available",
|
|
94
|
-
)
|
|
95
|
-
@pytest.mark.cvmfs # mark test as requiring cvmfs
|
|
96
|
-
@pytest.mark.requires("LDAStools.frameCPP") # skip if no frameCPP
|
|
97
|
-
def wrapper(*args, **kwargs):
|
|
98
|
-
return func(*args, **kwargs)
|
|
99
|
-
|
|
100
|
-
return wrapper
|
|
101
|
-
|
|
102
|
-
|
|
103
78
|
# -- tests --------------------------------------------------------------------
|
|
104
79
|
|
|
105
80
|
@mock.patch.dict("os.environ", clear=True)
|
|
@@ -207,34 +182,6 @@ def test_find_best_frametype():
|
|
|
207
182
|
) == 'HW100916'
|
|
208
183
|
|
|
209
184
|
|
|
210
|
-
@_gwosc_gwdatafind
|
|
211
|
-
def test_find_best_frametype_with_gaps():
|
|
212
|
-
"""Test that `find_best_frametype` works across gaps.
|
|
213
|
-
|
|
214
|
-
It tries to find something that covers at least some of the gap.
|
|
215
|
-
"""
|
|
216
|
-
assert io_datafind.find_best_frametype(
|
|
217
|
-
"L1:GWOSC-4KHZ_R1_STRAIN",
|
|
218
|
-
1187733504,
|
|
219
|
-
1187733504 + 4097, # one second too long
|
|
220
|
-
) == "L1_GWOSC_O2_4KHZ_R1"
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
@_gwosc_gwdatafind
|
|
224
|
-
def test_find_best_frametype_with_gaps_multiple():
|
|
225
|
-
"""Test that `find_best_frametype` works across gaps with multiple
|
|
226
|
-
channels.
|
|
227
|
-
"""
|
|
228
|
-
assert io_datafind.find_best_frametype(
|
|
229
|
-
("L1:GWOSC-4KHZ_R1_STRAIN", "L1:GWOSC-4KHZ_R1_DQMASK"),
|
|
230
|
-
1187733504,
|
|
231
|
-
1187733504 + 4097, # one second too long
|
|
232
|
-
) == {
|
|
233
|
-
"L1:GWOSC-4KHZ_R1_STRAIN": "L1_GWOSC_O2_4KHZ_R1",
|
|
234
|
-
"L1:GWOSC-4KHZ_R1_DQMASK": "L1_GWOSC_O2_4KHZ_R1",
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
185
|
@pytest.mark.requires("LDAStools.frameCPP")
|
|
239
186
|
@pytest_skip_network_error
|
|
240
187
|
@pytest.mark.skipif(
|
gwpy/plot/axes.py
CHANGED
|
@@ -39,6 +39,8 @@ from matplotlib.collections import PolyCollection
|
|
|
39
39
|
from matplotlib.lines import Line2D
|
|
40
40
|
from matplotlib.projections import register_projection
|
|
41
41
|
|
|
42
|
+
from packaging.version import Version
|
|
43
|
+
|
|
42
44
|
from . import (Plot, colorbar as gcbar)
|
|
43
45
|
from .colors import format_norm
|
|
44
46
|
from .gps import GPS_SCALES
|
|
@@ -47,6 +49,8 @@ from ..time import to_gps
|
|
|
47
49
|
|
|
48
50
|
__author__ = 'Duncan Macleod <duncan.macleod@ligo.org>'
|
|
49
51
|
|
|
52
|
+
matplotlib_version = Version(matplotlib_version)
|
|
53
|
+
|
|
50
54
|
|
|
51
55
|
def log_norm(func):
|
|
52
56
|
"""Wrap ``func`` to handle custom gwpy keywords for a LogNorm colouring
|
|
@@ -86,7 +90,7 @@ def restore_grid(func):
|
|
|
86
90
|
automatically removed a grid on a set of Axes. This decorator just
|
|
87
91
|
undoes that.
|
|
88
92
|
"""
|
|
89
|
-
if matplotlib_version >= "3.7.0":
|
|
93
|
+
if matplotlib_version >= Version("3.7.0"):
|
|
90
94
|
return func
|
|
91
95
|
|
|
92
96
|
@wraps(func)
|
|
@@ -162,7 +166,7 @@ class Axes(_Axes):
|
|
|
162
166
|
super().__init__(*args, **kwargs)
|
|
163
167
|
|
|
164
168
|
# handle Series in `ax.plot()`
|
|
165
|
-
if matplotlib_version >= "3.8.0":
|
|
169
|
+
if matplotlib_version >= Version("3.8.0"):
|
|
166
170
|
self._get_lines = PlotArgsProcessor()
|
|
167
171
|
else:
|
|
168
172
|
self._get_lines = PlotArgsProcessor(self)
|
gwpy/plot/plot.py
CHANGED
|
@@ -27,7 +27,12 @@ from itertools import zip_longest
|
|
|
27
27
|
|
|
28
28
|
import numpy
|
|
29
29
|
|
|
30
|
-
from matplotlib import (
|
|
30
|
+
from matplotlib import (
|
|
31
|
+
_pylab_helpers,
|
|
32
|
+
backends,
|
|
33
|
+
figure,
|
|
34
|
+
get_backend,
|
|
35
|
+
)
|
|
31
36
|
from matplotlib.artist import setp
|
|
32
37
|
from matplotlib.gridspec import GridSpec
|
|
33
38
|
from matplotlib.ticker import LogFormatterSciNotation
|
|
@@ -53,7 +58,12 @@ iterable_types = (list, tuple, KeysView, ValuesView,)
|
|
|
53
58
|
def interactive_backend():
|
|
54
59
|
"""Returns `True` if the current backend is interactive
|
|
55
60
|
"""
|
|
56
|
-
|
|
61
|
+
try:
|
|
62
|
+
interactive_bk = backends.backend_registry.list_builtin(
|
|
63
|
+
backends.BackendFilter.INTERACTIVE,
|
|
64
|
+
)
|
|
65
|
+
except AttributeError: # matplotlib < 3.9.0
|
|
66
|
+
from matplotlib.rcsetup import interactive_bk
|
|
57
67
|
return get_backend() in interactive_bk
|
|
58
68
|
|
|
59
69
|
|
gwpy/plot/segments.py
CHANGED
|
@@ -27,7 +27,7 @@ from matplotlib.projections import register_projection
|
|
|
27
27
|
from matplotlib.collections import PatchCollection
|
|
28
28
|
from matplotlib.patches import Rectangle
|
|
29
29
|
|
|
30
|
-
import
|
|
30
|
+
import igwn_segments
|
|
31
31
|
|
|
32
32
|
from .axes import Axes
|
|
33
33
|
from .colors import tint
|
|
@@ -44,10 +44,10 @@ class SegmentAxes(Axes):
|
|
|
44
44
|
This `SegmentAxes` provides custom methods for displaying any of
|
|
45
45
|
|
|
46
46
|
- `~gwpy.segments.DataQualityFlag`
|
|
47
|
-
- `~gwpy.segments.Segment` or :class:`
|
|
48
|
-
- `~gwpy.segments.SegmentList` or :class:`
|
|
47
|
+
- `~gwpy.segments.Segment` or :class:`igwn_segments.segment`
|
|
48
|
+
- `~gwpy.segments.SegmentList` or :class:`igwn_segments.segmentlist`
|
|
49
49
|
- `~gwpy.segments.SegmentListDict` or
|
|
50
|
-
:class:`
|
|
50
|
+
:class:`igwn_segments.segmentlistdict`
|
|
51
51
|
|
|
52
52
|
Parameters
|
|
53
53
|
----------
|
|
@@ -84,9 +84,9 @@ class SegmentAxes(Axes):
|
|
|
84
84
|
return self.plot_dict
|
|
85
85
|
if isinstance(obj, DataQualityFlag):
|
|
86
86
|
return self.plot_flag
|
|
87
|
-
if isinstance(obj,
|
|
87
|
+
if isinstance(obj, igwn_segments.segmentlistdict):
|
|
88
88
|
return self.plot_segmentlistdict
|
|
89
|
-
if isinstance(obj,
|
|
89
|
+
if isinstance(obj, igwn_segments.segmentlist):
|
|
90
90
|
return self.plot_segmentlist
|
|
91
91
|
raise TypeError(
|
|
92
92
|
f"no known {type(self).__name__}.plot_xxx method "
|
|
@@ -106,7 +106,7 @@ class SegmentAxes(Axes):
|
|
|
106
106
|
- `~gwpy.segments.SegmentList`
|
|
107
107
|
- `~gwpy.segments.SegmentListDict`
|
|
108
108
|
|
|
109
|
-
or equivalent types upstream from :mod:`
|
|
109
|
+
or equivalent types upstream from :mod:`igwn_segments`
|
|
110
110
|
|
|
111
111
|
kwargs
|
|
112
112
|
keyword arguments applicable to `~matplotib.axes.Axes.plot`
|
|
@@ -442,7 +442,7 @@ class SegmentFormatter(Formatter):
|
|
|
442
442
|
for patch in self.axis.axes.patches:
|
|
443
443
|
if not patch.get_label() or patch.get_label() == '_nolegend_':
|
|
444
444
|
continue
|
|
445
|
-
if t in
|
|
445
|
+
if t in igwn_segments.segment(*patch.get_bbox().intervaly):
|
|
446
446
|
return patch.get_label()
|
|
447
447
|
return ''
|
|
448
448
|
|
gwpy/plot/tests/test_axes.py
CHANGED
|
@@ -24,16 +24,18 @@ import pytest
|
|
|
24
24
|
import numpy
|
|
25
25
|
|
|
26
26
|
from matplotlib import (
|
|
27
|
-
__version__ as matplotlib_version,
|
|
28
27
|
rcParams,
|
|
29
28
|
)
|
|
30
29
|
from matplotlib.collections import PolyCollection
|
|
31
30
|
from matplotlib.lines import Line2D
|
|
32
31
|
|
|
32
|
+
from packaging.version import Version
|
|
33
|
+
|
|
33
34
|
from ...time import to_gps
|
|
34
35
|
from ...types import (Series, Array2D)
|
|
35
36
|
from ...testing import utils
|
|
36
37
|
from .. import Axes
|
|
38
|
+
from ..axes import matplotlib_version
|
|
37
39
|
from .utils import AxesTestBase
|
|
38
40
|
|
|
39
41
|
numpy.random.seed(0)
|
|
@@ -172,7 +174,7 @@ class TestAxes(AxesTestBase):
|
|
|
172
174
|
array = Array2D(numpy.random.random((10, 10)), dx=.1, dy=.2)
|
|
173
175
|
ax.grid(True, which="both", axis="both")
|
|
174
176
|
mesh = ax.pcolormesh(array)
|
|
175
|
-
if matplotlib_version >= "3.8.0":
|
|
177
|
+
if matplotlib_version >= Version("3.8.0"):
|
|
176
178
|
utils.assert_array_equal(mesh.get_array(), array.T)
|
|
177
179
|
else: # matplotlib < 3.8.0
|
|
178
180
|
utils.assert_array_equal(mesh.get_array(), array.T.flatten())
|
gwpy/plot/tests/test_segments.py
CHANGED
gwpy/segments/__init__.py
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"""This module provides classes for generating and manipulating
|
|
20
20
|
data segments of the form [gps_start, gps_end).
|
|
21
21
|
|
|
22
|
-
The core of this module is adapted from |
|
|
22
|
+
The core of this module is adapted from |igwn-segments|_.
|
|
23
23
|
"""
|
|
24
24
|
|
|
25
25
|
from .segments import (Segment, SegmentList, SegmentListDict)
|
gwpy/segments/flag.py
CHANGED
|
@@ -453,18 +453,20 @@ class DataQualityFlag(object):
|
|
|
453
453
|
Examples
|
|
454
454
|
--------
|
|
455
455
|
>>> from gwpy.segments import DataQualityFlag
|
|
456
|
-
>>> print(DataQualityFlag.fetch_open_data(
|
|
457
|
-
...
|
|
456
|
+
>>> print(DataQualityFlag.fetch_open_data(
|
|
457
|
+
... "H1_DATA",
|
|
458
|
+
... "Sep 14 2015",
|
|
459
|
+
... "Sep 15 2015",
|
|
460
|
+
... ))
|
|
458
461
|
<DataQualityFlag('H1:DATA',
|
|
459
|
-
known=[[
|
|
460
|
-
active=[[
|
|
461
|
-
[
|
|
462
|
-
[
|
|
463
|
-
|
|
464
|
-
[
|
|
465
|
-
[
|
|
466
|
-
[
|
|
467
|
-
[946415770 ... 946422986)],
|
|
462
|
+
known=[[1126224017 ... 1126310417)]
|
|
463
|
+
active=[[1126251604 ... 1126252133)
|
|
464
|
+
[1126252291 ... 1126274322)
|
|
465
|
+
[1126276234 ... 1126281754)
|
|
466
|
+
...
|
|
467
|
+
[1126308670 ... 1126309577)
|
|
468
|
+
[1126309637 ... 1126309817)
|
|
469
|
+
[1126309877 ... 1126310417)]
|
|
468
470
|
description=None)>
|
|
469
471
|
"""
|
|
470
472
|
start = to_gps(start).gpsSeconds
|
gwpy/segments/io/hdf5.py
CHANGED
|
@@ -306,7 +306,7 @@ def write_hdf5_segmentlist(seglist, output, path=None, **kwargs):
|
|
|
306
306
|
|
|
307
307
|
Parameters
|
|
308
308
|
----------
|
|
309
|
-
seglist : :class:`~
|
|
309
|
+
seglist : :class:`~igwn_segments.segmentlist`
|
|
310
310
|
data to write
|
|
311
311
|
|
|
312
312
|
output : `str`, `h5py.File`, `h5py.Group`
|
gwpy/segments/segments.py
CHANGED
|
@@ -24,7 +24,7 @@ configuration.
|
|
|
24
24
|
|
|
25
25
|
from astropy.io import registry as io_registry
|
|
26
26
|
|
|
27
|
-
from
|
|
27
|
+
from igwn_segments import (segment, segmentlist, segmentlistdict)
|
|
28
28
|
|
|
29
29
|
from ..io.mp import read_multi as io_read_multi
|
|
30
30
|
from ..utils.decorators import return_as
|
gwpy/signal/filter_design.py
CHANGED
|
@@ -89,7 +89,7 @@ def _design_fir(wp, ws, sample_rate, gpass, gstop, window='hamming', **kwargs):
|
|
|
89
89
|
if wp[0] > ws[0]:
|
|
90
90
|
kwargs.setdefault('pass_zero', False)
|
|
91
91
|
if ws.shape == (1,):
|
|
92
|
-
kwargs.setdefault(
|
|
92
|
+
kwargs.setdefault("width", ws.item() - wp.item())
|
|
93
93
|
kwargs.setdefault('fs', sample_rate)
|
|
94
94
|
return signal.firwin(nt, wp, window=window, **kwargs)
|
|
95
95
|
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
|
|
22
22
|
__author__ = "Alex Southgate <alex.southgate@ligo.org>"
|
|
23
23
|
|
|
24
|
+
import warnings
|
|
25
|
+
|
|
24
26
|
import numpy as np
|
|
25
27
|
import pytest
|
|
26
28
|
import scipy.signal as sig
|
|
@@ -121,7 +123,11 @@ def test_coherence_resample(unequal_fs_series_data):
|
|
|
121
123
|
# the first coherence val coh12 is broken intentionally since
|
|
122
124
|
# secondarr data should not have fs_1, instead fs_2
|
|
123
125
|
coh12 = spectral.coherence(first, second, segmentlength=seglen)
|
|
124
|
-
|
|
126
|
+
with pytest.warns(
|
|
127
|
+
UserWarning,
|
|
128
|
+
match="Sampling frequencies are unequal",
|
|
129
|
+
):
|
|
130
|
+
coh13 = spectral.coherence(first, third, segmentlength=seglen)
|
|
125
131
|
|
|
126
132
|
# get the frequency at minimum coherence, this should be the extra
|
|
127
133
|
# component in secondarr
|
|
@@ -136,7 +142,7 @@ def test_coherence_resample(unequal_fs_series_data):
|
|
|
136
142
|
assert not (4 <= maxf12.value <= 6)
|
|
137
143
|
|
|
138
144
|
|
|
139
|
-
def
|
|
145
|
+
def test_coherence_resample_downsample(series_data):
|
|
140
146
|
"""Ensure warning is raised by unequal sampling frequencies.
|
|
141
147
|
"""
|
|
142
148
|
firstarr, secondarr, seglen = series_data
|
|
@@ -145,15 +151,30 @@ def test_coherence_resample_arg(series_data):
|
|
|
145
151
|
first = TimeSeries(firstarr, sample_rate=f_s)
|
|
146
152
|
second = TimeSeries(secondarr, sample_rate=f_s * 2.32)
|
|
147
153
|
|
|
148
|
-
with pytest.warns(
|
|
149
|
-
|
|
154
|
+
with pytest.warns(
|
|
155
|
+
UserWarning,
|
|
156
|
+
match="Sampling frequencies are unequal",
|
|
157
|
+
):
|
|
158
|
+
coh1 = spectral.coherence(first, second, segmentlength=seglen)
|
|
150
159
|
|
|
160
|
+
# check that forcibly disabling downsample results in an error
|
|
151
161
|
with pytest.raises(ValueError):
|
|
152
|
-
spectral.coherence(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
162
|
+
spectral.coherence(
|
|
163
|
+
first,
|
|
164
|
+
second,
|
|
165
|
+
segmentlength=seglen,
|
|
166
|
+
downsample=False,
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
# but that accepting downsampling gives you the same result as
|
|
170
|
+
# doing nothing (but doesn't emit a warning)
|
|
171
|
+
with warnings.catch_warnings():
|
|
172
|
+
warnings.simplefilter("error", DeprecationWarning)
|
|
173
|
+
coh2 = spectral.coherence(
|
|
174
|
+
first,
|
|
175
|
+
second,
|
|
176
|
+
segmentlength=seglen,
|
|
177
|
+
downsample=True,
|
|
178
|
+
)
|
|
158
179
|
|
|
159
180
|
assert all(np.array(coh1.data) == np.array(coh2.data))
|
gwpy/table/io/ligolw.py
CHANGED
|
@@ -70,7 +70,7 @@ def test_to_astropy_table_empty():
|
|
|
70
70
|
tab = EventTable(llwtable, columns=["peak", "ifo"])
|
|
71
71
|
assert set(tab.colnames) == {"peak", "ifo"}
|
|
72
72
|
assert tab['peak'].dtype.type is numpy.object_
|
|
73
|
-
assert tab['ifo'].dtype.type is numpy.
|
|
73
|
+
assert tab['ifo'].dtype.type is numpy.str_
|
|
74
74
|
|
|
75
75
|
|
|
76
76
|
@pytest.mark.requires("ligo.lw.lsctables")
|
gwpy/testing/errors.py
CHANGED
gwpy/testing/marks.py
CHANGED
gwpy/timeseries/core.py
CHANGED
|
@@ -793,7 +793,6 @@ class TimeSeriesBase(Series):
|
|
|
793
793
|
op_ = ufunc.__name__
|
|
794
794
|
out = out.view(StateTimeSeries)
|
|
795
795
|
out.__metadata_finalize__(orig)
|
|
796
|
-
out.override_unit('')
|
|
797
796
|
oname = orig.name if isinstance(orig, type(self)) else orig
|
|
798
797
|
vname = value.name if isinstance(value, type(self)) else value
|
|
799
798
|
out.name = '{0!s} {1!s} {2!s}'.format(oname, op_, vname)
|
gwpy/timeseries/statevector.py
CHANGED
|
@@ -184,8 +184,10 @@ class StateTimeSeries(TimeSeriesBase):
|
|
|
184
184
|
def unit(self):
|
|
185
185
|
return units.dimensionless_unscaled
|
|
186
186
|
|
|
187
|
-
def override_unit(self,
|
|
188
|
-
|
|
187
|
+
def override_unit(self, *args, **kwargs):
|
|
188
|
+
raise NotImplementedError(
|
|
189
|
+
f"overriding units is not supported for {type(self).__name__}",
|
|
190
|
+
)
|
|
189
191
|
|
|
190
192
|
def _to_own_unit(self, value, check_precision=True):
|
|
191
193
|
if isinstance(value, units.Quantity) and value.unit != self.unit:
|
|
@@ -53,7 +53,8 @@ class TestTimeSeriesBase(_TestSeries):
|
|
|
53
53
|
def test_new(self):
|
|
54
54
|
"""Test `gwpy.timeseries.TimeSeriesBase` constructor
|
|
55
55
|
"""
|
|
56
|
-
array =
|
|
56
|
+
array = self.create()
|
|
57
|
+
super().test_new()
|
|
57
58
|
|
|
58
59
|
# check time-domain metadata
|
|
59
60
|
assert array.epoch == GPS_EPOCH
|
|
@@ -145,7 +146,7 @@ class TestTimeSeriesBase(_TestSeries):
|
|
|
145
146
|
def test_sample_rate_ghz(self, array):
|
|
146
147
|
"""Test that very large sample rates don't get rounded to dt=0.
|
|
147
148
|
|
|
148
|
-
Regression: https://
|
|
149
|
+
Regression: https://gitlab.com/gwpy/gwpy/-/issues/1646
|
|
149
150
|
"""
|
|
150
151
|
array.sample_rate = 1e9
|
|
151
152
|
assert array.dt.value > 0.
|
|
@@ -400,20 +401,13 @@ class TestTimeSeriesBaseDict(object):
|
|
|
400
401
|
|
|
401
402
|
def test_resample(self, instance):
|
|
402
403
|
if self.ENTRY_CLASS is TimeSeriesBase: # currently only for subclasses
|
|
403
|
-
|
|
404
|
+
pytest.skip(f"not implemented for {type(instance).__name__}")
|
|
405
|
+
|
|
406
|
+
# for all subclasses
|
|
404
407
|
a = instance.resample(.5)
|
|
405
408
|
for key in a:
|
|
406
409
|
assert a[key].dx == 1/.5 * a[key].xunit
|
|
407
410
|
|
|
408
|
-
def test_fetch(self):
|
|
409
|
-
return NotImplemented
|
|
410
|
-
|
|
411
|
-
def test_find(self):
|
|
412
|
-
return NotImplemented
|
|
413
|
-
|
|
414
|
-
def test_get(self):
|
|
415
|
-
return NotImplemented
|
|
416
|
-
|
|
417
411
|
@pytest.mark.requires("nds2")
|
|
418
412
|
def test_from_nds2_buffers(self):
|
|
419
413
|
buffers = [
|
|
@@ -445,7 +439,7 @@ class TestTimeSeriesBaseDict(object):
|
|
|
445
439
|
def test_plot_separate(self, instance):
|
|
446
440
|
"""Test plotting `TimeSeriesDict` on separate axes.
|
|
447
441
|
|
|
448
|
-
See https://
|
|
442
|
+
See https://gitlab.com/gwpy/gwpy/-/issues/1609
|
|
449
443
|
"""
|
|
450
444
|
with rc_context(rc={'text.usetex': False}):
|
|
451
445
|
plot = instance.plot(separate=True)
|
|
@@ -63,7 +63,7 @@ def test_read_scaled_type_change(int32ts, tmp_path):
|
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
def test_read_write_frvect_name(tmp_path):
|
|
66
|
-
"""Test against regression of https://
|
|
66
|
+
"""Test against regression of https://gitlab.com/gwpy/gwpy/-/issues/1206
|
|
67
67
|
"""
|
|
68
68
|
data = TimeSeries(
|
|
69
69
|
numpy.random.random(10),
|