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

Method checkStepVars

SLiCAP/SLiCAPinstruction.py:825–858  ·  view source on GitHub ↗

Checks if the step variables for array stepping are defined correctly. Called by **instruction.checkStep** and by **instruction.setStepVars( )**.

(self)

Source from the content-addressed store, hash-verified

823 return
824
825 def checkStepVars(self):
826 """
827 Checks if the step variables for array stepping are defined correctly.
828
829 Called by **instruction.checkStep** and by **instruction.setStepVars(<stepVars>)**.
830 """
831 if self.stepVars == None:
832 self.errors += 1
833 print("Error: missing list stepVars.")
834 return
835 errors = 0
836 if type(self.stepVars) == list:
837 if len(self.stepVars) != 0:
838 for i in range(len(self.stepVars)):
839 if type(self.stepVars[i]) == str:
840 try:
841 self.stepVars[i] = sp.Symbol(self.stepVars[i])
842 except:
843 errors += 1
844 print("Error: step variable '{0}' is not a parameter.".format(str(self.stepVars[i])))
845 if isinstance(self.stepVars[i], sp.Basic):
846 if self.stepVars[i] not in list(self.circuit.parDefs.keys()) and self.stepVars[i] not in self.circuit.params:
847 print("Warning: unknown step parameter '{0}'.".format(str(self.stepVars[i])))
848 else:
849 errors += 1
850 print("Error: argument type must be 'str' or 'sympy.Symbol'.")
851 else:
852 errors += 1
853 print("Error: empty stepVars.")
854 else:
855 print("Error: argument should be a list.")
856 errors += 1
857 self.errors += errors
858 return
859
860 def setStepMethod(self, stepMethod):
861 """

Callers 2

setStepVarsMethod · 0.95
checkStepMethod · 0.95

Calls 1

formatMethod · 0.80

Tested by

no test coverage detected