Skip to content

Commit 3121949

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

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

magpylib_material_response/demag.py

+10-14
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ def get_susceptibilities(*sources, susceptibility):
4444
susceptibility = getattr(src, "susceptibility", None)
4545
if susceptibility is None:
4646
if src.parent is None:
47-
raise ValueError("No susceptibility defined in any parent collection")
47+
raise ValueError(
48+
"No susceptibility defined in any parent collection"
49+
)
4850
susceptibilities.extend(get_susceptibilities(src.parent))
4951
elif not hasattr(susceptibility, "__len__"):
50-
susceptibilities.append((susceptibility, susceptibility, susceptibility))
52+
susceptibilities.append(
53+
(susceptibility, susceptibility, susceptibility)
54+
)
5155
elif len(susceptibility) == 3:
5256
susceptibilities.append(susceptibility)
5357
else:
@@ -57,10 +61,10 @@ def get_susceptibilities(*sources, susceptibility):
5761
# susceptibilities as input to demag function
5862
n = len(sources)
5963
if np.isscalar(susceptibility):
60-
susceptibility = np.ones((n,3))*susceptibility
64+
susceptibility = np.ones((n, 3)) * susceptibility
6165
elif len(susceptibility) == 3:
62-
susceptibility = np.tile(susceptibility, (n,1))
63-
if n==3:
66+
susceptibility = np.tile(susceptibility, (n, 1))
67+
if n == 3:
6468
raise ValueError(
6569
"Apply_demag input susceptibility is ambiguous - either scalar list or vector single entry. "
6670
"Please choose different means of input or change the number of cells in the Collection."
@@ -72,21 +76,13 @@ def get_susceptibilities(*sources, susceptibility):
7276
)
7377
susceptibility = np.array(susceptibility)
7478
if susceptibility.ndim == 1:
75-
susceptibility = np.repeat(susceptibility,3).reshape(n,3)
79+
susceptibility = np.repeat(susceptibility, 3).reshape(n, 3)
7680

7781
susceptibility = np.reshape(susceptibility, 3 * n, order="F")
7882

79-
80-
81-
82-
83-
84-
8583
return np.array(susceptibilities)
8684

8785

88-
89-
9086
def get_H_ext(*sources, H_ext=None):
9187
"""Return a list of length (len(sources)) with H_ext values
9288
Priority is given at the source level, hovever if value is not found, it is searched up the

0 commit comments

Comments
 (0)