From 919c60bab6c0c2d7b77503db6edbebd423230fe5 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Thu, 12 Dec 2024 12:48:11 -0500 Subject: [PATCH 1/2] ename to in init --- news/mv-input-scattering-quan.rst | 23 +++++++++++++++++++++++ src/diffpy/utils/diffraction_objects.py | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 news/mv-input-scattering-quan.rst diff --git a/news/mv-input-scattering-quan.rst b/news/mv-input-scattering-quan.rst new file mode 100644 index 00000000..25e8aac9 --- /dev/null +++ b/news/mv-input-scattering-quan.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* Rename `input_scattering_quantity` to `input_data` in `DiffractionObject` init + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/src/diffpy/utils/diffraction_objects.py b/src/diffpy/utils/diffraction_objects.py index ab39e53b..fe853d02 100644 --- a/src/diffpy/utils/diffraction_objects.py +++ b/src/diffpy/utils/diffraction_objects.py @@ -53,7 +53,7 @@ def __init__( if yarray is None: yarray = np.empty(0) - self.insert_scattering_quantity(xarray, yarray, xtype) + self.input_data(xarray, yarray, xtype) def __eq__(self, other): if not isinstance(other, DiffractionObject): @@ -317,7 +317,7 @@ def _set_xarrays(self, xarray, xtype): self.dmin = np.nanmin(self._all_arrays[:, 3], initial=np.inf) self.dmax = np.nanmax(self._all_arrays[:, 3], initial=0.0) - def insert_scattering_quantity( + def input_data( self, xarray, yarray, From f311988add3866b2e18c2a2185fde6d2a31f7811 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Thu, 12 Dec 2024 12:56:26 -0500 Subject: [PATCH 2/2] Fix insert_scattering_quantity to input data in all other files globally --- src/diffpy/utils/diffraction_objects.py | 4 ++-- tests/test_diffraction_objects.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/diffpy/utils/diffraction_objects.py b/src/diffpy/utils/diffraction_objects.py index fe853d02..59aac37b 100644 --- a/src/diffpy/utils/diffraction_objects.py +++ b/src/diffpy/utils/diffraction_objects.py @@ -29,7 +29,7 @@ def _xtype_wmsg(xtype): def _setter_wmsg(attribute): return ( f"Direct modification of attribute '{attribute}' is not allowed. " - f"Please use 'insert_scattering_quantity' to modify '{attribute}'.", + f"Please use 'input_data' to modify '{attribute}'.", ) @@ -351,7 +351,7 @@ def input_data( if len(xarray) != len(yarray): raise ValueError( "'xarray' and 'yarray' must have the same length. " - "Please re-initialize 'DiffractionObject' or re-run the method 'insert_scattering_quantity' " + "Please re-initialize 'DiffractionObject' or re-run the method 'input_data' " "with 'xarray' and 'yarray' of identical length." ) diff --git a/tests/test_diffraction_objects.py b/tests/test_diffraction_objects.py index f93190ae..328bb512 100644 --- a/tests/test_diffraction_objects.py +++ b/tests/test_diffraction_objects.py @@ -364,7 +364,7 @@ def test_all_array_setter(): with pytest.raises( AttributeError, match="Direct modification of attribute 'all_arrays' is not allowed. " - "Please use 'insert_scattering_quantity' to modify 'all_arrays'.", + "Please use 'input_data' to modify 'all_arrays'.", ): actual_do.all_arrays = np.empty((4, 4)) @@ -373,7 +373,7 @@ def test_xarray_yarray_length_mismatch(): with pytest.raises( ValueError, match="'xarray' and 'yarray' must have the same length. " - "Please re-initialize 'DiffractionObject' or re-run the method 'insert_scattering_quantity' " + "Please re-initialize 'DiffractionObject' or re-run the method 'input_data' " "with 'xarray' and 'yarray' of identical length", ): DiffractionObject(xarray=np.array([1.0, 2.0]), yarray=np.array([0.0, 0.0, 0.0])) @@ -391,7 +391,7 @@ def test_input_xtype_setter(): with pytest.raises( AttributeError, match="Direct modification of attribute 'input_xtype' is not allowed. " - "Please use 'insert_scattering_quantity' to modify 'input_xtype'.", + "Please use 'input_data' to modify 'input_xtype'.", ): do.input_xtype = "q"