MCPcopy Index your code
hub / github.com/SLiCAP/SLiCAP_python / defPar

Method defPar

SLiCAP/SLiCAPprotos.py:211–247  ·  view source on GitHub ↗

Updates or adds a parameter definition and updates the list **SLiCAPprotos.circuit.params** with names (*sympy.Symbol*) of undefined parameters. :param parName: Name of the parameter. :type parName: str, sympy.Symbol :param parValue: Value of the pa

(self, parName, parValue, units = None)

Source from the content-addressed store, hash-verified

209 return
210
211 def defPar(self, parName, parValue, units = None):
212 """
213 Updates or adds a parameter definition and updates the list
214 **SLiCAPprotos.circuit.params** with names (*sympy.Symbol*) of
215 undefined parameters.
216
217 :param parName: Name of the parameter.
218 :type parName: str, sympy.Symbol
219
220 :param parValue: Value of the parameter.
221 :type parValue: str, sympy.Symbol, sympy.Expr, int, float
222
223 :param units: Value of the parameter, defaults to None
224 :type units: str, sympy.Symbol
225
226 :return: None
227 :rtype: NoneType
228 """
229 errors = 0
230 try:
231 eval(parName)
232 errors += 1
233 print("Error: Parameter name cannot be a number.")
234 except BaseException:
235 pass
236 if errors == 0:
237 parName = Symbol(str(parName))
238 self.parDefs[parName] = _checkExpression(parValue)
239 if parName in self.params:
240 self.params.remove(parName)
241 if type(units) == str:
242 # ToDo: checkUnits() calculate wir SI units.
243 self.parUnits[parName] = units
244 else:
245 self.parUnits[parName] = ''
246 self.updateParams()
247 return
248
249 def defPars(self, parDict):
250 """

Callers 3

specs2circuitFunction · 0.45
parameters.pyFile · 0.45
dcvar.pyFile · 0.45

Calls 3

updateParamsMethod · 0.95
_checkExpressionFunction · 0.90
SymbolClass · 0.85

Tested by

no test coverage detected