diff --git a/news/cf-names-match-srfit.rst b/news/cf-names-match-srfit.rst new file mode 100644 index 0000000..771acc3 --- /dev/null +++ b/news/cf-names-match-srfit.rst @@ -0,0 +1,23 @@ +**Added:** + +* No news added: The unreleased fix-cfs news item already covers the characteristic function changes and lists the srfit 3.4.0 names. + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/news/fix-cfs.rst b/news/fix-cfs.rst index 4c23e04..5e67f5e 100644 --- a/news/fix-cfs.rst +++ b/news/fix-cfs.rst @@ -4,7 +4,7 @@ **Changed:** -* Rename the parameters of the characteristic functions ``spherical_particle``, ``spheroidal_particle``, ``lognormal_spherical_distribution``, ``sheet_particle``, and ``spherical_shell`` to match ``diffpy.srfit.pdf.characteristicfunctions``. +* Rename the parameters of the characteristic functions ``spherical_particle``, ``spheroidal_particle``, ``lognormal_spherical_particle``, ``sheet_particle``, and ``shell_particle`` to match ``diffpy.srfit.pdf.characteristicfunctions``. * Issue a ``RuntimeWarning`` once per process when a characteristic function is given non-physical input and returns zero. **Deprecated:** diff --git a/src/diffpy/cmipdf/characteristicfunctions.py b/src/diffpy/cmipdf/characteristicfunctions.py index 90eab31..7b6a0b0 100644 --- a/src/diffpy/cmipdf/characteristicfunctions.py +++ b/src/diffpy/cmipdf/characteristicfunctions.py @@ -28,9 +28,9 @@ __all__ = [ "spherical_particle", "spheroidal_particle", - "lognormal_spherical_distribution", + "lognormal_spherical_particle", "sheet_particle", - "spherical_shell", + "shell_particle", ] import warnings @@ -245,7 +245,7 @@ def spheroidal_particle(r, equatorial_radius, polar_radius): return f -def lognormal_spherical_distribution( +def lognormal_spherical_particle( r, particle_diameter, particle_diameter_sigma ): """Compute the spherical nanoparticle characteristic function with @@ -298,13 +298,13 @@ def lognormal_spherical_distribution( """ if particle_diameter <= 0: _warn_non_physical( - "lognormal_spherical_distribution", + "lognormal_spherical_particle", "'particle_diameter' must be positive", ) return numpy.zeros(numpy.shape(r), dtype=float) if particle_diameter_sigma < 0: _warn_non_physical( - "lognormal_spherical_distribution", + "lognormal_spherical_particle", "'particle_diameter_sigma' must not be negative", ) return numpy.zeros(numpy.shape(r), dtype=float) @@ -323,7 +323,7 @@ def lognormal_spherical_distribution( mu = log(particle_diameter) - s * s / 2 if mu < 0: _warn_non_physical( - "lognormal_spherical_distribution", + "lognormal_spherical_particle", "'particle_diameter' is too small for 'particle_diameter_sigma'", ) return numpy.zeros(numpy.shape(r), dtype=float) @@ -394,7 +394,7 @@ def sheet_particle(r, sheet_thickness): return characteristic_function -def spherical_shell(r, radius, thickness): +def shell_particle(r, radius, thickness): """Compute the spherical shell characteristic function. The outer radius equals ``radius + thickness``. From Lei et al., @@ -423,10 +423,10 @@ def spherical_shell(r, radius, thickness): rather than an error and does not warn. """ if thickness <= 0: - _warn_non_physical("spherical_shell", "'thickness' must be positive") + _warn_non_physical("shell_particle", "'thickness' must be positive") return numpy.zeros(numpy.shape(r), dtype=float) if radius < 0: - _warn_non_physical("spherical_shell", "'radius' must not be negative") + _warn_non_physical("shell_particle", "'radius' must not be negative") return numpy.zeros(numpy.shape(r), dtype=float) d = 1.0 * thickness diff --git a/tests/test_characteristicfunctions.py b/tests/test_characteristicfunctions.py index c194194..897b505 100644 --- a/tests/test_characteristicfunctions.py +++ b/tests/test_characteristicfunctions.py @@ -131,13 +131,13 @@ def test_spheroidal_particle( ), ], ) -def test_lognormal_spherical_distribution( +def test_lognormal_spherical_particle( input_r, input_particle_diameter, input_particle_diameter_sigma, expected_characteristic_function, ): - actual_characteristic_function = cf.lognormal_spherical_distribution( + actual_characteristic_function = cf.lognormal_spherical_particle( input_r, input_particle_diameter, input_particle_diameter_sigma ) npt.assert_allclose( @@ -196,10 +196,10 @@ def test_sheet_particle( ), ], ) -def test_spherical_shell( +def test_shell_particle( input_r, input_radius, input_thickness, expected_characteristic_function ): - actual_characteristic_function = cf.spherical_shell( + actual_characteristic_function = cf.shell_particle( input_r, input_radius, input_thickness ) npt.assert_allclose( @@ -264,7 +264,7 @@ def test_spherical_shell( # Expected: zero everywhere, warning that the diameter must be # positive. ( - "lognormal_spherical_distribution", + "lognormal_spherical_particle", (numpy.array([1.0, 2.0]), 0.0, 1.0), "'particle_diameter' must be positive", ), @@ -274,7 +274,7 @@ def test_spherical_shell( # Expected: zero everywhere, warning that the width must not be # negative. ( - "lognormal_spherical_distribution", + "lognormal_spherical_particle", (numpy.array([1.0, 5.0, 10.0]), 10.0, -2.0), "'particle_diameter_sigma' must not be negative", ), @@ -284,7 +284,7 @@ def test_spherical_shell( # Expected: zero everywhere, warning that the diameter is too small # for the width. ( - "lognormal_spherical_distribution", + "lognormal_spherical_particle", (numpy.array([1.0, 5.0]), 2.0, 4.0), "'particle_diameter' is too small for 'particle_diameter_sigma'", ), @@ -310,7 +310,7 @@ def test_spherical_shell( # Expected: zero everywhere, warning that the thickness must be # positive. ( - "spherical_shell", + "shell_particle", (numpy.array([1.0, 5.0, 10.0]), 10.0, 0.0), "'thickness' must be positive", ), @@ -320,7 +320,7 @@ def test_spherical_shell( # Expected: zero everywhere, warning that the thickness must be # positive. ( - "spherical_shell", + "shell_particle", (numpy.array([1.0, 5.0, 10.0]), 10.0, -5.0), "'thickness' must be positive", ), @@ -328,7 +328,7 @@ def test_spherical_shell( # Expected: zero everywhere, warning that the radius must not be # negative. ( - "spherical_shell", + "shell_particle", (numpy.array([1.0, 5.0, 10.0]), -20.0, 5.0), "'radius' must not be negative", ), @@ -366,7 +366,7 @@ def test_non_physical_input_returns_zero_and_warns( # Expected: matches spherical_particle for the same diameter, with no # warning. ( - "lognormal_spherical_distribution", + "lognormal_spherical_particle", (numpy.array([1.0, 5.0, 10.0]), 10.0, 0.0), cf.spherical_particle(numpy.array([1.0, 5.0, 10.0]), 10.0), ), @@ -375,7 +375,7 @@ def test_non_physical_input_returns_zero_and_warns( # Expected: matches spherical_particle for twice the thickness, with # no warning. ( - "spherical_shell", + "shell_particle", (numpy.array([1.0, 5.0, 10.0]), 0.0, 5.0), cf.spherical_particle(numpy.array([1.0, 5.0, 10.0]), 10.0), ),