From 6a34c3879fca618daf3e6785882c8f0a52ee58ab Mon Sep 17 00:00:00 2001 From: Nicholas Earl Date: Fri, 13 Sep 2019 13:42:17 -0400 Subject: [PATCH] Stricter spectrum1d initialializer --- specutils/spectra/spectrum1d.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/specutils/spectra/spectrum1d.py b/specutils/spectra/spectrum1d.py index b45280168..325d44746 100644 --- a/specutils/spectra/spectrum1d.py +++ b/specutils/spectra/spectrum1d.py @@ -41,7 +41,15 @@ class Spectrum1D(OneDSpectrumMixin, NDDataRef): around with the spectrum container object. """ def __init__(self, flux=None, spectral_axis=None, wcs=None, - velocity_convention=None, rest_value=None, *args, **kwargs): + velocity_convention=None, rest_value=None, **kwargs): + # Check for pre-defined entries in the kwargs dictionary. + unknown_kwargs = set(kwargs).difference( + {'data', 'unit', 'uncertainty', 'meta', 'mask', 'copy'}) + + if len(unknown_kwargs) > 0: + raise ValueError("Initializer contains unknown arguments(s): {}." + "".format(', '.join(map(str, unknown_kwargs)))) + # If the flux (data) argument is a subclass of nddataref (as it would # be for internal arithmetic operations), avoid setup entirely. if isinstance(flux, NDDataRef):