Skip to content

Commit dc5a412

Browse files
committed
Refactor demag.py for improved clarity and organization; enhance logging configuration
1 parent d3e9a7c commit dc5a412

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/magpylib_material_response/demag.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def _convert_to_array(susceptibility, n):
6666
if (
6767
hasattr(susceptibility, "__len__")
6868
and len(susceptibility) == 3
69-
and all(not isinstance(x, (list, tuple, np.ndarray)) for x in susceptibility)
69+
and all(not isinstance(x, list | tuple | np.ndarray) for x in susceptibility)
7070
):
7171
# This is a 3-vector, not a list of 3 items
7272
susis = np.tile(susceptibility, (n, 1))
@@ -97,7 +97,7 @@ def _convert_to_array(susceptibility, n):
9797
sus_tuple = tuple(float(x) for x in sus)
9898
except Exception as e:
9999
msg = f"Each element of susceptibility 3-vector must be numeric. Got: {sus!r} ({e})"
100-
raise ValueError(msg)
100+
raise ValueError(msg) from e
101101
susis.append(sus_tuple)
102102
else:
103103
msg = "susceptibility is not scalar or array of length 3"

0 commit comments

Comments
 (0)