88
99from easyscience .variable import Parameter
1010
11- from easydynamics . sample_model . components .model_component import ModelComponent
11+ from .model_component import ModelComponent
1212
1313import scipp as sc
1414
@@ -78,7 +78,7 @@ def __init__(
7878
7979 super ().__init__ (name = name )
8080
81- self .unit = unit # Set the unit for the component
81+ self ._unit = unit # Set the unit for the component
8282 # Create Parameters from floats, or set Parameters if already provided
8383 if center is None :
8484 self .center = Parameter (
@@ -128,9 +128,9 @@ def evaluate(self, x: Union[Numeric, sc.Variable]) -> Union[float, np.ndarray]:
128128 # Handle units
129129 if isinstance (x , sc .Variable ):
130130 x_in = x .values
131- if self .unit is not None and x .unit != self .unit :
131+ if self ._unit is not None and x .unit != self ._unit :
132132 warnings .warn (
133- f"Input x has unit { x .unit } , but Voigt component has unit { self .unit } . Converting Voigt to { x .unit } ."
133+ f"Input x has unit { x .unit } , but Voigt component has unit { self ._unit } . Converting Voigt to { x .unit } ."
134134 )
135135 self .convert_unit (x .unit .name )
136136 else :
@@ -152,7 +152,7 @@ def convert_unit(self, unit: str):
152152 self .center .convert_unit (unit )
153153 self .gaussian_width .convert_unit (unit )
154154 self .lorentzian_width .convert_unit (unit )
155- self .unit = unit
155+ self ._unit = unit
156156
157157 def get_parameters (self ):
158158 """
@@ -169,7 +169,7 @@ def copy(self) -> Voigt:
169169 center = self .center .value ,
170170 gaussian_width = self .gaussian_width .value ,
171171 lorentzian_width = self .lorentzian_width .value ,
172- unit = self .unit ,
172+ unit = self ._unit ,
173173 )
174174 model_copy .area .fixed = self .area .fixed
175175 model_copy .center .fixed = self .center .fixed
@@ -179,4 +179,4 @@ def copy(self) -> Voigt:
179179 return model_copy
180180
181181 def __repr__ (self ):
182- return f"Voigt(name = { self .name } , unit = { self .unit } ,\n area = { self .area } ,\n center = { self .center } ,\n gaussian_width = { self .gaussian_width } ,\n lorentzian_width = { self .lorentzian_width } )"
182+ return f"Voigt(name = { self .name } , unit = { self ._unit } ,\n area = { self .area } ,\n center = { self .center } ,\n gaussian_width = { self .gaussian_width } ,\n lorentzian_width = { self .lorentzian_width } )"
0 commit comments