Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename input_scattering_quantity to input_data in DiffractionObject init #215

Merged
merged 2 commits into from
Dec 12, 2024
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
23 changes: 23 additions & 0 deletions news/mv-input-scattering-quan.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**Changed:**

* Rename `input_scattering_quantity` to `input_data` in `DiffractionObject` init

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
8 changes: 4 additions & 4 deletions src/diffpy/utils/diffraction_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}'.",
)


Expand All @@ -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):
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -351,7 +351,7 @@ def insert_scattering_quantity(
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."
)

Expand Down
6 changes: 3 additions & 3 deletions tests/test_diffraction_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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]))
Expand All @@ -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"

Expand Down
Loading