Skip to content

Commit

Permalink
Replace two asserts with exception raises, if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
scottransom committed Jul 10, 2022
1 parent c3e3dd2 commit a92f788
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/pint/models/timing_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1520,14 +1520,18 @@ def get_spin_freq(self, times, calctype="modelF0"):
"numerical" is significantly slower, but is much more exact, and
"""
calc = calctype.lower()
assert calc in ["modelf0", "taylor", "numerical"]
if calc not in ["modelf0", "taylor", "numerical"]:
raise ValueError(
"calctype must be one of ['modelf0', 'taylor'', 'numerical']"
)

if calc == "modelf0":
return self.F0.quantity

# ToDo: How does this handle Glitch or Piecewise models?
if calc == "numerical":
assert isinstance(times, TOAs)
if not isinstance(times, TOAs):
raise TypeError("times must be TOAs when using calctype='numerical'")
return self.d_phase_d_toa(times)

# Handle various types of input times for "taylor" calc
Expand Down

0 comments on commit a92f788

Please sign in to comment.