Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# impedance: array of complex numbers
# impedance and frequency match in length
assert isinstance(frequencies, np.ndarray),\
'frequencies is not of type np.ndarray'
assert isinstance(frequencies[0], (float, int, np.int32, np.float64)),\
'frequencies does not contain a number'
assert isinstance(impedance, np.ndarray),\
'impedance is not of type np.ndarray'
assert isinstance(impedance[0], (complex, np.complex128)),\
'impedance does not contain complex numbers'
assert len(frequencies) == len(impedance),\
'mismatch in length of input frequencies and impedances'
if self.initial_guess is not None:
parameters, conf = circuit_fit(frequencies, impedance,
self.circuit, self.initial_guess,
self.constants, method=method,
bounds=bounds)
self.parameters_ = parameters
if conf is not None:
self.conf_ = conf
else:
# TODO auto calc guess
raise ValueError('no initial guess supplied')
return self
# impedance: array of complex numbers
# impedance and frequency match in length
assert isinstance(frequencies, np.ndarray),\
'frequencies is not of type np.ndarray'
assert isinstance(frequencies[0], (float, int, np.int32, np.float64)),\
'frequencies does not contain a number'
assert isinstance(impedance, np.ndarray),\
'impedance is not of type np.ndarray'
assert isinstance(impedance[0], (complex, np.complex128)),\
'impedance does not contain complex numbers'
assert len(frequencies) == len(impedance),\
'mismatch in length of input frequencies and impedances'
if self.initial_guess is not None:
parameters, conf = circuit_fit(frequencies, impedance,
self.circuit, self.initial_guess,
self.constants, method=method,
bounds=bounds)
self.parameters_ = parameters
if conf is not None:
self.conf_ = conf
else:
# TODO auto calc guess
raise ValueError('no initial guess supplied')
return self