Skip to content

Commit

Permalink
Merge pull request diffpy#215 from bobleesj/mv-input-scattering-quan
Browse files Browse the repository at this point in the history
Rename `input_scattering_quantity` to `input_data` in `DiffractionObject` init
  • Loading branch information
sbillinge authored Dec 12, 2024
2 parents fce1a32 + f311988 commit 5f67f6c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
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

0 comments on commit 5f67f6c

Please sign in to comment.