Skip to content

Commit

Permalink
Shielded libstempo dependencies if only pint installed (#184)
Browse files Browse the repository at this point in the history
* libstempo no longer required if user has pint installed

* Fixed lint import issue.

* Fixed lint import issue #2.
  • Loading branch information
Hazboun6 authored May 16, 2019
1 parent 954b03c commit 057a889
Showing 1 changed file with 8 additions and 3 deletions.
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

0 comments on commit 057a889

Please sign in to comment.