11import tabulate
2- from typing import Union
2+ from typing import Union , Any
33from RAT .utils .enums import ParallelOptions , Procedures , DisplayOptions , BoundHandlingOptions , StrategyOptions
44
55
@@ -10,10 +10,10 @@ class BaseProcedure:
1010 """
1111
1212 def __init__ (self ,
13- parallel : Union [ str , ParallelOptions ] = ParallelOptions .Single .value ,
13+ parallel : str = ParallelOptions .Single .value ,
1414 calcSldDuringFit : bool = False ,
1515 resamPars : list [Union [int , float ]] = [0.9 , 50 ],
16- display : Union [ str , DisplayOptions ] = DisplayOptions .Iter .value ) -> None :
16+ display : str = DisplayOptions .Iter .value ) -> None :
1717
1818 self ._parallel = parallel
1919 self ._calcSldDuringFit = calcSldDuringFit
@@ -22,7 +22,7 @@ def __init__(self,
2222
2323 def _validate_type (self ,
2424 name : str ,
25- value : Union [ int , float , str , bool , list [ Union [ int , float ]]] ,
25+ value : Any ,
2626 type : type ) -> None :
2727 """
2828 Validates the value has the correct type.
@@ -31,7 +31,7 @@ def _validate_type(self,
3131 ----------
3232 name : str
3333 The name of the property.
34- value : Union[int, float, str, bool, list[Union[int, float]]]
34+ value : Any
3535 The value of the property.
3636 type : type
3737 The expected type of the property.
@@ -147,13 +147,13 @@ def parallel(self) -> str:
147147 return self ._parallel
148148
149149 @parallel .setter
150- def parallel (self , value : Union [ str , ParallelOptions ] ) -> None :
150+ def parallel (self , value : str ) -> None :
151151 """
152152 Sets the parallel property after validation.
153153
154154 Parameters
155155 ----------
156- value : Union[ str, ParallelOptions]
156+ value : str
157157 The value to be set for the parallel property.
158158
159159 Raises
@@ -253,13 +253,13 @@ def display(self) -> str:
253253 return self ._display
254254
255255 @display .setter
256- def display (self , value : Union [ str , DisplayOptions ] ) -> None :
256+ def display (self , value : str ) -> None :
257257 """
258258 Sets the display property after validation.
259259
260260 Parameters
261261 ----------
262- value : Union[ str, DisplayOptions]
262+ value : str
263263 The value to be set for the display property.
264264
265265 Raises
@@ -272,13 +272,13 @@ def display(self, value: Union[str, DisplayOptions]) -> None:
272272 self ._validate_value ('display' , value , DisplayOptions )
273273 self ._display = value
274274
275- def __repr__ (self , procedure : Union [ str , Procedures ] ):
275+ def __repr__ (self , procedure : str ):
276276 """
277277 Defines the display method for procedure classes.
278278
279279 Parameters
280280 ----------
281- procedure : Union[ str, Procedures]
281+ procedure : str
282282 The procedure for the controls classes.
283283
284284 """
@@ -293,10 +293,10 @@ class Calculate(BaseProcedure):
293293 """Defines the class for the calculate procedure"""
294294
295295 def __init__ (self ,
296- parallel : Union [ str , ParallelOptions ] = ParallelOptions .Single .value ,
296+ parallel : str = ParallelOptions .Single .value ,
297297 calcSldDuringFit : bool = False ,
298298 resamPars : list [Union [int , float ]] = [0.9 , 50 ],
299- display : Union [ str , DisplayOptions ] = DisplayOptions .Iter .value ) -> None :
299+ display : str = DisplayOptions .Iter .value ) -> None :
300300
301301 # call the constructor of the parent class
302302 super ().__init__ (parallel = parallel ,
@@ -328,10 +328,10 @@ class Simplex(BaseProcedure):
328328 """Defines the class for the simplex procedure"""
329329
330330 def __init__ (self ,
331- parallel : Union [ str , ParallelOptions ] = ParallelOptions .Single .value ,
331+ parallel : str = ParallelOptions .Single .value ,
332332 calcSldDuringFit : bool = False ,
333333 resamPars : list [Union [int , float ]] = [0.9 , 50 ],
334- display : Union [ str , DisplayOptions ] = DisplayOptions .Iter .value ,
334+ display : str = DisplayOptions .Iter .value ,
335335 tolX : float = 1e-6 ,
336336 tolFun : float = 1e-6 ,
337337 maxFunEvals : int = 10000 ,
@@ -562,14 +562,14 @@ class DE(BaseProcedure):
562562 """Defines the class for the Differential Evolution procedure"""
563563
564564 def __init__ (self ,
565- parallel : Union [ str , ParallelOptions ] = ParallelOptions .Single .value ,
565+ parallel : str = ParallelOptions .Single .value ,
566566 calcSldDuringFit : bool = False ,
567567 resamPars : list [Union [int , float ]] = [0.9 , 50 ],
568- display : Union [ str , DisplayOptions ] = DisplayOptions .Iter .value ,
568+ display : str = DisplayOptions .Iter .value ,
569569 populationSize : int = 20 ,
570570 fWeight : float = 0.5 ,
571571 crossoverProbability : float = 0.8 ,
572- strategy : Union [ int , StrategyOptions ] = 4 ,
572+ strategy : int = StrategyOptions . RandomWithPerVectorDither . value ,
573573 targetValue : Union [int , float ] = 1 ,
574574 numGenerations : int = 500 ) -> None :
575575
@@ -712,13 +712,13 @@ def strategy(self) -> int:
712712 return self ._strategy
713713
714714 @strategy .setter
715- def strategy (self , value : Union [ int , StrategyOptions ] ) -> None :
715+ def strategy (self , value : int ) -> None :
716716 """
717717 Sets the strategy property after validation.
718718
719719 Parameters
720720 ----------
721- value : Union[ int, StrategyOptions]
721+ value : int
722722 The value to be set for the strategy property.
723723
724724 Raises
@@ -816,10 +816,10 @@ class NS(BaseProcedure):
816816 """Defines the class for the Nested Sampler procedure"""
817817
818818 def __init__ (self ,
819- parallel : Union [ str , ParallelOptions ] = ParallelOptions .Single .value ,
819+ parallel : str = ParallelOptions .Single .value ,
820820 calcSldDuringFit : bool = False ,
821821 resamPars : list [Union [int , float ]] = [0.9 , 50 ],
822- display : Union [ str , DisplayOptions ] = DisplayOptions .Iter .value ,
822+ display : str = DisplayOptions .Iter .value ,
823823 Nlive : int = 150 ,
824824 Nmcmc : Union [float , int ] = 0 ,
825825 propScale : float = 0.1 ,
@@ -1000,15 +1000,15 @@ class Dream(BaseProcedure):
10001000 """Defines the class for the Dream procedure"""
10011001
10021002 def __init__ (self ,
1003- parallel : Union [ str , ParallelOptions ] = ParallelOptions .Single .value ,
1003+ parallel : str = ParallelOptions .Single .value ,
10041004 calcSldDuringFit : bool = False ,
10051005 resamPars : list [Union [int , float ]] = [0.9 , 50 ],
1006- display : Union [ str , DisplayOptions ] = DisplayOptions .Iter .value ,
1006+ display : str = DisplayOptions .Iter .value ,
10071007 nSamples : int = 50000 ,
10081008 nChains : int = 10 ,
10091009 jumpProb : float = 0.5 ,
10101010 pUnitGamma :float = 0.2 ,
1011- boundHandling : Union [ str , BoundHandlingOptions ] = BoundHandlingOptions .Fold .value ) -> None :
1011+ boundHandling : str = BoundHandlingOptions .Fold .value ) -> None :
10121012
10131013 # call the constructor of the parent class
10141014 super ().__init__ (parallel = parallel ,
@@ -1187,13 +1187,13 @@ def boundHandling(self) -> str:
11871187 return self ._boundHandling
11881188
11891189 @boundHandling .setter
1190- def boundHandling (self , value : Union [ str , BoundHandlingOptions ] ) -> None :
1190+ def boundHandling (self , value : str ) -> None :
11911191 """
11921192 Sets the boundHandling property after validation.
11931193
11941194 Parameters
11951195 ----------
1196- value : float
1196+ value : str
11971197 The value to be set for the boundHandling property.
11981198
11991199 Raises
@@ -1217,7 +1217,7 @@ def __repr__(self):
12171217class ControlsClass :
12181218
12191219 def __init__ (self ,
1220- procedure : Union [ str , Procedures ] = Procedures .Calculate .value ,
1220+ procedure : str = Procedures .Calculate .value ,
12211221 ** properties ) -> None :
12221222
12231223 self ._procedure = procedure
0 commit comments