diff --git a/src/harmonica/_transformations.py b/src/harmonica/_transformations.py index 0e16cb6c5..6387a0da0 100644 --- a/src/harmonica/_transformations.py +++ b/src/harmonica/_transformations.py @@ -389,8 +389,8 @@ def reduction_to_pole( grid, inclination, declination, - magnetization_inclination=None, - magnetization_declination=None, + magnetization_inclination, + magnetization_declination, *, pad=True, pad_kwargs=None, @@ -412,16 +412,10 @@ def reduction_to_pole( The inclination of the inducing Geomagnetic field. declination : float in degrees The declination of the inducing Geomagnetic field. - magnetization_inclination : float in degrees or None - The inclination of the total magnetization of the anomaly source. If - None, the ``magnetization_inclination`` will be set equal to the - ``inclination``, neglecting remanent magnetization and self - demagnetization. Default None. + magnetization_inclination : float in degrees + The inclination of the total magnetization of the anomaly source. magnetization_declination : float in degrees - The declination of the total magnetization of the anomaly source. If - None, the ``magnetization_declination`` will be set equal to the - ``declination``, neglecting remanent magnetization and self - demagnetization. Default None. + The declination of the total magnetization of the anomaly source. pad : bool, optional If True, will add padding to the grid before taking the Fourier Transform and applying the filter and remove it after the inverse Fourier Transform. diff --git a/test/test_transformations.py b/test/test_transformations.py index 19209f6f3..0d7954b4d 100644 --- a/test/test_transformations.py +++ b/test/test_transformations.py @@ -553,6 +553,21 @@ def test_reduction_to_pole_dim_names(sample_potential): reduction_to_pole(renamed_dims_grid, 60, 45, 60, 45) +def test_reduction_to_pole_magnetization_required(sample_potential): + """ + The magnetization direction must be a required argument. + + Making it required forces users to be explicit about the induced-only + magnetization assumption (see #440 and #661). It used to default to None on + the public ``reduction_to_pole`` function, which crashed deep inside the + kernel after #661 removed the None handling. + """ + with pytest.raises(TypeError, match="magnetization_inclination"): + reduction_to_pole(sample_potential, 60, 45) + with pytest.raises(TypeError, match="magnetization_declination"): + reduction_to_pole(sample_potential, 60, 45, 60) + + class TestTotalGradientAmplitude: """ Test total_gradient_amplitude function.