Skip to content

Commit

Permalink
Update submodules before installing (#240)
Browse files Browse the repository at this point in the history
* Resolve another unit test for datafind.get_data under conda

Check that submodule is populated

* Embellish the error message a little
  • Loading branch information
Alex L. Urban committed Mar 4, 2019
1 parent 68bbe80 commit d3bb4b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
6 changes: 6 additions & 0 deletions _setup_utils.py
Expand Up @@ -41,6 +41,12 @@
SASS_FILES = glob.glob(os.path.join('share', 'sass', '[!_]*.scss')) + (
glob.glob(os.path.join('bootstrap-ligo', 'css', '[!_]*.scss')))

# make sure submodule is not empty
static = glob.glob(os.path.join('bootstrap-ligo', '*'))
if not static:
raise ValueError('bootstrap-ligo submodule is empty, please populate it '
'with `git submodule update --init`')


# -- custom commands ----------------------------------------------------------

Expand Down
26 changes: 9 additions & 17 deletions gwdetchar/io/tests/test_datafind.py
Expand Up @@ -19,9 +19,6 @@
"""Tests for `gwdetchar.io.datafind`
"""

import os
import shutil

import pytest

import numpy
Expand Down Expand Up @@ -86,40 +83,35 @@ def test_get_data_dict_from_NDS(tsdfetch):
nptest.assert_array_equal(data['X1:TEST-STRAIN'].value, HOFT.value)


def test_get_data_from_cache(tmpdir):
# set up a data file
os.chdir(str(tmpdir))
HOFT.write('test.gwf')

@mock.patch('gwpy.timeseries.TimeSeries.read',
return_value=HOFT.crop(16, 48))
def test_get_data_from_cache(tsfetch):
# retrieve test frame
start = 16
end = start + 32
channel = 'X1:TEST-STRAIN'
data = datafind.get_data(channel, start, end, source='test.gwf')
data = datafind.get_data(channel, start, end, source=True)

# test data products
assert isinstance(data, TimeSeries)
assert data.duration.value == 32
assert data.span == Segment(start, end)
nptest.assert_array_equal(data.value, HOFT.crop(start, end).value)
shutil.rmtree(str(tmpdir), ignore_errors=True)


def test_get_data_dict_from_cache(tmpdir):
# set up a data file
os.chdir(str(tmpdir))
HOFT.write('test.gwf')

@mock.patch('gwpy.timeseries.TimeSeriesDict.read',
return_value=TimeSeriesDict({
'X1:TEST-STRAIN': HOFT.crop(16, 48)}))
def test_get_data_dict_from_cache(tsdfetch):
# retrieve test frame
start = 16
end = start + 32
channels = ['X1:TEST-STRAIN']
data = datafind.get_data(channels, start, end, source='test.gwf')
data = datafind.get_data(channels, start, end, source=True)

# test data products
assert isinstance(data, TimeSeriesDict)
assert data[channels[0]].duration.value == 32
assert data[channels[0]].span == Segment(start, end)
nptest.assert_array_equal(data[channels[0]].value,
HOFT.crop(start, end).value)
shutil.rmtree(str(tmpdir), ignore_errors=True)

0 comments on commit d3bb4b7

Please sign in to comment.