Skip to content

Commit

Permalink
Fix 'waves is None' check
Browse files Browse the repository at this point in the history
  • Loading branch information
hugobuddel committed Oct 28, 2024
1 parent 6930beb commit e4c2c09
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions spextra/spextra.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,9 @@ def flat_spectrum(
spex : Spextrum
New ``Spextrum`` instance.
"""
waves = (waves or _default_waves()).to(u.AA).value
if waves is None:
waves = _default_waves()
waves = waves.to(u.AA).value

# The if-statement below also allowed amplitude.unit to be
# u.Unit("vegamag"). Vegamag is removed from astropy, so the
Expand Down Expand Up @@ -509,7 +511,9 @@ def black_body_spectrum(
-------
a scaled black-body spectrum
"""
waves = (waves or _default_waves()).to(u.AA)
if waves is None:
waves = _default_waves()
waves = waves.to(u.AA)

Check warning on line 516 in spextra/spextra.py

View check run for this annotation

Codecov / codecov/patch

spextra/spextra.py#L514-L516

Added lines #L514 - L516 were not covered by tests
blackbody = BlackBody1D(temperature=temperature.to(u.K).value)

spex = cls(modelclass=Empirical1D, points=waves,
Expand Down Expand Up @@ -558,7 +562,9 @@ def powerlaw(
spex : Spextrum
New ``Spextrum`` instance.
"""
waves = (waves or _default_waves()).to(u.AA)
if waves is None:
waves = _default_waves()
waves = waves.to(u.AA)

Check warning on line 567 in spextra/spextra.py

View check run for this annotation

Codecov / codecov/patch

spextra/spextra.py#L565-L567

Added lines #L565 - L567 were not covered by tests
power = SourceSpectrum(
PowerLawFlux1D, amplitude=1, x_0=x_0, alpha=alpha)
spex = cls(modelclass=Empirical1D, points=waves,
Expand Down

0 comments on commit e4c2c09

Please sign in to comment.