Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 12, 2024
1 parent 1b9d885 commit 9818d51
Show file tree
Hide file tree
Showing 43 changed files with 74 additions and 74 deletions.
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

# Location of Sphinx files
sys.path.insert(0, os.path.abspath("./../")) ##Add the folder one level above
os.environ[
"SPHINX_APIDOC_OPTIONS"
] = "members,show-inheritance" ## Hide undocumented members
os.environ["SPHINX_APIDOC_OPTIONS"] = (
"members,show-inheritance" ## Hide undocumented members
)
import sphinx.ext.apidoc

# from sphinx_gallery.sorting import FileNameSortKey
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/defaults/defaults_utility.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""utilities for creating property classes"""

# pylint: disable=too-many-branches
import collections.abc
import re
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/display/backend_matplotlib.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""matplotlib backend"""

# pylint: disable=too-many-branches
# pylint: disable=too-many-statements
# pylint: disable=import-outside-toplevel
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/display/backend_plotly.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""plotly backend"""

# pylint: disable=C0302
# pylint: disable=too-many-branches
import inspect
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/display/backend_pyvista.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""pyvista backend"""

# pylint: disable=too-many-branches
# pylint: disable=too-many-statements
import os
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/display/display.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Display function codes"""

import warnings
from contextlib import contextmanager
from importlib import import_module
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/display/traces_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""base traces building functions"""

from functools import partial

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/display/traces_core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Generic trace drawing functionalities"""

# pylint: disable=C0302
# pylint: disable=too-many-branches
# pylint: disable=too-many-statements
Expand Down
15 changes: 7 additions & 8 deletions magpylib/_src/display/traces_generic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Generic trace drawing functionalities"""

# pylint: disable=C0302
# pylint: disable=too-many-branches
# pylint: disable=too-many-statements
Expand Down Expand Up @@ -559,9 +560,7 @@ def get_generic_traces(
tr["showlegend"] = (
showlegend
if showlegend is not None
else tr_showleg
if style.legend.show
else False
else tr_showleg if style.legend.show else False
)
out = {"generic": path_traces_generic}

Expand All @@ -580,11 +579,11 @@ def get_generic_traces(
"opacity": style.opacity,
"color": style.color,
"legendgroup": legendgroup,
"showlegend": showlegend
if showlegend is not None
else None
if style.legend.show
else False,
"showlegend": (
showlegend
if showlegend is not None
else None if style.legend.show else False
),
"name": legendtext if legendtext else legend_label,
"row": row,
"col": col,
Expand Down
5 changes: 2 additions & 3 deletions magpylib/_src/display/traces_utility.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Display function codes"""

# pylint: disable=too-many-branches
from collections import defaultdict
from functools import lru_cache
Expand Down Expand Up @@ -136,9 +137,7 @@ def draw_arrowed_line(
anchor = (
(0, -0.5, 0)
if pivot == "tip"
else (0, 0.5, 0)
if pivot == "tail"
else (0, 0, 0)
else (0, 0.5, 0) if pivot == "tail" else (0, 0, 0)
)
arrow = [
[0, arrow_shift, 0],
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/fields/field_BH_circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Implementations of analytical expressions for the magnetic field of
a circular current loop. Computation details in function docstrings.
"""

import warnings

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/fields/field_BH_cuboid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Implementations of analytical expressions for the magnetic field of homogeneously
magnetized Cuboids. Computation details in function docstrings.
"""

import numpy as np

from magpylib._src.input_checks import check_field_input
Expand Down
6 changes: 2 additions & 4 deletions magpylib/_src/fields/field_BH_cylinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Implementations of analytical expressions for the magnetic field of
homogeneously magnetized Cylinders. Computation details in function docstrings.
"""

# pylint: disable = no-name-in-module
import numpy as np
from scipy.special import ellipe
Expand Down Expand Up @@ -154,10 +155,7 @@ def fieldH_cylinder_diametral(
+ 3
/ 8
* r3X
* (
(1 - 4 * zp2X) / zpp**3 / sqrt_p
- (1 - 4 * zm2X) / zmm**3 / sqrt_m
)
* ((1 - 4 * zp2X) / zpp**3 / sqrt_p - (1 - 4 * zm2X) / zmm**3 / sqrt_m)
+ 15
/ 64
* r5X
Expand Down
54 changes: 13 additions & 41 deletions magpylib/_src/fields/field_BH_cylinder_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,7 @@ def Hz_ri_case115(r, r_i, r_bar_i, phi_bar_j, phi_bar_M, theta_M):
E_coef = np.sin(theta_M) * np.cos(phi_bar_M) * np.abs(r_bar_i) / r
F = ellipkinc(phi_bar_j / 2.0, -4.0 * r * r_i / r_bar_i**2)
F_coef = (
-np.sin(theta_M)
* np.cos(phi_bar_M)
* (r**2 + r_i**2)
/ (r * np.abs(r_bar_i))
-np.sin(theta_M) * np.cos(phi_bar_M) * (r**2 + r_i**2) / (r * np.abs(r_bar_i))
)
return t1_coef * t1 + E_coef * E + F_coef * F

Expand Down Expand Up @@ -222,10 +219,7 @@ def Hz_ri_case125(r, r_i, r_bar_i, phi_bar_j, phi_bar_M, theta_M):
E_coef = np.sin(theta_M) * np.cos(phi_bar_M) * np.abs(r_bar_i) / r
F = ellipkinc(phi_bar_j / 2.0, -4.0 * r * r_i / r_bar_i**2)
F_coef = (
-np.sin(theta_M)
* np.cos(phi_bar_M)
* (r**2 + r_i**2)
/ (r * np.abs(r_bar_i))
-np.sin(theta_M) * np.cos(phi_bar_M) * (r**2 + r_i**2) / (r * np.abs(r_bar_i))
)
return np.sin(theta_M) * np.sin(phi_bar_M) * (r + r_i) / r + E_coef * E + F_coef * F

Expand Down Expand Up @@ -349,9 +343,7 @@ def Hz_ri_case135(r, r_i, r_bar_i, phi_bar_j, phi_bar_M, theta_M):
E = ellipeinc(phi_bar_j / 2.0, -4.0 * r * r_i / t)
E_coef = np.sin(theta_M) * np.cos(phi_bar_M) * np.sqrt(t) / r
F = ellipkinc(phi_bar_j / 2.0, -4.0 * r * r_i / t)
F_coef = (
-np.sin(theta_M) * np.cos(phi_bar_M) * (r**2 + r_i**2) / (r * np.sqrt(t))
)
F_coef = -np.sin(theta_M) * np.cos(phi_bar_M) * (r**2 + r_i**2) / (r * np.sqrt(t))
return t1_coef * t1 + E_coef * E + F_coef * F


Expand Down Expand Up @@ -508,9 +500,7 @@ def Hr_zk_case214(r, phi_bar_j, theta_M, z_bar_k):
t = np.sqrt(r**2 + z_bar_k**2)

def Pi1(sign):
return el3_angle(
phi_bar_j / 2, 2 * r / (r + sign * t), -4 * r**2 / z_bar_k**2
)
return el3_angle(phi_bar_j / 2, 2 * r / (r + sign * t), -4 * r**2 / z_bar_k**2)

def Pi1_coef(sign):
return (
Expand Down Expand Up @@ -603,9 +593,7 @@ def Hz_zk_case214(r, phi_bar_j, theta_M, z_bar_k):
t = np.sqrt(r**2 + z_bar_k**2)

def Pi(sign):
return el3_angle(
phi_bar_j / 2, 2 * r / (r + sign * t), -4 * r**2 / z_bar_k**2
)
return el3_angle(phi_bar_j / 2, 2 * r / (r + sign * t), -4 * r**2 / z_bar_k**2)

Pi_coef = np.cos(theta_M) * np.sign(z_bar_k)
return Pi_coef * Pi(1) + Pi_coef * Pi(-1)
Expand Down Expand Up @@ -728,9 +716,7 @@ def Hphi_ri_case215(r, r_i, r_bar_i, phi_bar_j, phi_bar_M, theta_M, z_bar_k):
t1 = np.sqrt(r_bar_i**2 + z_bar_k**2) * z_bar_k / (2.0 * r**2)
t1_coef = -np.sin(theta_M) * np.cos(phi_bar_M)
t2 = np.arctanh(z_bar_k / np.sqrt(r_bar_i**2 + z_bar_k**2))
t2_coef = (
-np.sin(theta_M) * np.cos(phi_bar_M) * (r**2 + r_i**2) / (2.0 * r**2)
)
t2_coef = -np.sin(theta_M) * np.cos(phi_bar_M) * (r**2 + r_i**2) / (2.0 * r**2)
E = ellipeinc(phi_bar_j / 2.0, -4.0 * r * r_i / (r_bar_i**2 + z_bar_k**2))
E_coef = (
np.sin(theta_M)
Expand Down Expand Up @@ -902,9 +888,7 @@ def Hz_phij_case223(r, phi_bar_M, theta_M, z_bar_k):


def Hz_zk_case223(r, phi_bar_j, theta_M, z_bar_k):
t1 = arctan_k_tan_2(
np.sqrt(r**2 + z_bar_k**2) / np.abs(z_bar_k), 2.0 * phi_bar_j
)
t1 = arctan_k_tan_2(np.sqrt(r**2 + z_bar_k**2) / np.abs(z_bar_k), 2.0 * phi_bar_j)
t1_coef = np.cos(theta_M) * np.sign(z_bar_k)
return t1_coef * t1

Expand Down Expand Up @@ -1163,9 +1147,7 @@ def Hphi_ri_case225(r, r_i, r_bar_i, phi_bar_j, phi_bar_M, theta_M, z_bar_k):
t1 = np.sqrt((r + r_i) ** 2 + z_bar_k**2) * z_bar_k / (2.0 * r**2)
t1_coef = -np.sin(theta_M) * np.cos(phi_bar_M)
t2 = np.arctanh(z_bar_k / np.sqrt((r + r_i) ** 2 + z_bar_k**2))
t2_coef = (
-np.sin(theta_M) * np.cos(phi_bar_M) * (r**2 + r_i**2) / (2.0 * r**2)
)
t2_coef = -np.sin(theta_M) * np.cos(phi_bar_M) * (r**2 + r_i**2) / (2.0 * r**2)
E = ellipeinc(phi_bar_j / 2.0, -4.0 * r * r_i / (r_bar_i**2 + z_bar_k**2))
E_coef = (
np.sin(theta_M)
Expand Down Expand Up @@ -1400,9 +1382,7 @@ def Hz_phij_case233(r, phi_bar_j, phi_bar_Mj, theta_M, z_bar_k):


def Hz_zk_case233(r, phi_bar_j, theta_M, z_bar_k):
t1 = arctan_k_tan_2(
np.sqrt(r**2 + z_bar_k**2) / np.abs(z_bar_k), 2.0 * phi_bar_j
)
t1 = arctan_k_tan_2(np.sqrt(r**2 + z_bar_k**2) / np.abs(z_bar_k), 2.0 * phi_bar_j)
t1_coef = np.cos(theta_M) * np.sign(z_bar_k)
return t1_coef * t1

Expand Down Expand Up @@ -1480,9 +1460,7 @@ def Pi1_coef(sign):

def Pi2(sign):
return el3_angle(
arctan_k_tan_2(
np.sqrt((4.0 * r**2 + z_bar_k**2) / z_bar_k**2), phi_bar_j
),
arctan_k_tan_2(np.sqrt((4.0 * r**2 + z_bar_k**2) / z_bar_k**2), phi_bar_j),
1.0 - z_bar_k**4 / ((4.0 * r**2 + z_bar_k**2) * (r + sign * t) ** 2),
4.0 * r**2 / (4.0 * r**2 + z_bar_k**2),
)
Expand Down Expand Up @@ -1647,9 +1625,7 @@ def Hr_phij_case235(r, r_i, phi_bar_j, phi_bar_Mj, theta_M, z_bar_k):
/ (
r
* np.sin(phi_bar_j)
* np.sqrt(
r**2 + r_i**2 - 2.0 * r * r_i * np.cos(phi_bar_j) + z_bar_k**2
)
* np.sqrt(r**2 + r_i**2 - 2.0 * r * r_i * np.cos(phi_bar_j) + z_bar_k**2)
)
)
t2_coef = np.sin(theta_M) * np.sin(phi_bar_Mj) * np.sin(phi_bar_j)
Expand Down Expand Up @@ -1695,9 +1671,7 @@ def Pi1_coef(sign):
def Pi2(sign):
return el3_angle(
arctan_k_tan_2(
np.sqrt(
((r_i + r) ** 2 + z_bar_k**2) / (r_bar_i**2 + z_bar_k**2)
),
np.sqrt(((r_i + r) ** 2 + z_bar_k**2) / (r_bar_i**2 + z_bar_k**2)),
phi_bar_j,
),
1.0
Expand Down Expand Up @@ -1740,9 +1714,7 @@ def Hphi_ri_case235(r, r_i, r_bar_i, phi_bar_j, phi_bar_M, theta_M, z_bar_k):
z_bar_k
/ np.sqrt(r**2 + r_i**2 - 2.0 * r * r_i * np.cos(phi_bar_j) + z_bar_k**2)
)
t2_coef = (
-np.sin(theta_M) * np.cos(phi_bar_M) * (r**2 + r_i**2) / (2.0 * r**2)
)
t2_coef = -np.sin(theta_M) * np.cos(phi_bar_M) * (r**2 + r_i**2) / (2.0 * r**2)
E = ellipeinc(phi_bar_j / 2.0, -4.0 * r * r_i / (r_bar_i**2 + z_bar_k**2))
E_coef = (
np.sin(theta_M)
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/fields/field_BH_dipole.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Core implementation of dipole field
"""

import numpy as np

from magpylib._src.input_checks import check_field_input
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/fields/field_BH_polyline.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Implementations of analytical expressions of line current segments
"""

import warnings

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/fields/field_BH_sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Implementations of analytical expressions for the magnetic field of homogeneously
magnetized Spheres. Computation details in function docstrings.
"""

import numpy as np

from magpylib._src.input_checks import check_field_input
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/fields/field_BH_tetrahedron.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Implementation for the magnetic field of homogeneously
magnetized tetrahedra. Computation details in function docstrings.
"""

import numpy as np

from magpylib._src.fields.field_BH_triangle import triangle_field
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/fields/field_BH_triangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Implementations of analytical expressions for the magnetic field of a triangular surface.
Computation details in function docstrings.
"""

# pylance: disable=Code is unreachable
import numpy as np

Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/fields/field_BH_triangularmesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Implementations of analytical expressions for the magnetic field of a triangular surface.
Computation details in function docstrings.
"""

# pylint: disable=too-many-nested-blocks
# pylance: disable=Code is unreachable
import numpy as np
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/fields/field_wrap_BH.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
level5(sens.getB, sens.getH): <--- USER INTERFACE
"""

# pylint: disable=cyclic-import
import numbers
import warnings
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/input_checks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" input checks code"""

# pylint: disable=import-outside-toplevel
# pylint: disable=cyclic-import
import inspect
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/obj_classes/class_BaseDisplayRepr.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""BaseGeo class code"""

# pylint: disable=cyclic-import
# pylint: disable=too-many-branches
import numpy as np
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/obj_classes/class_BaseExcitations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""BaseHomMag class code"""

# pylint: disable=cyclic-import
import warnings

Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/obj_classes/class_BaseGeo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""BaseGeo class code"""

# pylint: disable=cyclic-import
# pylint: disable=too-many-instance-attributes
# pylint: disable=protected-access
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/obj_classes/class_BaseTransform.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""BaseTransform class code"""

# pylint: disable=protected-access
import numbers

Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/obj_classes/class_Collection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Collection class code"""

# pylint: disable=redefined-builtin
# pylint: disable=import-outside-toplevel
from collections import Counter
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/obj_classes/class_Sensor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Sensor class code"""

import numpy as np

from magpylib._src.display.traces_core import make_Sensor
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/obj_classes/class_current_Circle.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CircularCircle current class code"""

import warnings

from magpylib._src.display.traces_core import make_Circle
Expand Down
1 change: 1 addition & 0 deletions magpylib/_src/obj_classes/class_current_Polyline.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Polyline current class code"""

import warnings

from magpylib._src.display.traces_core import make_Polyline
Expand Down

0 comments on commit 9818d51

Please sign in to comment.