Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shielded libstempo dependencies if only pint installed #184

Merged
merged 3 commits into from
May 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions enterprise/pulsar.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
try:
import libstempo as t2
except ImportError:
print('ERROR: Must have libstempo package installed!')
print('Ooh, no libstempo?')
t2 = None

try:
Expand All @@ -35,6 +35,10 @@

import astropy.units as u

if pint is None and t2 is None:
err_msg = 'Must have either PINT or libstempo timing package installed'
raise ImportError(err_msg)


def get_maxobs(timfile):
"""Utility function to return number of lines in tim file.
Expand Down Expand Up @@ -450,11 +454,12 @@ def Pulsar(*args, **kwargs):
drop_t2pulsar = kwargs.get('drop_t2pulsar', True)
timing_package = kwargs.get('timing_package', 'tempo2')

if pint:
if pint is not None:
toas = list(filter(lambda x: isinstance(x, toa.TOAs), args))
model = list(filter(lambda x: isinstance(x, TimingModel), args))

t2pulsar = list(filter(lambda x: isinstance(x, t2.tempopulsar), args))
if t2 is not None:
t2pulsar = list(filter(lambda x: isinstance(x, t2.tempopulsar), args))

parfile = list(filter(lambda x: isinstance(x, str) and
x.split('.')[-1] == 'par', args))
Expand Down