diff --git a/src/easydynamics/sample_model/components/damped_harmonic_oscillator.py b/src/easydynamics/sample_model/components/damped_harmonic_oscillator.py index 86fd6c0b..e7ea9561 100644 --- a/src/easydynamics/sample_model/components/damped_harmonic_oscillator.py +++ b/src/easydynamics/sample_model/components/damped_harmonic_oscillator.py @@ -26,9 +26,9 @@ class DampedHarmonicOscillator(CreateParametersMixin, ModelComponent): def __init__( self, - area: Numeric | Parameter = 1.0, - center: Numeric | Parameter = 1.0, - width: Numeric | Parameter = 1.0, + area: Numeric = 1.0, + center: Numeric = 1.0, + width: Numeric = 1.0, unit: str | sc.Unit = 'meV', name: str = 'DampedHarmonicOscillator', display_name: str | None = None, @@ -39,11 +39,11 @@ def __init__( Parameters ---------- - area : Numeric | Parameter, default=1.0 + area : Numeric, default=1.0 Area under the curve. - center : Numeric | Parameter, default=1.0 + center : Numeric, default=1.0 Resonance frequency, approximately the peak position. - width : Numeric | Parameter, default=1.0 + width : Numeric, default=1.0 Damping constant, approximately the half width at half max (HWHM) of the peaks. By default, 1.0. unit : str | sc.Unit, default='meV' diff --git a/src/easydynamics/sample_model/components/delta_function.py b/src/easydynamics/sample_model/components/delta_function.py index d63780fa..c10e6185 100644 --- a/src/easydynamics/sample_model/components/delta_function.py +++ b/src/easydynamics/sample_model/components/delta_function.py @@ -30,8 +30,8 @@ class DeltaFunction(CreateParametersMixin, ModelComponent): def __init__( self, - center: Numeric | Parameter | None = None, - area: Numeric | Parameter = 1.0, + center: Numeric | None = None, + area: Numeric = 1.0, unit: str | sc.Unit = 'meV', name: str = 'DeltaFunction', display_name: str | None = None, @@ -42,9 +42,9 @@ def __init__( Parameters ---------- - center : Numeric | Parameter | None, default=None + center : Numeric | None, default=None Center of the delta function. If None, it will be centered at 0 and fixed. - area : Numeric | Parameter, default=1.0 + area : Numeric, default=1.0 Total area under the curve. unit : str | sc.Unit, default='meV' Unit of the parameters. diff --git a/src/easydynamics/sample_model/components/exponential.py b/src/easydynamics/sample_model/components/exponential.py index b331b162..8894a065 100644 --- a/src/easydynamics/sample_model/components/exponential.py +++ b/src/easydynamics/sample_model/components/exponential.py @@ -25,9 +25,9 @@ class Exponential(CreateParametersMixin, ModelComponent): def __init__( self, - amplitude: Numeric | Parameter = 1.0, - center: Numeric | Parameter | None = None, - rate: Numeric | Parameter = 1.0, + amplitude: Numeric = 1.0, + center: Numeric | None = None, + rate: Numeric = 1.0, unit: str | sc.Unit = 'meV', name: str = 'Exponential', display_name: str | None = None, @@ -38,11 +38,11 @@ def __init__( Parameters ---------- - amplitude : Numeric | Parameter, default=1.0 + amplitude : Numeric, default=1.0 Amplitude of the Exponential. - center : Numeric | Parameter | None, default=None + center : Numeric | None, default=None Center of the Exponential. If None, the center is fixed at 0. - rate : Numeric | Parameter, default=1.0 + rate : Numeric, default=1.0 Decay or growth constant of the Exponential. unit : str | sc.Unit, default='meV' Unit of the parameters. diff --git a/src/easydynamics/sample_model/components/gaussian.py b/src/easydynamics/sample_model/components/gaussian.py index 54cfe97c..cab505b1 100644 --- a/src/easydynamics/sample_model/components/gaussian.py +++ b/src/easydynamics/sample_model/components/gaussian.py @@ -33,9 +33,9 @@ class Gaussian(CreateParametersMixin, ModelComponent): def __init__( self, - area: Numeric | Parameter = 1.0, - center: Numeric | Parameter | None = None, - width: Numeric | Parameter = 1.0, + area: Numeric = 1.0, + center: Numeric | None = None, + width: Numeric = 1.0, unit: str | sc.Unit = 'meV', name: str = 'Gaussian', display_name: str | None = None, @@ -46,11 +46,11 @@ def __init__( Parameters ---------- - area : Numeric | Parameter, default=1.0 + area : Numeric, default=1.0 Area of the Gaussian. - center : Numeric | Parameter | None, default=None + center : Numeric | None, default=None Center of the Gaussian. If None. - width : Numeric | Parameter, default=1.0 + width : Numeric, default=1.0 Standard deviation. unit : str | sc.Unit, default='meV' Unit of the parameters. diff --git a/src/easydynamics/sample_model/components/lorentzian.py b/src/easydynamics/sample_model/components/lorentzian.py index 81453fb8..88051d16 100644 --- a/src/easydynamics/sample_model/components/lorentzian.py +++ b/src/easydynamics/sample_model/components/lorentzian.py @@ -30,9 +30,9 @@ class Lorentzian(CreateParametersMixin, ModelComponent): def __init__( self, - area: Numeric | Parameter = 1.0, - center: Numeric | Parameter | None = None, - width: Numeric | Parameter = 1.0, + area: Numeric = 1.0, + center: Numeric | None = None, + width: Numeric = 1.0, unit: str | sc.Unit = 'meV', name: str = 'Lorentzian', display_name: str | None = None, @@ -43,11 +43,11 @@ def __init__( Parameters ---------- - area : Numeric | Parameter, default=1.0 + area : Numeric, default=1.0 Area of the Lorentzian. - center : Numeric | Parameter | None, default=None + center : Numeric | None, default=None Center of the Lorentzian. If None, defaults to 0 and is fixed. - width : Numeric | Parameter, default=1.0 + width : Numeric, default=1.0 Half width at half maximum (HWHM). unit : str | sc.Unit, default='meV' Unit of the parameters. diff --git a/src/easydynamics/sample_model/components/mixins.py b/src/easydynamics/sample_model/components/mixins.py index 0d760865..22ef7bc5 100644 --- a/src/easydynamics/sample_model/components/mixins.py +++ b/src/easydynamics/sample_model/components/mixins.py @@ -24,7 +24,7 @@ class CreateParametersMixin: def _create_area_parameter( self, - area: Numeric | Parameter, + area: Numeric, name: str, unit: str | sc.Unit = 'meV', minimum_area: float = MINIMUM_AREA, @@ -37,11 +37,11 @@ def _create_area_parameter( Parameters ---------- - area : Numeric | Parameter - The area value or Parameter. + area : Numeric + The area value. name : str The name of the model component. - unit : str | sc.Unit, default='meV' + unit : str | sc.Unit, default="meV" The unit of the area Parameter. minimum_area : float, default=MINIMUM_AREA The minimum allowed area. @@ -49,39 +49,36 @@ def _create_area_parameter( Raises ------ TypeError - If area is not a number or a Parameter. + If area is not a number. ValueError - If area is not a finite number or if the area Parameter has a non-finite value. + If area is not a finite number. Returns ------- Parameter The validated area Parameter. """ - if not isinstance(area, (Parameter, Numeric)): - raise TypeError('area must be a number or a Parameter.') + if not isinstance(area, Numeric): + raise TypeError('area must be a number.') - if isinstance(area, Numeric): - if not np.isfinite(area): - raise ValueError('area must be a finite number or a Parameter') + if not np.isfinite(area): + raise ValueError('area must be a finite number.') + area_param = Parameter(name=name + ' area', value=float(area), unit=unit) - area = Parameter(name=name + ' area', value=float(area), unit=unit) - - if area.value < 0: + if area_param.value < 0: warnings.warn( f'The area of {name} is negative, which may not be physically meaningful.', UserWarning, stacklevel=3, ) else: - if area.min < minimum_area: - area.min = minimum_area + area_param.min = minimum_area - return area + return area_param def _create_center_parameter( self, - center: Numeric | Parameter | None, + center: Numeric | None, name: str, fix_if_none: bool, unit: str | sc.Unit = 'meV', @@ -92,13 +89,13 @@ def _create_center_parameter( Parameters ---------- - center : Numeric | Parameter | None - The center value or Parameter. + center : Numeric | None + The center value. name : str The name of the model component. fix_if_none : bool Whether to fix the center Parameter if center is None. - unit : str | sc.Unit, default='meV' + unit : str | sc.Unit, default="meV" The unit of the center Parameter. enforce_minimum_center : bool, default=False Whether to enforce a minimum center value to avoid zero center in DHO. @@ -106,38 +103,37 @@ def _create_center_parameter( Raises ------ TypeError - If center is not None, a number, or a Parameter. + If center is not None or a number. ValueError - If center is a number but not finite, or if center is a Parameter but has a non-finite - value. + If center is a number but not finite. Returns ------- Parameter The validated center Parameter. """ - if center is not None and not isinstance(center, (Numeric, Parameter)): - raise TypeError('center must be None, a number, or a Parameter.') + if center is not None and not isinstance(center, Numeric): + raise TypeError('center must be None or a number.') if center is None: - center = Parameter( + center_param = Parameter( name=name + ' center', value=0.0, unit=unit, fixed=fix_if_none, ) - elif isinstance(center, Numeric): + else: if not np.isfinite(center): - raise ValueError('center must be None, a finite number or a Parameter') + raise ValueError('center must be None or a finite number.') - center = Parameter(name=name + ' center', value=float(center), unit=unit) - if enforce_minimum_center and center.min < DHO_MINIMUM_CENTER: - center.min = DHO_MINIMUM_CENTER - return center + center_param = Parameter(name=name + ' center', value=float(center), unit=unit) + if enforce_minimum_center and center_param.min < DHO_MINIMUM_CENTER: + center_param.min = DHO_MINIMUM_CENTER + return center_param def _create_width_parameter( self, - width: Numeric | Parameter, + width: Numeric, name: str, param_name: str = 'width', unit: str | sc.Unit = 'meV', @@ -148,13 +144,13 @@ def _create_width_parameter( Parameters ---------- - width : Numeric | Parameter - The width value or Parameter. + width : Numeric + The width value. name : str The name of the model component. - param_name : str, default='width' + param_name : str, default="width" The name of the width parameter. - unit : str | sc.Unit, default='meV' + unit : str | sc.Unit, default="meV" The unit of the width Parameter. minimum_width : float, default=MINIMUM_WIDTH The minimum allowed width. @@ -162,7 +158,7 @@ def _create_width_parameter( Raises ------ TypeError - If width is not a number or a Parameter. + If width is not a number. ValueError If width is non-positive. @@ -171,29 +167,19 @@ def _create_width_parameter( Parameter The validated width Parameter. """ - if not isinstance(width, (Numeric, Parameter)): - raise TypeError(f'{param_name} must be a number or a Parameter.') - - if isinstance(width, Numeric): - if not np.isfinite(width): - raise ValueError(f'{param_name} must be a finite number or a Parameter') - - if float(width) < minimum_width: - raise ValueError( - f'The {param_name} of a {self.__class__.__name__} must be greater than zero.' - ) - width = Parameter( - name=name + ' ' + param_name, - value=float(width), - unit=unit, - min=minimum_width, + if not isinstance(width, Numeric): + raise TypeError(f'{param_name} must be a number.') + + if not np.isfinite(width): + raise ValueError(f'{param_name} must be a finite number') + + if float(width) < minimum_width: + raise ValueError( + f'The {param_name} of a {self.__class__.__name__} must be greater than zero.' ) - else: - if width.value <= 0: - raise ValueError( - f'The {param_name} of a {self.__class__.__name__} must be greater than zero.' - ) - if width.min < minimum_width: - width.min = minimum_width - - return width + return Parameter( + name=name + ' ' + param_name, + value=float(width), + unit=unit, + min=minimum_width, + ) diff --git a/src/easydynamics/sample_model/diffusion_model/delta_lorentz.py b/src/easydynamics/sample_model/diffusion_model/delta_lorentz.py index 0a96ee59..150015a7 100644 --- a/src/easydynamics/sample_model/diffusion_model/delta_lorentz.py +++ b/src/easydynamics/sample_model/diffusion_model/delta_lorentz.py @@ -486,16 +486,13 @@ def create_component_collections( # ------------------------------# # Create Lorentzian # ------------------------------# - if self._allow_Q_variation['lorentzian_width'] is True: - width = self._lorentzian_width_list[i] - else: - width = 1.0 lorentzian_component = Lorentzian( name=self.lorentzian_name, display_name=self.lorentzian_display_name, unit=self.unit, - width=width, ) + if self._allow_Q_variation['lorentzian_width'] is True: + lorentzian_component._width = self._lorentzian_width_list[i] # noqa: SLF001 # If the width is allowed to vary with Q it is independent. # If the width is not allowed to vary with Q it must be made diff --git a/tests/unit/easydynamics/sample_model/components/test_damped_harmonic_oscillator.py b/tests/unit/easydynamics/sample_model/components/test_damped_harmonic_oscillator.py index a420fa40..87f9556c 100644 --- a/tests/unit/easydynamics/sample_model/components/test_damped_harmonic_oscillator.py +++ b/tests/unit/easydynamics/sample_model/components/test_damped_harmonic_oscillator.py @@ -42,28 +42,6 @@ def test_initialization(self, dho: DampedHarmonicOscillator): assert dho.width.value == pytest.approx(0.3) assert dho.unit == 'meV' - def test_init_with_parameters(self): - # WHEN - area_param = Parameter(name='area_param', value=3.0, unit='meV') - center_param = Parameter(name='center_param', value=1.0, unit='meV') - width_param = Parameter(name='width_param', value=0.8, unit='meV') - - # THEN - dho = DampedHarmonicOscillator( - display_name='Paramdho', - area=area_param, - center=center_param, - width=width_param, - unit='meV', - ) - - # EXPECT - assert dho.display_name == 'Paramdho' - assert dho.area is area_param - assert dho.center is center_param - assert dho.width is width_param - assert dho.unit == 'meV' - @pytest.mark.parametrize( 'kwargs, expected_message', [ diff --git a/tests/unit/easydynamics/sample_model/components/test_exponential.py b/tests/unit/easydynamics/sample_model/components/test_exponential.py index 97df632e..6c2a1c50 100644 --- a/tests/unit/easydynamics/sample_model/components/test_exponential.py +++ b/tests/unit/easydynamics/sample_model/components/test_exponential.py @@ -42,28 +42,6 @@ def test_initialization(self, exponential: Exponential): assert exponential.rate.value == pytest.approx(1.2) assert exponential.unit == 'meV' - def test_init_with_parameters(self): - # WHEN - amplitude_param = Parameter(name='amp_param', value=3.0, unit='meV') - center_param = Parameter(name='center_param', value=1.0, unit='meV') - rate_param = Parameter(name='rate_param', value=0.5, unit='1/meV') - - # THEN - exponential = Exponential( - display_name='ParamExponential', - amplitude=amplitude_param, - center=center_param, - rate=rate_param, - unit='meV', - ) - - # EXPECT - assert exponential.display_name == 'ParamExponential' - assert exponential.amplitude is amplitude_param - assert exponential.center is center_param - assert exponential.rate is rate_param - assert exponential.unit == 'meV' - @pytest.mark.parametrize( 'kwargs, expected_message', [ @@ -73,11 +51,11 @@ def test_init_with_parameters(self): ), ( {'amplitude': 2.0, 'center': 'invalid', 'rate': 1.0, 'unit': 'meV'}, - 'center must be None, a number', + 'center must be None or a number', ), ( {'amplitude': 2.0, 'center': 0.5, 'rate': 'invalid', 'unit': 'meV'}, - 'rate must be a number or a Parameter', + 'rate must be a number', ), ], ) diff --git a/tests/unit/easydynamics/sample_model/components/test_gaussian.py b/tests/unit/easydynamics/sample_model/components/test_gaussian.py index 9bf0b13d..f5acf10c 100644 --- a/tests/unit/easydynamics/sample_model/components/test_gaussian.py +++ b/tests/unit/easydynamics/sample_model/components/test_gaussian.py @@ -43,28 +43,6 @@ def test_initialization(self, gaussian: Gaussian): assert gaussian.width.value == pytest.approx(0.6) assert gaussian.unit == 'meV' - def test_init_with_parameters(self): - # WHEN - area_param = Parameter(name='area_param', value=3.0, unit='meV') - center_param = Parameter(name='center_param', value=1.0, unit='meV') - width_param = Parameter(name='width_param', value=0.8, unit='meV') - - # THEN - gaussian = Gaussian( - display_name='ParamGaussian', - area=area_param, - center=center_param, - width=width_param, - unit='meV', - ) - - # EXPECT - assert gaussian.display_name == 'ParamGaussian' - assert gaussian.area is area_param - assert gaussian.center is center_param - assert gaussian.width is width_param - assert gaussian.unit == 'meV' - @pytest.mark.parametrize( 'kwargs, expected_message', [ @@ -74,7 +52,7 @@ def test_init_with_parameters(self): ), ( {'area': 2.0, 'center': 'invalid', 'width': 0.6, 'unit': 'meV'}, - 'center must be None, a number', + 'center must be None or a number', ), ( {'area': 2.0, 'center': 0.5, 'width': 'invalid', 'unit': 'meV'}, @@ -85,6 +63,12 @@ def test_init_with_parameters(self): 'unit must be None', ), ], + ids=[ + 'invalid area', + 'invalid center', + 'invalid width', + 'invalid unit', + ], ) def test_input_type_validation_raises(self, kwargs, expected_message): with pytest.raises(TypeError, match=expected_message): diff --git a/tests/unit/easydynamics/sample_model/components/test_lorentzian.py b/tests/unit/easydynamics/sample_model/components/test_lorentzian.py index 3c7809c6..6056bab9 100644 --- a/tests/unit/easydynamics/sample_model/components/test_lorentzian.py +++ b/tests/unit/easydynamics/sample_model/components/test_lorentzian.py @@ -43,28 +43,6 @@ def test_initialization(self, lorentzian: Lorentzian): assert lorentzian.width.value == pytest.approx(0.6) assert lorentzian.unit == 'meV' - def test_init_with_parameters(self): - # WHEN - area_param = Parameter(name='area_param', value=3.0, unit='meV') - center_param = Parameter(name='center_param', value=1.0, unit='meV') - width_param = Parameter(name='width_param', value=0.8, unit='meV') - - # THEN - lorentzian = Lorentzian( - display_name='ParamLorentzian', - area=area_param, - center=center_param, - width=width_param, - unit='meV', - ) - - # EXPECT - assert lorentzian.display_name == 'ParamLorentzian' - assert lorentzian.area is area_param - assert lorentzian.center is center_param - assert lorentzian.width is width_param - assert lorentzian.unit == 'meV' - @pytest.mark.parametrize( 'kwargs, expected_message', [ diff --git a/tests/unit/easydynamics/sample_model/components/test_mixins.py b/tests/unit/easydynamics/sample_model/components/test_mixins.py index 4989f76e..e30f4bdd 100644 --- a/tests/unit/easydynamics/sample_model/components/test_mixins.py +++ b/tests/unit/easydynamics/sample_model/components/test_mixins.py @@ -28,20 +28,9 @@ def test_create_area_parameter_from_numeric(self, dummy_model, area_input, unit) assert not area_param.fixed assert area_param.min == pytest.approx(0.0) - def test_create_area_parameter_from_parameter(self, dummy_model): - # WHEN - area_input = Parameter(name='input_area', value=3.0, unit='meV', fixed=True) - - # THEN - area_param = dummy_model._create_area_parameter(area_input, 'TestModel') - - # EXPECT - assert area_param is area_input # Should be the same object - assert area_param.min == pytest.approx(0.0) - def test_create_area_parameter_invalid_type_raises(self, dummy_model): # WHEN THEN EXPECT - with pytest.raises(TypeError, match='area must be a number or a Parameter'): + with pytest.raises(TypeError, match='area must be a number'): dummy_model._create_area_parameter('invalid', 'TestModel') @pytest.mark.parametrize( @@ -54,7 +43,7 @@ def test_create_area_parameter_invalid_type_raises(self, dummy_model): ) def test_create_area_parameter_invalid_numeric_raises(self, dummy_model, non_finite_area): # WHEN THEN EXPECT - with pytest.raises(ValueError, match='area must be a finite number or a Parameter'): + with pytest.raises(ValueError, match='area must be a finite number'): dummy_model._create_area_parameter(non_finite_area, 'TestModel') def test_negative_area_warns(self, dummy_model): @@ -92,21 +81,9 @@ def test_create_center_parameter_from_None(self, dummy_model, fix_if_none): assert center_param.unit == 'meV' assert center_param.fixed == fix_if_none - def test_create_center_parameter_from_parameter(self, dummy_model): - # WHEN - center_input = Parameter(name='input_center', value=1.0, unit='meV', fixed=True) - - # THEN - center_param = dummy_model._create_center_parameter( - center_input, 'TestModel', fix_if_none=False - ) - - # EXPECT - assert center_param is center_input # Should be the same object - def test_create_center_parameter_invalid_type_raises(self, dummy_model): # WHEN THEN EXPECT - with pytest.raises(TypeError, match='center must be None, a number, or a Parameter'): + with pytest.raises(TypeError, match='center must be None or a number'): dummy_model._create_center_parameter('invalid', 'TestModel', fix_if_none=False) @pytest.mark.parametrize( @@ -119,9 +96,7 @@ def test_create_center_parameter_invalid_type_raises(self, dummy_model): ) def test_create_center_parameter_invalid_numeric_raises(self, dummy_model, non_finite_center): # WHEN THEN EXPECT - with pytest.raises( - ValueError, match='center must be None, a finite number or a Parameter' - ): + with pytest.raises(ValueError, match='center must be None or a finite number'): dummy_model._create_center_parameter(non_finite_center, 'TestModel', fix_if_none=False) @pytest.mark.parametrize('unit', ['meV', 'eV']) @@ -138,29 +113,9 @@ def test_create_width_parameter_from_numeric(self, dummy_model, width_input, uni assert width_param.unit == unit assert not width_param.fixed - def test_create_width_parameter_from_parameter(self, dummy_model): - # WHEN - width_input = Parameter(name='input_width', value=3.0, unit='meV', fixed=True) - - # THEN - width_param = dummy_model._create_width_parameter( - width_input, 'TestModel', param_name='width' - ) - - # EXPECT - assert width_param is width_input # Should be the same object - - def test_create_width_parameter_from_parameter_negative_raises(self, dummy_model): - # WHEN - width_input = Parameter(name='input_width', value=-1.0, unit='meV', fixed=True) - - # THEN EXPECT - with pytest.raises(ValueError, match=' must be greater than zero'): - dummy_model._create_width_parameter(width_input, 'TestModel', param_name='width') - def test_create_width_parameter_invalid_type_raises(self, dummy_model): # WHEN THEN EXPECT - with pytest.raises(TypeError, match='width must be a number or a Parameter'): + with pytest.raises(TypeError, match='width must be a number'): dummy_model._create_width_parameter('invalid', 'TestModel', param_name='width') def test_create_width_parameter_negative_raises(self, dummy_model): @@ -178,5 +133,5 @@ def test_create_width_parameter_negative_raises(self, dummy_model): ) def test_create_width_parameter_invalid_numeric_raises(self, dummy_model, non_finite_center): # WHEN THEN EXPECT - with pytest.raises(ValueError, match='width must be a finite number or a Parameter'): + with pytest.raises(ValueError, match='width must be a finite number'): dummy_model._create_width_parameter(non_finite_center, 'TestModel') diff --git a/tests/unit/easydynamics/sample_model/components/test_voigt.py b/tests/unit/easydynamics/sample_model/components/test_voigt.py index 4d28c73a..5f42704d 100644 --- a/tests/unit/easydynamics/sample_model/components/test_voigt.py +++ b/tests/unit/easydynamics/sample_model/components/test_voigt.py @@ -47,31 +47,6 @@ def test_initialization(self, voigt: Voigt): assert voigt.lorentzian_width.value == pytest.approx(0.7) assert voigt.unit == 'meV' - def test_init_with_parameters(self): - # WHEN - area_param = Parameter(name='area_param', value=3.0, unit='meV') - center_param = Parameter(name='center_param', value=1.0, unit='meV') - gaussian_width_param = Parameter(name='gaussian_width_param', value=0.8, unit='meV') - lorentzian_width_param = Parameter(name='lorentzian_width_param', value=0.9, unit='meV') - - # THEN - voigt = Voigt( - display_name='ParamVoigt', - area=area_param, - center=center_param, - gaussian_width=gaussian_width_param, - lorentzian_width=lorentzian_width_param, - unit='meV', - ) - - # EXPECT - assert voigt.display_name == 'ParamVoigt' - assert voigt.area is area_param - assert voigt.center is center_param - assert voigt.gaussian_width is gaussian_width_param - assert voigt.lorentzian_width is lorentzian_width_param - assert voigt.unit == 'meV' - @pytest.mark.parametrize( 'kwargs, expected_message', [