Skip to content

Commit 248943d

Browse files
committed
pre-commit run
1 parent b9d4584 commit 248943d

File tree

11 files changed

+39
-27
lines changed

11 files changed

+39
-27
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616

1717
# 0.2.0a0
1818
* renaming xi->susceptibility ([#5](https://github.com/magpylib/magpylib-material-response/pull/5))
19-
* update to magpylib v5 ([#4](https://github.com/magpylib/magpylib-material-response/pull/4))
19+
* update to magpylib v5 ([#4](https://github.com/magpylib/magpylib-material-response/pull/4))

src/magpylib_material_response/demag.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
# +
44
# pylint: disable=invalid-name, redefined-outer-name, protected-access
5+
from __future__ import annotations
6+
57
import sys
68
from collections import Counter
79

@@ -55,25 +57,24 @@ def get_susceptibilities(sources, susceptibility):
5557
susis.append(susceptibility)
5658
else:
5759
raise ValueError("susceptibility is not scalar or array fo length 3")
60+
# susceptibilities as input to demag function
61+
elif np.isscalar(susceptibility):
62+
susis = np.ones((n, 3)) * susceptibility
63+
elif len(susceptibility) == 3:
64+
susis = np.tile(susceptibility, (n, 1))
65+
if n == 3:
66+
raise ValueError(
67+
"Apply_demag input susceptibility is ambiguous - either scalar list or vector single entry. "
68+
"Please choose different means of input or change the number of cells in the Collection."
69+
)
5870
else:
59-
# susceptibilities as input to demag function
60-
if np.isscalar(susceptibility):
61-
susis = np.ones((n, 3)) * susceptibility
62-
elif len(susceptibility) == 3:
63-
susis = np.tile(susceptibility, (n, 1))
64-
if n == 3:
65-
raise ValueError(
66-
"Apply_demag input susceptibility is ambiguous - either scalar list or vector single entry. "
67-
"Please choose different means of input or change the number of cells in the Collection."
68-
)
69-
else:
70-
if len(susceptibility) != n:
71-
raise ValueError(
72-
"Apply_demag input susceptibility must be scalar, 3-vector, or same length as input Collection."
73-
)
74-
susis = np.array(susceptibility)
75-
if susis.ndim == 1:
76-
susis = np.repeat(susis, 3).reshape(n, 3)
71+
if len(susceptibility) != n:
72+
raise ValueError(
73+
"Apply_demag input susceptibility must be scalar, 3-vector, or same length as input Collection."
74+
)
75+
susis = np.array(susceptibility)
76+
if susis.ndim == 1:
77+
susis = np.repeat(susis, 3).reshape(n, 3)
7778

7879
susis = np.reshape(susis, 3 * n, order="F")
7980
return np.array(susis)
@@ -141,7 +142,7 @@ def demag_tensor(
141142

142143
if pairs_matching and split != 1:
143144
raise ValueError("Pairs matching does not support splitting")
144-
elif max_dist != 0:
145+
if max_dist != 0:
145146
mask_inds, getH_params, pos0, rot0 = filter_distance(
146147
src_list, max_dist, return_params=False, return_base_geo=True
147148
)
@@ -179,7 +180,7 @@ def demag_tensor(
179180
H_unit_pol = []
180181
for split_ind, src_list_subset in enumerate(src_list_split):
181182
logger.info(
182-
f"Sources subset {split_ind+1}/{len(src_list_split)}"
183+
f"Sources subset {split_ind + 1}/{len(src_list_split)}"
183184
)
184185
if src_list_subset.size > 0:
185186
H_unit_pol.append(

src/magpylib_material_response/meshing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from collections import Counter
24
from itertools import product
35

src/magpylib_material_response/meshing_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from itertools import product
24

35
import numpy as np

src/magpylib_material_response/package_data/datasets/FEMdata_test_cuboids.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/magpylib_material_response/package_data/datasets/FEMdata_test_softmag.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/magpylib_material_response/polyline.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import numpy as np
24

35

src/magpylib_material_response/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import threading
24
import time
35
import warnings
@@ -61,7 +63,7 @@ def timelog(msg, min_log_time=1):
6163

6264
if end > min_log_time:
6365
logger.opt(colors=True).success(
64-
f"{msg} done" f"<green> 🕑 {round(end, 3)}sec</green>"
66+
f"{msg} done<green> 🕑 {round(end, 3)}sec</green>"
6567
)
6668

6769

tests/test_basic.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import magpylib as magpy
24
import numpy as np
35

tests/test_isotropic_anisotropic.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
from __future__ import annotations
2+
13
import magpylib as magpy
24
import numpy as np
35

46
from magpylib_material_response import demag, meshing
57

68

79
def test_isotropic_susceptibility():
8-
910
cells = 1000 # should be >=1000, otherwise discretization error too large
1011

1112
magnet = magpy.magnet.Cuboid(dimension=(1e-3, 1e-3, 1e-3), polarization=(0, 0, 1.1))
@@ -25,7 +26,6 @@ def test_isotropic_susceptibility():
2526

2627

2728
def test_anisotropic_susceptibility():
28-
2929
cells = 1000 # should be >=1000, otherwise discretization error too large
3030

3131
magnet = magpy.magnet.Cuboid(dimension=(1e-3, 1e-3, 1e-3), polarization=(0, 0, 1.1))
@@ -45,7 +45,6 @@ def test_anisotropic_susceptibility():
4545

4646

4747
def test_negative_susceptibility():
48-
4948
cells = 1000 # should be >=1000, otherwise discretization error too large
5049

5150
magnet = magpy.magnet.Cuboid(

0 commit comments

Comments
 (0)