Skip to content

Commit 9b9f7d2

Browse files
committed
fix linting
1 parent 1daa641 commit 9b9f7d2

File tree

7 files changed

+20
-30
lines changed

7 files changed

+20
-30
lines changed

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,6 @@ messages_control.disable = [
166166
"missing-module-docstring",
167167
"missing-function-docstring",
168168
"wrong-import-position",
169+
"invalid-name", # TODO - review later
170+
"protected-access", # TODO - review later
169171
]

src/magpylib_material_response/_data/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
from __future__ import annotations
66

7+
import importlib
8+
import json
9+
from pathlib import Path
710

8-
def get_dataset(name):
9-
import importlib
10-
import json
11-
from pathlib import Path
1211

12+
def get_dataset(name):
1313
name = Path(name).with_suffix("").with_suffix(".json")
1414
with (
1515
importlib.resources.path(

src/magpylib_material_response/demag.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
logger.configure(**config)
3232

3333

34-
def get_susceptibilities(sources, susceptibility):
34+
def get_susceptibilities(sources, susceptibility=None):
3535
"""Return a list of length (len(sources)) with susceptibility values
3636
Priority is given at the source level, however if value is not found, it is searched
3737
up the parent tree, if available. Raises an error if no value is found when reached
@@ -141,6 +141,8 @@ def demag_tensor(
141141
if pairs_matching and split != 1:
142142
msg = "Pairs matching does not support splitting"
143143
raise ValueError(msg)
144+
mask_inds = None
145+
getH_params = {}
144146
if max_dist != 0:
145147
mask_inds, getH_params, pos0, rot0 = filter_distance(
146148
src_list, max_dist, return_params=False, return_base_geo=True
@@ -158,7 +160,9 @@ def demag_tensor(
158160
# point matching field and demag tensor
159161
with timelog(f"getH with unit_pol={unit_pol}", min_log_time=min_log_time):
160162
if pairs_matching or max_dist != 0:
161-
polarization = np.repeat(pol_all, len(src_list), axis=0)[mask_inds]
163+
polarization = np.repeat(pol_all, len(src_list), axis=0)
164+
if mask_inds is not None:
165+
polarization = polarization[mask_inds]
162166
H_unique = magpy.getH(
163167
"Cuboid", polarization=polarization, **getH_params
164168
)

src/magpylib_material_response/meshing.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,13 +430,15 @@ def mesh_all(
430430
for child, targ_elems in zip(supported_objs, target_elems_by_child):
431431
parent = child.parent
432432
kw = kwargs if parent is None else {}
433+
child_meshed = None
433434
if isinstance(child, magpy.magnet.Cuboid):
434435
child_meshed = mesh_Cuboid(child, targ_elems, **kw)
435436
elif isinstance(child, magpy.magnet.Cylinder):
436437
child_meshed = mesh_Cylinder(child, targ_elems, **kw)
437-
child.parent = None
438-
if parent is not None:
439-
parent.add(child_meshed)
440-
else:
441-
obj = child_meshed
438+
if child_meshed is not None:
439+
child.parent = None
440+
if parent is not None:
441+
parent.add(child_meshed)
442+
else:
443+
obj = child_meshed
442444
return obj

src/magpylib_material_response/meshing_utils.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,6 @@ def mask_inside_Sphere(obj, positions, tolerance=1e-14):
176176
def mask_inside_CylinderSegment(obj, positions, tolerance=1e-14):
177177
"""Return mask of provided positions inside a CylinderSegment"""
178178

179-
def close(arg1, arg2):
180-
return np.isclose(arg1, arg2, rtol=tolerance, atol=tolerance)
181-
182179
r1, r2, h, phi1, phi2 = obj.dimension.T
183180
r1 = abs(r1)
184181
r2 = abs(r2)

src/magpylib_material_response/polyline.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -242,21 +242,6 @@ def move_grid_along_polyline(verts: np.ndarray, grid: np.ndarray) -> np.ndarray:
242242
"""
243243
Move a grid along a polyline, defined by the vertices.
244244
245-
Parameters
246-
----------
247-
verts : np.ndarray, shape (n, d)
248-
Array of polyline vertices, where n is the number of vertices and d is the dimension.
249-
grid : np.ndarray, shape (m, d)
250-
Array of grid points to move along the polyline, where m is the number of points.
251-
252-
Returns
253-
-------
254-
np.ndarray, shape (m, n, d)
255-
Array of moved grid points along the polyline, with the same dimensions as the input grid.
256-
"""
257-
"""
258-
Move a grid along a polyline, defined by the vertices.
259-
260245
Parameters
261246
----------
262247
verts : np.ndarray, shape (n, d)

tests/test_meshing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def test_slice_Cuboid2():
110110
np.testing.assert_allclose(cm[0].position, [0.0, 0.0, -0.45])
111111
np.testing.assert_allclose(cm[1].position, [0.0, 0.0, 0.05])
112112

113-
with pytest.raises(ValueError, match="Shift must be between 0 and 1 (exclusive)"):
113+
with pytest.raises(ValueError, match=r"Shift must be between 0 and 1 *."):
114114
slice_Cuboid(c, shift=0, axis="y")
115115

116116

0 commit comments

Comments
 (0)