From 20154bd7407832fd80f1a40f05b4502a8d41f11a Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Wed, 28 Oct 2026 17:21:33 -0700 Subject: [PATCH] Autofix Ruff warnings Fix the new Ruff warnings through its auto-fix option. Enable unsafe fixes to allow it to add the `strict` option to the `zip` function. --- doc/conf.py | 3 +- test/test_dipole.py | 95 ++++++++++++++++++++++++------------- test/test_point_gravity.py | 28 +++++------ test/test_prism_gravity.py | 63 +++++++++++++----------- test/test_prism_magnetic.py | 17 ++++--- 5 files changed, 120 insertions(+), 86 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index b0ad3994..39081c18 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -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__ diff --git a/test/test_dipole.py b/test/test_dipole.py index f6fac6ee..0ef89003 100644 --- a/test/test_dipole.py +++ b/test/test_dipole.py @@ -95,7 +95,7 @@ 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 ) ] ) @@ -103,7 +103,10 @@ 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_bottom.ravel() + easting.ravel(), + northing.ravel(), + upward_bottom.ravel(), + strict=False, ) ] ) @@ -145,7 +148,10 @@ 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, ) ] ) @@ -153,7 +159,10 @@ def test_symmetry_across_easting_upward( [ 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, ) ] ) @@ -195,7 +204,7 @@ 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 ) ] ) @@ -203,7 +212,7 @@ def test_symmetry_across_northing_upward( [ 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 ) ] ) @@ -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 @@ -283,7 +292,7 @@ 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 ) ] ) @@ -291,7 +300,10 @@ 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_bottom.ravel() + easting.ravel(), + northing.ravel(), + upward_bottom.ravel(), + strict=False, ) ] ) @@ -333,7 +345,10 @@ 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, ) ] ) @@ -341,7 +356,10 @@ def test_symmetry_across_easting_upward( [ 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, ) ] ) @@ -383,7 +401,7 @@ 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 ) ] ) @@ -391,7 +409,7 @@ def test_symmetry_across_northing_upward( [ 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 ) ] ) @@ -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 @@ -471,7 +489,7 @@ 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 ) ] ) @@ -479,7 +497,10 @@ 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_bottom.ravel() + easting.ravel(), + northing.ravel(), + upward_bottom.ravel(), + strict=False, ) ] ) @@ -521,7 +542,10 @@ 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, ) ] ) @@ -529,7 +553,10 @@ def test_symmetry_across_easting_upward( [ 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, ) ] ) @@ -571,7 +598,7 @@ 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 ) ] ) @@ -579,7 +606,7 @@ def test_symmetry_across_northing_upward( [ 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 ) ] ) @@ -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 @@ -639,7 +666,7 @@ 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)) @@ -647,19 +674,19 @@ def test_magnetic_field( 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) @@ -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 @@ -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 @@ -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 diff --git a/test/test_point_gravity.py b/test/test_point_gravity.py index b2a08374..43a78e76 100644 --- a/test/test_point_gravity.py +++ b/test/test_point_gravity.py @@ -128,7 +128,7 @@ def test_symmetry_on_sphere(self, sample_point_source, sample_mass): # Evaluate gravity_pot on every observation point potential = tuple( gravity_pot(*coords, *sample_point_source, sample_mass) - for coords in zip(*observation_points) + for coords in zip(*observation_points, strict=False) ) # Check if all values are equal npt.assert_allclose(potential[0], potential) @@ -225,7 +225,7 @@ def test_zero_in_northing_upward( g_e = np.array( [ gravity_e(*coords, *sample_point_source, sample_mass) - for coords in zip(*coords_northing_upward_plane) + for coords in zip(*coords_northing_upward_plane, strict=False) ] ) assert (g_e <= 1e-30).all() @@ -238,13 +238,13 @@ def test_mirror_symmetry(self, sample_point_source, mirrored_points, sample_mass g_e_1 = np.array( [ gravity_e(*coords, *sample_point_source, sample_mass) - for coords in zip(*coords_1) + for coords in zip(*coords_1, strict=False) ] ) g_e_2 = np.array( [ gravity_e(*coords, *sample_point_source, sample_mass) - for coords in zip(*coords_2) + for coords in zip(*coords_2, strict=False) ] ) npt.assert_allclose(g_e_1, -g_e_2) @@ -302,7 +302,7 @@ def test_zero_in_easting_upward( g_n = np.array( [ gravity_n(*coords, *sample_point_source, sample_mass) - for coords in zip(*coords_easting_upward_plane) + for coords in zip(*coords_easting_upward_plane, strict=False) ] ) assert (g_n <= 1e-30).all() @@ -315,13 +315,13 @@ def test_mirror_symmetry(self, sample_point_source, mirrored_points, sample_mass g_n_1 = np.array( [ gravity_n(*coords, *sample_point_source, sample_mass) - for coords in zip(*coords_1) + for coords in zip(*coords_1, strict=False) ] ) g_n_2 = np.array( [ gravity_n(*coords, *sample_point_source, sample_mass) - for coords in zip(*coords_2) + for coords in zip(*coords_2, strict=False) ] ) npt.assert_allclose(g_n_1, -g_n_2) @@ -379,7 +379,7 @@ def test_zero_in_easting_northing( g_u = np.array( [ gravity_u(*coords, *sample_point_source, sample_mass) - for coords in zip(*coords_easting_northing_plane) + for coords in zip(*coords_easting_northing_plane, strict=False) ] ) assert (g_u <= 1e-30).all() @@ -392,13 +392,13 @@ def test_mirror_symmetry(self, sample_point_source, mirrored_points, sample_mass g_u_1 = np.array( [ gravity_u(*coords, *sample_point_source, sample_mass) - for coords in zip(*coords_1) + for coords in zip(*coords_1, strict=False) ] ) g_u_2 = np.array( [ gravity_u(*coords, *sample_point_source, sample_mass) - for coords in zip(*coords_2) + for coords in zip(*coords_2, strict=False) ] ) npt.assert_allclose(g_u_1, -g_u_2) @@ -749,7 +749,7 @@ def compute_kernel_points(coordinates, source, kernel): result = np.array( [ kernel(e, n, u, *source, distance_cartesian(e, n, u, *source)) - for e, n, u in zip(*coordinates) + for e, n, u in zip(*coordinates, strict=False) ] ) return result @@ -854,19 +854,19 @@ def test_laplacian( g_ee = np.array( [ gravity_ee(e, n, u, *sample_point_source, sample_mass) - for e, n, u in zip(*sample_observation_points) + for e, n, u in zip(*sample_observation_points, strict=False) ] ) g_nn = np.array( [ gravity_nn(e, n, u, *sample_point_source, sample_mass) - for e, n, u in zip(*sample_observation_points) + for e, n, u in zip(*sample_observation_points, strict=False) ] ) g_uu = np.array( [ gravity_uu(e, n, u, *sample_point_source, sample_mass) - for e, n, u in zip(*sample_observation_points) + for e, n, u in zip(*sample_observation_points, strict=False) ] ) # Set an atol to avoid getting failures when comparing values close to diff --git a/test/test_prism_gravity.py b/test/test_prism_gravity.py index 1df30eb0..a8cbd2e7 100644 --- a/test/test_prism_gravity.py +++ b/test/test_prism_gravity.py @@ -419,7 +419,7 @@ def test_northing_upward_plane( # Compute gravity_e on every observation point of northing-upward plane g_e = [ gravity_e(e, n, u, *sample_prism, sample_density) - for e, n, u in zip(*coords_in_northing_upward_plane) + for e, n, u in zip(*coords_in_northing_upward_plane, strict=False) ] # Compute gravity_e on a point slightly shifted from the prism center # (it will be our control for non-zero field) @@ -440,13 +440,13 @@ def test_mirrored_points(self, mirrored_points, sample_prism, sample_density): g_e_west = np.array( [ gravity_e(e, n, u, *sample_prism, sample_density) - for e, n, u in zip(*west) + for e, n, u in zip(*west, strict=False) ] ) g_e_east = np.array( [ gravity_e(e, n, u, *sample_prism, sample_density) - for e, n, u in zip(*east) + for e, n, u in zip(*east, strict=False) ] ) npt.assert_allclose(g_e_west, -g_e_east) @@ -572,7 +572,7 @@ def test_northing_upward_plane( # Compute gravity_n on every observation point of easting-upward plane g_n = [ gravity_n(e, n, u, *sample_prism, sample_density) - for e, n, u in zip(*coords_in_easting_upward_plane) + for e, n, u in zip(*coords_in_easting_upward_plane, strict=False) ] # Compute gravity_n on a point slightly shifted from the prism center # (it will be our control for non-zero field) @@ -593,13 +593,13 @@ def test_mirrored_points(self, mirrored_points, sample_prism, sample_density): g_n_south = np.array( [ gravity_n(e, n, u, *sample_prism, sample_density) - for e, n, u in zip(*south) + for e, n, u in zip(*south, strict=False) ] ) g_n_north = np.array( [ gravity_n(e, n, u, *sample_prism, sample_density) - for e, n, u in zip(*north) + for e, n, u in zip(*north, strict=False) ] ) npt.assert_allclose(g_n_south, -g_n_north) @@ -726,7 +726,7 @@ def test_easting_northing_plane( # plane g_u = [ gravity_u(e, n, u, *sample_prism, sample_density) - for e, n, u in zip(*coords_in_easting_northing_plane) + for e, n, u in zip(*coords_in_easting_northing_plane, strict=False) ] # Compute gravity_u on a point slightly shifted from the prism center # (it will be our control for non-zero field) @@ -747,11 +747,14 @@ def test_mirrored_points(self, mirrored_points, sample_prism, sample_density): g_u_bottom = np.array( [ gravity_u(e, n, u, *sample_prism, sample_density) - for e, n, u in zip(*bottom) + for e, n, u in zip(*bottom, strict=False) ] ) g_u_top = np.array( - [gravity_u(e, n, u, *sample_prism, sample_density) for e, n, u in zip(*top)] + [ + gravity_u(e, n, u, *sample_prism, sample_density) + for e, n, u in zip(*top, strict=False) + ] ) npt.assert_allclose(g_u_bottom, -g_u_top) @@ -1088,19 +1091,19 @@ def test_laplacian( g_ee = np.array( [ gravity_ee(e, n, u, *sample_prism, sample_density) - for e, n, u in zip(*sample_observation_points) + for e, n, u in zip(*sample_observation_points, strict=False) ] ) g_nn = np.array( [ gravity_nn(e, n, u, *sample_prism, sample_density) - for e, n, u in zip(*sample_observation_points) + for e, n, u in zip(*sample_observation_points, strict=False) ] ) g_uu = np.array( [ gravity_uu(e, n, u, *sample_prism, sample_density) - for e, n, u in zip(*sample_observation_points) + for e, n, u in zip(*sample_observation_points, strict=False) ] ) if left_component == "g_ee": @@ -1385,7 +1388,8 @@ def test_on_vertices(self, prism_boundaries, function): a.ravel() for a in np.meshgrid([west, east], [south, north], [bottom, top]) ) results = [ - function(e, n, u, *prism, density) for (e, n, u) in zip(*coordinates) + function(e, n, u, *prism, density) + for (e, n, u) in zip(*coordinates, strict=False) ] assert np.isnan(results).all() @@ -1406,7 +1410,7 @@ def test_gee_on_edges(self, prism_boundaries): ) # put points in the center of the edge results = [ gravity_ee(e, n, u, *prism, density) - for (e, n, u) in zip(easting, northing, upward) + for (e, n, u) in zip(easting, northing, upward, strict=False) ] assert np.isnan(results).all() # Define observation points on edges parallel to upward @@ -1418,7 +1422,7 @@ def test_gee_on_edges(self, prism_boundaries): ) # put points in the center of the edge results = [ gravity_ee(e, n, u, *prism, density) - for (e, n, u) in zip(easting, northing, upward) + for (e, n, u) in zip(easting, northing, upward, strict=False) ] assert np.isnan(results).all() @@ -1439,7 +1443,7 @@ def test_gnn_on_edges(self, prism_boundaries): ) # put points in the center of the edge results = [ gravity_nn(e, n, u, *prism, density) - for (e, n, u) in zip(easting, northing, upward) + for (e, n, u) in zip(easting, northing, upward, strict=False) ] assert np.isnan(results).all() # Define observation points on edges parallel to upward @@ -1451,7 +1455,7 @@ def test_gnn_on_edges(self, prism_boundaries): ) # put points in the center of the edge results = [ gravity_nn(e, n, u, *prism, density) - for (e, n, u) in zip(easting, northing, upward) + for (e, n, u) in zip(easting, northing, upward, strict=False) ] assert np.isnan(results).all() @@ -1472,7 +1476,7 @@ def test_guu_on_edges(self, prism_boundaries): ) # put points in the center of the edge results = [ gravity_uu(e, n, u, *prism, density) - for (e, n, u) in zip(easting, northing, upward) + for (e, n, u) in zip(easting, northing, upward, strict=False) ] assert np.isnan(results).all() # Define observation points on edges parallel to northing @@ -1484,7 +1488,7 @@ def test_guu_on_edges(self, prism_boundaries): ) # put points in the center of the edge results = [ gravity_ee(e, n, u, *prism, density) - for (e, n, u) in zip(easting, northing, upward) + for (e, n, u) in zip(easting, northing, upward, strict=False) ] assert np.isnan(results).all() @@ -1505,11 +1509,11 @@ def test_gee_faces_symmetry(self, prism_boundaries): west_face = np.full_like(northing, west) result_east_face = [ gravity_ee(e, n, u, *prism, density) - for (e, n, u) in zip(east_face, northing, upward) + for (e, n, u) in zip(east_face, northing, upward, strict=False) ] result_west_face = [ gravity_ee(e, n, u, *prism, density) - for (e, n, u) in zip(west_face, northing, upward) + for (e, n, u) in zip(west_face, northing, upward, strict=False) ] npt.assert_allclose(result_east_face, result_west_face) @@ -1581,11 +1585,11 @@ def test_gnn_faces_symmetry(self, prism_boundaries): north_face = np.full_like(easting, north) result_north_face = [ gravity_nn(e, n, u, *prism, density) - for (e, n, u) in zip(easting, north_face, upward) + for (e, n, u) in zip(easting, north_face, upward, strict=False) ] result_south_face = [ gravity_nn(e, n, u, *prism, density) - for (e, n, u) in zip(easting, south_face, upward) + for (e, n, u) in zip(easting, south_face, upward, strict=False) ] npt.assert_allclose(result_north_face, result_south_face) @@ -1606,11 +1610,11 @@ def test_guu_faces_symmetry(self, prism_boundaries): bottom_face = np.full_like(easting, bottom) result_top_face = [ gravity_uu(e, n, u, *prism, density) - for (e, n, u) in zip(easting, northing, top_face) + for (e, n, u) in zip(easting, northing, top_face, strict=False) ] result_bottom_face = [ gravity_uu(e, n, u, *prism, density) - for (e, n, u) in zip(easting, northing, bottom_face) + for (e, n, u) in zip(easting, northing, bottom_face, strict=False) ] npt.assert_allclose(result_top_face, result_bottom_face) @@ -1647,7 +1651,8 @@ def test_on_vertices(self, prism_boundaries, function): a.ravel() for a in np.meshgrid([west, east], [south, north], [bottom, top]) ) results = [ - function(e, n, u, *prism, density) for (e, n, u) in zip(*coordinates) + function(e, n, u, *prism, density) + for (e, n, u) in zip(*coordinates, strict=False) ] assert np.isnan(results).all() @@ -1668,7 +1673,7 @@ def test_gen_edges(self, prism_boundaries): ) # put points in the center of the edge results = [ gravity_en(e, n, u, *prism, density) - for (e, n, u) in zip(easting, northing, upward) + for (e, n, u) in zip(easting, northing, upward, strict=False) ] assert np.isnan(results).all() @@ -1689,7 +1694,7 @@ def test_geu_edges(self, prism_boundaries): ) # put points in the center of the edge results = [ gravity_eu(e, n, u, *prism, density) - for (e, n, u) in zip(easting, northing, upward) + for (e, n, u) in zip(easting, northing, upward, strict=False) ] assert np.isnan(results).all() @@ -1710,6 +1715,6 @@ def test_gnu_edges(self, prism_boundaries): ) # put points in the center of the edge results = [ gravity_nu(e, n, u, *prism, density) - for (e, n, u) in zip(easting, northing, upward) + for (e, n, u) in zip(easting, northing, upward, strict=False) ] assert np.isnan(results).all() diff --git a/test/test_prism_magnetic.py b/test/test_prism_magnetic.py index 3c7164fe..7fe3d823 100644 --- a/test/test_prism_magnetic.py +++ b/test/test_prism_magnetic.py @@ -126,7 +126,10 @@ def evaluate(forward_func, coordinates, prism, magnetization): """ coordinates = tuple(c.ravel() for c in coordinates) result = np.array( - [forward_func(e, n, u, *prism, *magnetization) for e, n, u in zip(*coordinates)] + [ + forward_func(e, n, u, *prism, *magnetization) + for e, n, u in zip(*coordinates, strict=False) + ] ) return result @@ -773,7 +776,7 @@ def test_on_vertices(self, sample_prism, forward_func): magnetization = np.array([1.0, 1.0, 1.0]) results = [ forward_func(e, n, u, *sample_prism, *magnetization) - for (e, n, u) in zip(easting, northing, upward) + for (e, n, u) in zip(easting, northing, upward, strict=False) ] assert np.isnan(results).all() @@ -789,7 +792,7 @@ def test_on_edges(self, sample_prism, direction, forward_func): magnetization = np.array([1.0, 1.0, 1.0]) results = [ forward_func(e, n, u, *sample_prism, *magnetization) - for (e, n, u) in zip(easting, northing, upward) + for (e, n, u) in zip(easting, northing, upward, strict=False) ] assert np.isnan(results).all() @@ -802,7 +805,7 @@ def test_on_interior_points(self, sample_prism, forward_func): magnetization = np.array([1.0, 1.0, 1.0]) results = [ forward_func(e, n, u, *sample_prism, *magnetization) - for (e, n, u) in zip(easting, northing, upward) + for (e, n, u) in zip(easting, northing, upward, strict=False) ] assert np.isnan(results).all() @@ -825,12 +828,12 @@ def test_symmetry_on_faces(self, sample_prism, direction, forward_func): index = component_mapping[direction] results = [ forward_func(e, n, u, *sample_prism, *magnetization)[index] - for (e, n, u) in zip(easting, northing, upward) + for (e, n, u) in zip(easting, northing, upward, strict=False) ] else: results = [ forward_func(e, n, u, *sample_prism, *magnetization) - for (e, n, u) in zip(easting, northing, upward) + for (e, n, u) in zip(easting, northing, upward, strict=False) ] npt.assert_allclose(results, results[0]) @@ -858,7 +861,7 @@ def test_gradiometry_symmetry_on_faces(self, sample_prism, direction, forward_fu magnetization = np.array([1.0, 1.0, 1.0]) results = [ forward_func(e, n, u, *sample_prism, *magnetization) - for (e, n, u) in zip(easting, northing, upward) + for (e, n, u) in zip(easting, northing, upward, strict=False) ] npt.assert_allclose(-results[0], results[1:], atol=1e-23)