Skip to content

Commit 3c5a426

Browse files
remove error msg, change copy method
1 parent 8a3ebd5 commit 3c5a426

File tree

2 files changed

+1
-18
lines changed

2 files changed

+1
-18
lines changed

src/diffpy/utils/diffraction_objects.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,11 +388,9 @@ def scale_to(self, target_diff_object, q=None, tth=None, d=None, offset=0):
388388
-------
389389
the rescaled DiffractionObject as a new object
390390
"""
391-
scaled = deepcopy(self)
391+
scaled = self.copy()
392392
xtype = "q" if q is not None else "tth" if tth is not None else "d" if d is not None else "q"
393393
data, target = self.on_xtype(xtype), target_diff_object.on_xtype(xtype)
394-
if len(data[0]) == 0 or len(target[0]) == 0:
395-
raise ValueError("I cannot scale diffraction objects with empty arrays.")
396394

397395
xvalue = q if xtype == "q" else tth if xtype == "tth" else d
398396
if xvalue is None:

tests/test_diffraction_objects.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -331,21 +331,6 @@ def test_scale_to(inputs, expected):
331331
assert np.allclose(scaled_diff_object.on_xtype(expected[0])[1], expected[1])
332332

333333

334-
def test_scale_to_bad():
335-
# UC1: at least one of the y-arrays is empty
336-
orig_diff_object = DiffractionObject(
337-
xarray=np.array([]), yarray=np.array([]), xtype="tth", wavelength=2 * np.pi
338-
)
339-
target_diff_object = DiffractionObject(
340-
xarray=np.array([11, 14, 16, 20, 25, 30]),
341-
yarray=np.array([2, 3, 4, 5, 6, 7]),
342-
xtype="tth",
343-
wavelength=2 * np.pi,
344-
)
345-
with pytest.raises(ValueError, match="I cannot scale diffraction objects with empty arrays."):
346-
orig_diff_object.scale_to(target_diff_object, tth=20)
347-
348-
349334
params_index = [
350335
# UC1: exact match
351336
([4 * np.pi, np.array([30.005, 60]), np.array([1, 2]), "tth", "tth", 30.005], [0]),

0 commit comments

Comments
 (0)