Skip to content

Commit b6c7a20

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 8dfbce0 commit b6c7a20

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

magpylib_material_response/demag.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,17 @@ def get_susceptibilities(sources, susceptibility):
3737
up the parent tree, if available. Raises an error if no value is found when reached
3838
the top level of the tree."""
3939
n = len(sources)
40-
40+
4141
# susceptibilities from source attributes
4242
if susceptibility is None:
4343
susis = []
4444
for src in sources:
4545
susceptibility = getattr(src, "susceptibility", None)
4646
if susceptibility is None:
4747
if src.parent is None:
48-
raise ValueError("No susceptibility defined in any parent collection")
48+
raise ValueError(
49+
"No susceptibility defined in any parent collection"
50+
)
4951
susis.extend(get_susceptibilities(src.parent))
5052
elif not hasattr(susceptibility, "__len__"):
5153
susis.append((susceptibility, susceptibility, susceptibility))
@@ -56,10 +58,10 @@ def get_susceptibilities(sources, susceptibility):
5658
else:
5759
# susceptibilities as input to demag function
5860
if np.isscalar(susceptibility):
59-
susis = np.ones((n,3))*susceptibility
61+
susis = np.ones((n, 3)) * susceptibility
6062
elif len(susceptibility) == 3:
61-
susis = np.tile(susceptibility, (n,1))
62-
if n==3:
63+
susis = np.tile(susceptibility, (n, 1))
64+
if n == 3:
6365
raise ValueError(
6466
"Apply_demag input susceptibility is ambiguous - either scalar list or vector single entry. "
6567
"Please choose different means of input or change the number of cells in the Collection."
@@ -71,7 +73,7 @@ def get_susceptibilities(sources, susceptibility):
7173
)
7274
susis = np.array(susceptibility)
7375
if susis.ndim == 1:
74-
susis = np.repeat(susis,3).reshape(n,3)
76+
susis = np.repeat(susis, 3).reshape(n, 3)
7577

7678
susis = np.reshape(susis, 3 * n, order="F")
7779
return np.array(susis)

0 commit comments

Comments
 (0)