17"""Tests for lalframe.frread
23 from pathlib
import Path
24except ImportError
as exc:
26 warnings.warn(str(exc))
34from lalframe
import frread
37 from glue.lal
import Cache
41 Cache.entry_class = CacheEntry
44TEST_PATH = Path(os.getenv(
46 Path(__file__).parent,
48TEST_GWF = TEST_PATH /
"F-TEST-600000060-60.gwf"
53 lal.CacheGlob(str(TEST_GWF.parent), TEST_GWF.name),
56 SOURCES.append(
Cache([CacheEntry.from_T050017(str(TEST_GWF))]))
59@pytest.mark.parametrize("source", SOURCES)
61 ts = frread.read_timeseries(
65 assert ts.name ==
"H1:LSC-AS_Q"
66 assert ts.data.length == 16384 * 60
67 assert ts.deltaT == 6.103515625e-05
70@pytest.mark.parametrize(
"instart, induration, outstart, outduration", [
71 (
None,
None, 600000060, 60),
72 (600000061,
None, 600000061, 59),
73 (
None, 30, 600000060, 30),
74 (600000061, 1, 600000061, 1),
82 ts = frread.read_timeseries(
88 assert ts.epoch == outstart
89 assert ts.data.length * ts.deltaT == outduration
92@pytest.mark.parametrize(
"inputs, message", [
93 ((
"does-not-exist.gwf",
"channel"),
94 "Internal function call failed: I/O error"),
95 ((str(TEST_GWF),
"bad-channel"),
"Wrong name"),
98 with pytest.raises(RuntimeError)
as exc:
99 frread.read_timeseries(*inputs)
100 assert str(exc.value) == message
103if __name__ ==
'__main__':
104 args = sys.argv[1:]
or [
"-v",
"-rs",
"--junit-xml=junit-frread.xml"]
105 sys.exit(pytest.main(args=[__file__] + args))
def test_read_timeseries(source)
def test_read_timeseries_start_duration(instart, induration, outstart, outduration)
def test_read_timeseries_error(inputs, message)