88from numpy import integer
99from pathlib import Path
1010from re import match
11- from warnings import warn
1211from logging import getLogger
1312
1413from jpype import JClass
@@ -629,30 +628,27 @@ def rename(self, name: str):
629628
630629 @overload
631630 def parameter (self ,
632- name : str ,
633- value : str | int | float | complex ,
634- unit : str | None ,
635- description : str | None ,
636- evaluate : Literal [False ],
631+ name : str ,
632+ value : str | int | float | complex ,
633+ * ,
634+ evaluate : Literal [False ],
637635 ): ...
638636 @overload
639637 def parameter (self ,
640- name : str ,
641- value : Literal [None ],
642- unit : Literal [None ],
643- description : Literal [None ],
644- evaluate : Literal [False ],
638+ name : str ,
639+ value : Literal [None ],
640+ * ,
641+ evaluate : Literal [False ],
645642 ) -> str : ...
646643 @overload
647644 def parameter (self ,
648- name : str ,
649- value : Literal [None ],
650- unit : Literal [None ],
651- description : Literal [None ],
652- evaluate : Literal [True ],
645+ name : str ,
646+ value : Literal [None ],
647+ * ,
648+ evaluate : Literal [True ],
653649 ) -> int | float | complex : ...
654650 def parameter (
655- self , name , value = None , unit = None , description = None , evaluate = False
651+ self , name , value = None , * , evaluate = False
656652 ):
657653 """
658654 Returns or sets the parameter of the given name.
@@ -669,21 +665,7 @@ def parameter(
669665 the unit, again inside brackets. If the option `evaluate` is set
670666 to `True`, the numerical value that the expression evaluates to
671667 is returned.
672-
673- *Warning*: The optional arguments `unit` and `description` are
674- deprecated and will be removed in a future release. Include the
675- unit in the value expression and call the `description()` method
676- to change a parameter description.
677668 """
678- if unit is not None :
679- warn ('Argument "unit" to Model.parameter() is deprecated. '
680- 'Include the unit in the value inside square brackets.' )
681- if value :
682- value = f'{ value } [{ unit } ]'
683- if description is not None :
684- warn ('Argument "description" to Model.parameter() is deprecated. '
685- 'Call .description() instead.' )
686- self .description (name , description )
687669 if value is None :
688670 if not evaluate :
689671 try :
@@ -725,13 +707,6 @@ def parameters(self, evaluate=False):
725707 the user, unless `evaluate` is set to `True`, in which case
726708 the expressions are evaluated and the corresponding numbers
727709 are returned.
728-
729- *Warning*: Prior to version 1.0, this method would return
730- a list of named tuples holding name, value, and description.
731- It now returns a dictionary, which is a breaking change that
732- may require application code to be adapted. The descriptions
733- can be retrieved by additionally calling `.description()` or
734- `.descriptions()`.
735710 """
736711 if not evaluate :
737712 return {str (name ): str (self .java .param ().get (name ))
@@ -1010,70 +985,3 @@ def save(self, path: Path | str = None, format: str = None):
1010985 else :
1011986 self .java .save (str (file ), type )
1012987 log .info ('Finished saving model.' )
1013-
1014- ###############
1015- # Deprecation #
1016- ###############
1017-
1018- def features (self , physics : str ) -> list [str ]:
1019- # Returns the names of all features in a given physics interface.
1020- #
1021- # The term feature refers to the nodes defined under a physics
1022- # interface. They define the differential equations, boundary
1023- # conditions, initial values, etc.
1024- warn ('Model.features() is deprecated. Use the Node class instead.' )
1025- if physics not in self .physics ():
1026- error = f'No physics interface named "{ physics } ".'
1027- log .error (error )
1028- raise LookupError (error )
1029- tags = [tag for tag in self .java .physics ().tags ()]
1030- ptag = tags [self .physics ().index (physics )]
1031- tags = [tag for tag in self .java .physics (ptag ).feature ().tags ()]
1032- return [str (self .java .physics (ptag ).feature (ftag ).label ())
1033- for ftag in tags ]
1034-
1035- def toggle (self , physics : str , feature : str , action : str = 'flip' ):
1036- # Enables or disables features of a physics interface.
1037- #
1038- # If `action` is `'flip'` (the default), it enables the feature
1039- # if it is currently disabled or disables it if enabled. Pass
1040- # `'enable'` or `'on'` to enable the feature regardless of its
1041- # current state. Pass `'disable'` or `'off'` to disable it.
1042- warn ('Model.toggle() is deprecated. Use the Node class instead.' )
1043- if physics not in self .physics ():
1044- error = f'No physics interface named "{ physics } ".'
1045- log .error (error )
1046- raise LookupError (error )
1047- tags = [tag for tag in self .java .physics ().tags ()]
1048- ptag = tags [self .physics ().index (physics )]
1049- node = self .java .physics (ptag )
1050- if feature not in self .features (physics ):
1051- error = f'No feature named "{ feature } " in physics "{ physics } ".'
1052- log .error (error )
1053- raise LookupError (error )
1054- tags = [tag for tag in node .feature ().tags ()]
1055- ftag = tags [self .features (physics ).index (feature )]
1056- node = node .feature (ftag )
1057- if action == 'flip' :
1058- node .active (not node .isActive ())
1059- elif action in ('enable' , 'on' , 'activate' ):
1060- node .active (True )
1061- elif action in ('disable' , 'off' , 'deactivate' ):
1062- node .active (False )
1063-
1064- def load (self , file : Path | str , interpolation : str ):
1065- # Loads data from a file and assigns it to an interpolation function.
1066- warn ('Model.load() is deprecated. Call .import_() instead.' )
1067- for tag in self .java .func ().tags ():
1068- if str (self .java .func (tag ).label ()) == interpolation :
1069- break
1070- else :
1071- error = f'Interpolation function "{ interpolation } " does not exist.'
1072- log .error (error )
1073- raise LookupError (error )
1074- file = Path (file )
1075- log .info (f'Loading external data from file "{ file .name } ".' )
1076- self .java .func (tag ).discardData ()
1077- self .java .func (tag ).set ('filename' , f'{ file } ' )
1078- self .java .func (tag ).importData ()
1079- log .info ('Finished loading external data.' )
0 commit comments