コード例 #1
0
ファイル: test_archive.py プロジェクト: berkowitze/gwsumm
 def test_write_archive(self, delete=True):
     data.add_timeseries(TEST_DATA)
     fname = tempfile.mktemp(suffix='.hdf', prefix='gwsumm-tests-')
     try:
         archive.write_data_archive(fname)
     finally:
         if delete and os.path.isfile(fname):
             os.remove(fname)
     return fname
コード例 #2
0
ファイル: test_archive.py プロジェクト: idorrington92/gwsumm
 def test_write_archive(self, delete=True):
     data.add_timeseries(TEST_DATA)
     fname = tempfile.mktemp(suffix='.hdf', prefix='gwsumm-tests-')
     try:
         archive.write_data_archive(fname)
     finally:
         if delete and os.path.isfile(fname):
             os.remove(fname)
     return fname
コード例 #3
0
ファイル: test_data.py プロジェクト: berkowitze/gwsumm
 def test_get_timeseries(self):
     # test simple get after add
     a = TimeSeries([1, 2, 3, 4, 5], name='test name', epoch=0,
                    sample_rate=1)
     data.add_timeseries(a)
     b = data.get_timeseries('test name', [(0, 5)])
     self.assertEqual(a, b)
     # test more complicated add with a cache
     a = data.get_timeseries('H1:LOSC-STRAIN', LOSC_SEGMENTS,
                             cache=self.FRAMES['H1:LOSC-STRAIN'])
     b = data.get_timeseries('H1:LOSC-STRAIN', LOSC_SEGMENTS)
     self.assertEqual(a, b)
コード例 #4
0
 def test_get_timeseries(self):
     # test simple get after add
     a = TimeSeries([1, 2, 3, 4, 5],
                    name='test name',
                    epoch=0,
                    sample_rate=1)
     data.add_timeseries(a)
     b = data.get_timeseries('test name', [(0, 5)])
     self.assertEqual(a, b)
     # test more complicated add with a cache
     a = data.get_timeseries('H1:LOSC-STRAIN',
                             LOSC_SEGMENTS,
                             cache=self.FRAMES['H1:LOSC-STRAIN'])
     b = data.get_timeseries('H1:LOSC-STRAIN', LOSC_SEGMENTS)
     self.assertEqual(a, b)
コード例 #5
0
ファイル: test_data.py プロジェクト: gwpy/gwsumm
    def test_get_timeseries(self):
        # empty globalv.DATA
        globalv.DATA = type(globalv.DATA)()

        # test simple get after add
        a = TimeSeries([1, 2, 3, 4, 5], name='test name', epoch=0,
                       sample_rate=1)
        data.add_timeseries(a)
        b, = data.get_timeseries('test name', [(0, 5)], nproc=1)
        nptest.assert_array_equal(a.value, b.value)
        assert a.sample_rate.value == b.sample_rate.value

        # test more complicated add with a cache
        a, = data.get_timeseries('H1:LOSC-STRAIN', LOSC_SEGMENTS,
                                 cache=self.FRAMES['H1:LOSC-STRAIN'],
                                 nproc=1)
        b, = data.get_timeseries('H1:LOSC-STRAIN', LOSC_SEGMENTS,
                                 nproc=1)
        nptest.assert_array_equal(a.value, b.value)
コード例 #6
0
    def test_get_timeseries(self):
        # empty globalv.DATA
        globalv.DATA = type(globalv.DATA)()

        # test simple get after add
        a = TimeSeries([1, 2, 3, 4, 5],
                       name='test name',
                       epoch=0,
                       sample_rate=1)
        data.add_timeseries(a)
        b, = data.get_timeseries('test name', [(0, 5)], nproc=1)
        nptest.assert_array_equal(a.value, b.value)
        assert a.sample_rate.value == b.sample_rate.value

        # test more complicated add with a cache
        a, = data.get_timeseries('H1:LOSC-STRAIN',
                                 LOSC_SEGMENTS,
                                 cache=self.FRAMES['H1:LOSC-STRAIN'],
                                 nproc=1)
        b, = data.get_timeseries('H1:LOSC-STRAIN', LOSC_SEGMENTS, nproc=1)
        nptest.assert_array_equal(a.value, b.value)
コード例 #7
0
    def test_add_timeseries(self):
        a = TimeSeries([1, 2, 3, 4, 5],
                       name='test name',
                       epoch=0,
                       sample_rate=1)

        # test simple add using 'name'
        data.add_timeseries(a)
        assert 'test name' in globalv.DATA
        assert len(globalv.DATA['test name']) == 1
        assert globalv.DATA['test name'][0] is a

        # test add using key kwarg
        data.add_timeseries(a, key='test key')
        assert globalv.DATA['test key'][0] is a

        # test add to existing key with coalesce
        b = TimeSeries([6, 7, 8, 9, 10],
                       name='test name 2',
                       epoch=5,
                       sample_rate=1)
        data.add_timeseries(b, key='test key', coalesce=True)
        assert len(globalv.DATA['test key']) == 1
        nptest.assert_array_equal(globalv.DATA['test key'][0].value,
                                  arange(1, 11))
コード例 #8
0
ファイル: test_data.py プロジェクト: berkowitze/gwsumm
 def test_add_timeseries(self):
     a = TimeSeries([1, 2, 3, 4, 5], name='test name', epoch=0,
                    sample_rate=1)
     # test simple add using 'name'
     data.add_timeseries(a)
     self.assertIn('test name', globalv.DATA)
     self.assertEqual(globalv.DATA['test name'], [a])
     # test add using key kwarg
     data.add_timeseries(a, key='test key')
     self.assertIn('test key', globalv.DATA)
     self.assertEqual(globalv.DATA['test key'], [a])
     # test add to existing key with coalesce
     b = TimeSeries([6, 7, 8, 9, 10], name='test name 2', epoch=5,
                    sample_rate=1)
     data.add_timeseries(b, key='test key', coalesce=True)
     self.assertEqual(globalv.DATA['test key'],
                      [a.append(b, inplace=False)])
コード例 #9
0
ファイル: test_data.py プロジェクト: gwpy/gwsumm
    def test_add_timeseries(self):
        a = TimeSeries([1, 2, 3, 4, 5], name='test name', epoch=0,
                       sample_rate=1)

        # test simple add using 'name'
        data.add_timeseries(a)
        assert 'test name' in globalv.DATA
        assert len(globalv.DATA['test name']) == 1
        assert globalv.DATA['test name'][0] is a

        # test add using key kwarg
        data.add_timeseries(a, key='test key')
        assert globalv.DATA['test key'][0] is a

        # test add to existing key with coalesce
        b = TimeSeries([6, 7, 8, 9, 10], name='test name 2', epoch=5,
                       sample_rate=1)
        data.add_timeseries(b, key='test key', coalesce=True)
        assert len(globalv.DATA['test key']) == 1
        nptest.assert_array_equal(globalv.DATA['test key'][0].value,
                                  arange(1, 11))
コード例 #10
0
 def test_add_timeseries(self):
     a = TimeSeries([1, 2, 3, 4, 5],
                    name='test name',
                    epoch=0,
                    sample_rate=1)
     # test simple add using 'name'
     data.add_timeseries(a)
     self.assertIn('test name', globalv.DATA)
     self.assertEqual(globalv.DATA['test name'], [a])
     # test add using key kwarg
     data.add_timeseries(a, key='test key')
     self.assertIn('test key', globalv.DATA)
     self.assertEqual(globalv.DATA['test key'], [a])
     # test add to existing key with coalesce
     b = TimeSeries([6, 7, 8, 9, 10],
                    name='test name 2',
                    epoch=5,
                    sample_rate=1)
     data.add_timeseries(b, key='test key', coalesce=True)
     self.assertEqual(globalv.DATA['test key'],
                      [a.append(b, inplace=False)])
コード例 #11
0
ファイル: test_archive.py プロジェクト: gwpy/gwsumm
def test_write_archive(delete=True):
    empty_globalv()
    data.add_timeseries(TEST_DATA)
    data.add_timeseries(create([1, 2, 3, 4, 5],
                               dt=60., channel='X1:TEST-TREND.mean'))
    data.add_timeseries(create([1, 2, 3, 2, 1],
                               series_class=StateVector,
                               channel='X1:TEST-STATE_VECTOR'))
    data.add_spectrogram(create([[1, 2, 3], [3, 2, 1], [1, 2, 3]],
                                series_class=Spectrogram,
                                channel='X1:TEST-SPECTROGRAM'))
    t = EventTable(random.random((100, 5)), names=['time', 'a', 'b', 'c', 'd'])
    t.meta['segments'] = SegmentList([Segment(0, 100)])
    triggers.add_triggers(t, 'X1:TEST-TABLE,testing')
    fname = tempfile.mktemp(suffix='.h5', prefix='gwsumm-tests-')
    try:
        archive.write_data_archive(fname)
        archive.write_data_archive(fname)  # test again to validate backups
    finally:
        if delete and os.path.isfile(fname):
            os.remove(fname)
    return fname
コード例 #12
0
ファイル: test_archive.py プロジェクト: tjma12/gwsumm
def test_write_archive(delete=True):
    empty_globalv()
    data.add_timeseries(TEST_DATA)
    data.add_timeseries(create([1, 2, 3, 4, 5],
                               dt=60., channel='X1:TEST-TREND.mean'))
    data.add_timeseries(create([1, 2, 3, 2, 1],
                               series_class=StateVector,
                               channel='X1:TEST-STATE_VECTOR'))
    data.add_spectrogram(create([[1, 2, 3], [3, 2, 1], [1, 2, 3]],
                                series_class=Spectrogram,
                                channel='X1:TEST-SPECTROGRAM'))
    t = EventTable(random.random((100, 5)), names=['time', 'a', 'b', 'c', 'd'])
    t.meta['segments'] = SegmentList([Segment(0, 100)])
    triggers.add_triggers(t, 'X1:TEST-TABLE,testing')
    fname = tempfile.mktemp(suffix='.h5', prefix='gwsumm-tests-')
    try:
        archive.write_data_archive(fname)
        archive.write_data_archive(fname)  # test again to validate backups
    finally:
        if delete and os.path.isfile(fname):
            os.remove(fname)
    return fname