Skip to content

Commit d3e9a7c

Browse files
AlexboiboiCopilot
andauthored
Update src/magpylib_material_response/demag.py
Co-authored-by: Copilot <[email protected]>
1 parent 7c3ab6f commit d3e9a7c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/magpylib_material_response/demag.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ def _convert_to_array(susceptibility, n):
9393
if np.isscalar(sus):
9494
susis.append((float(sus), float(sus), float(sus)))
9595
elif hasattr(sus, "__len__") and len(sus) == 3:
96-
susis.append(tuple(sus))
96+
try:
97+
sus_tuple = tuple(float(x) for x in sus)
98+
except Exception as e:
99+
msg = f"Each element of susceptibility 3-vector must be numeric. Got: {sus!r} ({e})"
100+
raise ValueError(msg)
101+
susis.append(sus_tuple)
97102
else:
98103
msg = "susceptibility is not scalar or array of length 3"
99104
raise ValueError(msg)

0 commit comments

Comments
 (0)