Skip to content

Commit 6a269c4

Browse files
authored
remove partial fix of defining np as an element. replace with more robust fix converting numpy array to scalars with .tolist() so element values appear without the type prefix in circtuit string (#322)
1 parent 741f406 commit 6a269c4

2 files changed

Lines changed: 10 additions & 12 deletions

File tree

impedance/models/circuits/elements.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ def wrapper(p, f):
4444
)
4545
else:
4646
circuit_elements[func.__name__] = wrapper
47-
# Adding numpy to circuit_elements for proper evaluation with
48-
# numpy>=2.0.0 because the scalar representation was changed.
49-
# "Scalars are now printed as np.float64(3.0) rather than just 3.0."
50-
# https://numpy.org/doc/2.0/release/2.0.0-notes.html
51-
# #representation-of-numpy-scalars-changed
52-
circuit_elements["np"] = np
5347

5448
return wrapper
5549

impedance/validation.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,18 @@ def fit_linKK(f, ts, M, Z, fit_type='real', add_cap=False):
265265

266266
def eval_linKK(elements, ts, f):
267267
"""Builds a circuit of RC elements to be used in LinKK"""
268-
circuit_string = f"s([R({[elements[0]]},{f.tolist()}),"
268+
elements_list = elements.tolist()
269+
ts_list = ts.tolist()
270+
f_list = f.tolist()
269271

270-
for Rk, tk in zip(elements[1:], ts):
271-
circuit_string += f"K({[Rk, tk]},{f.tolist()}),"
272+
circuit_string = f"s([R({[elements_list[0]]},{f_list}),"
272273

273-
circuit_string += f"L({[elements[-1]]},{f.tolist()}),"
274-
if elements.size == (ts.size + 3):
275-
circuit_string += f"C({[1 / elements[-2]]},{f.tolist()}),"
274+
for Rk, tk in zip(elements_list[1:], ts_list):
275+
circuit_string += f"K({[Rk, tk]},{f_list}),"
276+
277+
circuit_string += f"L({[elements_list[-1]]},{f_list}),"
278+
if len(elements_list) == (len(ts_list) + 3):
279+
circuit_string += f"C({[1 / elements_list[-2]]},{f_list}),"
276280

277281
circuit_string = circuit_string.strip(',')
278282
circuit_string += '])'

0 commit comments

Comments
 (0)