@@ -44,10 +44,14 @@ def get_susceptibilities(*sources, susceptibility):
44
44
susceptibility = getattr (src , "susceptibility" , None )
45
45
if susceptibility is None :
46
46
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
+ )
48
50
susceptibilities .extend (get_susceptibilities (src .parent ))
49
51
elif not hasattr (susceptibility , "__len__" ):
50
- susceptibilities .append ((susceptibility , susceptibility , susceptibility ))
52
+ susceptibilities .append (
53
+ (susceptibility , susceptibility , susceptibility )
54
+ )
51
55
elif len (susceptibility ) == 3 :
52
56
susceptibilities .append (susceptibility )
53
57
else :
@@ -57,10 +61,10 @@ def get_susceptibilities(*sources, susceptibility):
57
61
# susceptibilities as input to demag function
58
62
n = len (sources )
59
63
if np .isscalar (susceptibility ):
60
- susceptibility = np .ones ((n ,3 ))* susceptibility
64
+ susceptibility = np .ones ((n , 3 )) * susceptibility
61
65
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 :
64
68
raise ValueError (
65
69
"Apply_demag input susceptibility is ambiguous - either scalar list or vector single entry. "
66
70
"Please choose different means of input or change the number of cells in the Collection."
@@ -72,21 +76,13 @@ def get_susceptibilities(*sources, susceptibility):
72
76
)
73
77
susceptibility = np .array (susceptibility )
74
78
if susceptibility .ndim == 1 :
75
- susceptibility = np .repeat (susceptibility ,3 ).reshape (n ,3 )
79
+ susceptibility = np .repeat (susceptibility , 3 ).reshape (n , 3 )
76
80
77
81
susceptibility = np .reshape (susceptibility , 3 * n , order = "F" )
78
82
79
-
80
-
81
-
82
-
83
-
84
-
85
83
return np .array (susceptibilities )
86
84
87
85
88
-
89
-
90
86
def get_H_ext (* sources , H_ext = None ):
91
87
"""Return a list of length (len(sources)) with H_ext values
92
88
Priority is given at the source level, hovever if value is not found, it is searched up the
0 commit comments