diff --git a/docs/arithmetic.rst b/docs/arithmetic.rst index dbdfbfa93..f46c6a834 100644 --- a/docs/arithmetic.rst +++ b/docs/arithmetic.rst @@ -28,22 +28,19 @@ Arithmetic support includes addition, subtract, multiplication, and division. >>> spec2 = Spectrum1D(spectral_axis=np.arange(1, 50) * u.nm, flux=np.random.sample(49)*u.Jy) >>> spec3 = spec1 + spec2 >>> spec3 #doctest:+SKIP - Spectrum1D([1.42980955, 0.76450583, 0.53973912, 1.12714653, 1.46747729, - 0.98485104, 1.13618017, 1.02447445, 0.68610084, 0.85083215, - 0.57521794, 1.16854341, 1.05139223, 1.44550638, 1.67533841, - 1.41277807, 0.46008942, 1.1399328 , 0.41708163, 0.61282024, - 0.40034388, 0.95204057, 0.98280167, 1.30647318, 1.43317265, - 0.71426198, 0.58622459, 1.17063336, 1.37244261, 1.06886942, - 1.54349149, 1.15019089, 0.51719866, 1.23114699, 1.16464384, - 0.90833751, 1.04018595, 1.34931354, 1.01936352, 0.39543304, - 1.22407522, 0.34658842, 1.18760707, 1.38161461, 1.05829078, - 1.57852604, 1.13365571, 0.59304282, 1.3913748 ]) - >>> spec3.wavelength - + , spectral_axis=)> Propagation of Uncertainties diff --git a/specutils/spectra/spectrum1d.py b/specutils/spectra/spectrum1d.py index a861832ea..08d88312b 100644 --- a/specutils/spectra/spectrum1d.py +++ b/specutils/spectra/spectrum1d.py @@ -262,11 +262,14 @@ def __str__(self): return result def __repr__(self): - if self.wcs: - result = "".format( - repr(self.flux), repr(self.spectral_axis)) - else: - result = "".format(repr(self.flux)) + inner_str = "flux={}, spectral_axis={}".format(repr(self.flux), + repr(self.spectral_axis)) + + if self.uncertainty is not None: + inner_str += ", uncertainty={}".format(repr(self.uncertainty)) + + result = "".format(inner_str) + return result diff --git a/specutils/tests/test_spectrum1d.py b/specutils/tests/test_spectrum1d.py index b65f618c9..510dfbefa 100644 --- a/specutils/tests/test_spectrum1d.py +++ b/specutils/tests/test_spectrum1d.py @@ -234,9 +234,14 @@ def test_repr(): assert result.startswith(''.format(repr(spec_without_wcs.flux)) + spec_with_unc = Spectrum1D(spectral_axis=np.linspace(100, 1000, 10) * u.nm, + flux=np.random.random(10) * u.Jy, + uncertainty=StdDevUncertainty( + np.random.sample(50), unit='Jy')) + result = repr(spec_with_unc) + assert result.startswith('