Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
# -----------------------------------------------------------------------------
project = "Choclo"
copyright = (
f"{datetime.datetime.now(tz=datetime.timezone.utc).date().year}, "
f"The {project} Developers"
f"{datetime.datetime.now(tz=datetime.UTC).date().year}, The {project} Developers"
)
is_dev_version = len(choclo.__version__.split(".")) > 3
version = "dev" if is_dev_version else choclo.__version__
Expand Down
95 changes: 61 additions & 34 deletions test/test_dipole.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,18 @@ def test_symmetry_across_easting_northing(
[
magnetic_e(e, n, u, *sample_dipole, *magnetic_moment)
for e, n, u in zip(
easting.ravel(), northing.ravel(), upward_top.ravel()
easting.ravel(), northing.ravel(), upward_top.ravel(), strict=False
)
]
)
b_e_bottom = np.array(
[
magnetic_e(e, n, u, *sample_dipole, *magnetic_moment)
for e, n, u in zip(
easting.ravel(), northing.ravel(), upward_bottom.ravel()
easting.ravel(),
northing.ravel(),
upward_bottom.ravel(),
strict=False,
)
]
)
Expand Down Expand Up @@ -145,15 +148,21 @@ def test_symmetry_across_easting_upward(
[
magnetic_e(e, n, u, *sample_dipole, *magnetic_moment)
for e, n, u in zip(
easting.ravel(), northing_north.ravel(), upward.ravel()
easting.ravel(),
northing_north.ravel(),
upward.ravel(),
strict=False,
)
]
)
b_e_south = np.array(
[
magnetic_e(e, n, u, *sample_dipole, *magnetic_moment)
for e, n, u in zip(
easting.ravel(), northing_south.ravel(), upward.ravel()
easting.ravel(),
northing_south.ravel(),
upward.ravel(),
strict=False,
)
]
)
Expand Down Expand Up @@ -195,15 +204,15 @@ def test_symmetry_across_northing_upward(
[
magnetic_e(e, n, u, *sample_dipole, *magnetic_moment)
for e, n, u in zip(
easting_east.ravel(), northing.ravel(), upward.ravel()
easting_east.ravel(), northing.ravel(), upward.ravel(), strict=False
)
]
)
b_e_west = np.array(
[
magnetic_e(e, n, u, *sample_dipole, *magnetic_moment)
for e, n, u in zip(
easting_west.ravel(), northing.ravel(), upward.ravel()
easting_west.ravel(), northing.ravel(), upward.ravel(), strict=False
)
]
)
Expand Down Expand Up @@ -231,13 +240,13 @@ def test_symmetry_when_flipping(self, sample_3d_grid, sample_dipole):
b_e_east = np.array(
[
magnetic_e(e, n, u, *sample_dipole, *magnetic_moment_east)
for e, n, u in zip(easting, northing, upward)
for e, n, u in zip(easting, northing, upward, strict=False)
]
)
b_e_west = np.array(
[
magnetic_e(e, n, u, *sample_dipole, *magnetic_moment_west)
for e, n, u in zip(easting, northing, upward)
for e, n, u in zip(easting, northing, upward, strict=False)
]
)
# Check if the sign gets inverted
Expand Down Expand Up @@ -283,15 +292,18 @@ def test_symmetry_across_easting_northing(
[
magnetic_n(e, n, u, *sample_dipole, *magnetic_moment)
for e, n, u in zip(
easting.ravel(), northing.ravel(), upward_top.ravel()
easting.ravel(), northing.ravel(), upward_top.ravel(), strict=False
)
]
)
b_n_bottom = np.array(
[
magnetic_n(e, n, u, *sample_dipole, *magnetic_moment)
for e, n, u in zip(
easting.ravel(), northing.ravel(), upward_bottom.ravel()
easting.ravel(),
northing.ravel(),
upward_bottom.ravel(),
strict=False,
)
]
)
Expand Down Expand Up @@ -333,15 +345,21 @@ def test_symmetry_across_easting_upward(
[
magnetic_n(e, n, u, *sample_dipole, *magnetic_moment)
for e, n, u in zip(
easting.ravel(), northing_north.ravel(), upward.ravel()
easting.ravel(),
northing_north.ravel(),
upward.ravel(),
strict=False,
)
]
)
b_n_south = np.array(
[
magnetic_n(e, n, u, *sample_dipole, *magnetic_moment)
for e, n, u in zip(
easting.ravel(), northing_south.ravel(), upward.ravel()
easting.ravel(),
northing_south.ravel(),
upward.ravel(),
strict=False,
)
]
)
Expand Down Expand Up @@ -383,15 +401,15 @@ def test_symmetry_across_northing_upward(
[
magnetic_n(e, n, u, *sample_dipole, *magnetic_moment)
for e, n, u in zip(
easting_east.ravel(), northing.ravel(), upward.ravel()
easting_east.ravel(), northing.ravel(), upward.ravel(), strict=False
)
]
)
b_n_west = np.array(
[
magnetic_n(e, n, u, *sample_dipole, *magnetic_moment)
for e, n, u in zip(
easting_west.ravel(), northing.ravel(), upward.ravel()
easting_west.ravel(), northing.ravel(), upward.ravel(), strict=False
)
]
)
Expand Down Expand Up @@ -419,13 +437,13 @@ def test_symmetry_when_flipping(self, sample_3d_grid, sample_dipole):
b_n_north = np.array(
[
magnetic_n(e, n, u, *sample_dipole, *magnetic_moment_north)
for e, n, u in zip(easting, northing, upward)
for e, n, u in zip(easting, northing, upward, strict=False)
]
)
b_n_south = np.array(
[
magnetic_n(e, n, u, *sample_dipole, *magnetic_moment_south)
for e, n, u in zip(easting, northing, upward)
for e, n, u in zip(easting, northing, upward, strict=False)
]
)
# Check if the sign gets inverted
Expand Down Expand Up @@ -471,15 +489,18 @@ def test_symmetry_across_easting_northing(
[
magnetic_u(e, n, u, *sample_dipole, *magnetic_moment)
for e, n, u in zip(
easting.ravel(), northing.ravel(), upward_top.ravel()
easting.ravel(), northing.ravel(), upward_top.ravel(), strict=False
)
]
)
b_u_bottom = np.array(
[
magnetic_u(e, n, u, *sample_dipole, *magnetic_moment)
for e, n, u in zip(
easting.ravel(), northing.ravel(), upward_bottom.ravel()
easting.ravel(),
northing.ravel(),
upward_bottom.ravel(),
strict=False,
)
]
)
Expand Down Expand Up @@ -521,15 +542,21 @@ def test_symmetry_across_easting_upward(
[
magnetic_u(e, n, u, *sample_dipole, *magnetic_moment)
for e, n, u in zip(
easting.ravel(), northing_north.ravel(), upward.ravel()
easting.ravel(),
northing_north.ravel(),
upward.ravel(),
strict=False,
)
]
)
b_u_south = np.array(
[
magnetic_u(e, n, u, *sample_dipole, *magnetic_moment)
for e, n, u in zip(
easting.ravel(), northing_south.ravel(), upward.ravel()
easting.ravel(),
northing_south.ravel(),
upward.ravel(),
strict=False,
)
]
)
Expand Down Expand Up @@ -571,15 +598,15 @@ def test_symmetry_across_northing_upward(
[
magnetic_u(e, n, u, *sample_dipole, *magnetic_moment)
for e, n, u in zip(
easting_east.ravel(), northing.ravel(), upward.ravel()
easting_east.ravel(), northing.ravel(), upward.ravel(), strict=False
)
]
)
b_u_west = np.array(
[
magnetic_u(e, n, u, *sample_dipole, *magnetic_moment)
for e, n, u in zip(
easting_west.ravel(), northing.ravel(), upward.ravel()
easting_west.ravel(), northing.ravel(), upward.ravel(), strict=False
)
]
)
Expand Down Expand Up @@ -607,13 +634,13 @@ def test_symmetry_when_flipping(self, sample_3d_grid, sample_dipole):
b_u_up = np.array(
[
magnetic_u(e, n, u, *sample_dipole, *magnetic_moment_up)
for e, n, u in zip(easting, northing, upward)
for e, n, u in zip(easting, northing, upward, strict=False)
]
)
b_u_down = np.array(
[
magnetic_u(e, n, u, *sample_dipole, *magnetic_moment_down)
for e, n, u in zip(easting, northing, upward)
for e, n, u in zip(easting, northing, upward, strict=False)
]
)
# Check if the sign gets inverted
Expand All @@ -639,27 +666,27 @@ def test_magnetic_field(
b = np.array(
[
magnetic_field(e, n, u, *sample_dipole, *sample_magnetic_moment)
for e, n, u in zip(*sample_3d_grid)
for e, n, u in zip(*sample_3d_grid, strict=False)
]
)
b_e, b_n, b_u = tuple(b[:, i] for i in range(3))
# Computed the individual fields
b_e_expected = np.array(
[
magnetic_e(e, n, u, *sample_dipole, *sample_magnetic_moment)
for e, n, u in zip(*sample_3d_grid)
for e, n, u in zip(*sample_3d_grid, strict=False)
]
)
b_n_expected = np.array(
[
magnetic_n(e, n, u, *sample_dipole, *sample_magnetic_moment)
for e, n, u in zip(*sample_3d_grid)
for e, n, u in zip(*sample_3d_grid, strict=False)
]
)
b_u_expected = np.array(
[
magnetic_u(e, n, u, *sample_dipole, *sample_magnetic_moment)
for e, n, u in zip(*sample_3d_grid)
for e, n, u in zip(*sample_3d_grid, strict=False)
]
)
npt.assert_allclose(b_e, b_e_expected)
Expand Down Expand Up @@ -689,13 +716,13 @@ def get_b_ee_finite_differences(self, coordinates, dipole, magnetic_moment):
b_e = np.array(
[
magnetic_e(e, n, u, *dipole, *magnetic_moment)
for e, n, u in zip(easting, northing, upward)
for e, n, u in zip(easting, northing, upward, strict=False)
]
)
b_e_shifted = np.array(
[
magnetic_e(e, n, u, *dipole, *magnetic_moment)
for e, n, u in zip(easting_shifted, northing, upward)
for e, n, u in zip(easting_shifted, northing, upward, strict=False)
]
)
# Compute b_ee
Expand All @@ -714,13 +741,13 @@ def get_b_nn_finite_differences(self, coordinates, dipole, magnetic_moment):
b_n = np.array(
[
magnetic_n(e, n, u, *dipole, *magnetic_moment)
for e, n, u in zip(easting, northing, upward)
for e, n, u in zip(easting, northing, upward, strict=False)
]
)
b_n_shifted = np.array(
[
magnetic_n(e, n, u, *dipole, *magnetic_moment)
for e, n, u in zip(easting, northing_shifted, upward)
for e, n, u in zip(easting, northing_shifted, upward, strict=False)
]
)
# Compute b_nn
Expand All @@ -739,13 +766,13 @@ def get_b_uu_finite_differences(self, coordinates, dipole, magnetic_moment):
b_u = np.array(
[
magnetic_u(e, n, u, *dipole, *magnetic_moment)
for e, n, u in zip(easting, northing, upward)
for e, n, u in zip(easting, northing, upward, strict=False)
]
)
b_u_shifted = np.array(
[
magnetic_u(e, n, u, *dipole, *magnetic_moment)
for e, n, u in zip(easting, northing, upward_shifted)
for e, n, u in zip(easting, northing, upward_shifted, strict=False)
]
)
# Compute b_uu
Expand Down
Loading
Loading