Inplace multiplication of the spectral axis with a constant fails
- Dominant language
- Python
- Stars
- 204
- Forks
- 134
- Avg merge
- 12h 55m
- Merged PRs (30d)
- 1
Description
As the title says, inplace multiplication of the spectral axis with a constant fails.
It produces the following error:
```
astropy.units.core.UnitTypeError: Cannot store output with unit 'Angstrom' from multiply function in instance. Use instance instead.
```
Here is the minimal working code:
```
import numpy as np
from astropy import units as u
from specutils.spectra import Spectrum1D
wave = np.linspace(100, 200, 100) << u.AA
flux = np.ones(100) << u.one
spec = Spectrum1D(spectral_axis=wave, flux=flux)
spec._spectral_axis *= 1
```
Contributor guide
Research direction
Run the minimal reproduction and inspect specutils.spectra.spectral_axis.SpectralAxis together with the Astropy unit error. Determine why in-place multiplication rejects the output, then verify that multiplying the spectral axis by a constant completes without UnitTypeError and preserves the expected spectral-axis values and units.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100