Skip to content

Commit

Permalink
Avoid build test failures (#223)
Browse files Browse the repository at this point in the history
* Use TeX only if it's available

gwpy.signal.fft has been renamed gwpy.signal.spectral

* Remove all references to gwpy.signal.spectral from gwsumm.data.utils
  • Loading branch information
Alex L. Urban authored Mar 4, 2019
1 parent 771c846 commit 19c7536
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 39 deletions.
23 changes: 0 additions & 23 deletions gwsumm/data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,12 @@
from ligo.segments import segmentlist as LigoSegmentList

from gwpy.segments import (DataQualityFlag, SegmentList, Segment)
from gwpy.signal.fft import (get_default_fft_api, lal as fft_lal)
from gwpy.signal.fft.registry import get_method as get_fft_method

from ..channels import get_channel
from ..config import GWSummConfigParser

__author__ = 'Duncan Macleod <duncan.macleod@ligo.org>'

FFT_API = get_default_fft_api()

# get FFT scheme
FFT_SCHEME = None
if FFT_API.startswith('pycbc'):
from pycbc.scheme import (DefaultScheme, MKLScheme)
try:
FFT_SCHEME = MKLScheme()
except RuntimeError:
FFT_SCHEME = DefaultScheme()
elif FFT_API == 'lal':
fft_lal.LAL_FFTPLAN_LEVEL = 2


# -- method decorators --------------------------------------------------------

def use_segmentlist(f):
Expand Down Expand Up @@ -97,7 +81,6 @@ def decorated_func(*args, **kwargs):

DEFAULT_FFT_PARAMS = {
'method': 'median',
'scheme': FFT_SCHEME,
}


Expand Down Expand Up @@ -164,12 +147,6 @@ def get_fftparams(channel, **defaults):
raise ZeroDivisionError("Cannot generate spectrogram with stride "
"length of 0")

# unwrap method
method_func = get_fft_method(fftparams.method)
if method_func.__module__.rsplit('.', 1)[-1] == 'basic':
fftmod = FFT_API.split('.', 1)[0]
fftparams.method = '{0}-{1}'.format(fftmod, fftparams.method)

return fftparams


Expand Down
18 changes: 11 additions & 7 deletions gwsumm/plot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
__author__ = 'Duncan Macleod <duncan.macleod@ligo.org>'

from matplotlib import rcParams
from gwpy.plot.tex import MACROS as GWPY_TEX_MACROS
from gwpy.plot.tex import (has_tex, MACROS as GWPY_TEX_MACROS)

from .registry import *
from .utils import *
Expand All @@ -57,12 +57,6 @@
from .sei import *

rcParams.update({
# reproduce GWPY_TEX_PARAMS
'text.usetex': True,
'text.latex.preamble': (
rcParams.get('text.latex.preamble', []) + GWPY_TEX_MACROS),
'font.family': ['serif'],
'axes.formatter.use_mathtext': False,
# custom GWSumm formatting
'font.size': 10,
'xtick.labelsize': 18,
Expand All @@ -73,3 +67,13 @@
'figure.figsize': (12, 6),
'svg.fonttype': 'none',
})

if has_tex():
rcParams.update({
# reproduce GWPY_TEX_RCPARAMS
'text.usetex': True,
'text.latex.preamble': (
rcParams.get('text.latex.preamble', []) + GWPY_TEX_MACROS),
'font.family': ['serif'],
'axes.formatter.use_mathtext': False,
})
12 changes: 3 additions & 9 deletions gwsumm/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@
}
LOSC_SEGMENTS = SegmentList([Segment(1126259446, 1126259478)])

FFT_SCHEME_NAME = type(utils.FFT_SCHEME).__name__ if utils.FFT_SCHEME else ''


def download(remote, target=None):
"""Download a file
Expand Down Expand Up @@ -127,20 +125,16 @@ def test_make_globalv_key(self):
'', # overlap
'test-window', # window
'123.456', # stride
FFT_SCHEME_NAME, # FFT scheme
'', # FFT scheme
])

def test_get_fftparams(self):
fftparams = utils.get_fftparams('L1:TEST-CHANNEL')
assert isinstance(fftparams, utils.FftParams)

for key in utils.FFT_PARAMS.keys():
if key == 'method':
assert fftparams.method == '{0}-{1}'.format(
utils.FFT_API.split('.')[0], utils.DEFAULT_FFT_PARAMS[key])
else:
assert (getattr(fftparams, key) is
utils.DEFAULT_FFT_PARAMS.get(key, None))
assert (getattr(fftparams, key) is
utils.DEFAULT_FFT_PARAMS.get(key, None))

fftparams = utils.get_fftparams('L1:TEST-CHANNEL', window='hanning',
overlap=0)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ enum34 ; python_version < '3'
python-dateutil
lxml
numpy>=1.10
scipy>=1.2.0
matplotlib>=2.0
astropy>=1.2.1
lalsuite
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
'python-dateutil',
'lxml',
'numpy>=1.10',
'scipy>=1.2.0',
'matplotlib>=2.2.0',
'astropy>=1.2.1',
'lalsuite',
Expand Down

0 comments on commit 19c7536

Please sign in to comment.