Skip to content

Commit

Permalink
Merge pull request #520 from nmearl/fix-issue-517
Browse files Browse the repository at this point in the history
Better error message for incompatible units
  • Loading branch information
nmearl committed Sep 26, 2019
2 parents 3636758 + 748ca21 commit 60a1653
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions specutils/fitting/fitmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,13 @@ class instantiation.

v = current_value.to(m_orig_param_quantity.unit,
equivalencies=u.equivalencies.spectral_density(dispersion))
else:
raise ValueError(
"The parameter '{}' with unit '{}' is not convertible "
"to either the current flux unit '{}' or spectral "
"axis unit '{}'.".format(
m_orig_param.name, m_orig_param.unit,
spectrum.flux.unit, spectrum.spectral_axis.unit))

else:
v = getattr(m_in, pn).value
Expand Down

0 comments on commit 60a1653

Please sign in to comment.