Skip to content

Commit 2c364fc

Browse files
Alison WuAlison Wu
authored andcommitted
fixed diffraction_objects class name
1 parent 79a2f1e commit 2c364fc

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/diffpy/utils/scattering_objects/diffraction_objects.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
)
1818

1919

20-
class diffraction_object:
20+
class DiffractionObject:
2121
def __init__(self, name="", wavelength=None):
2222
self.name = name
2323
self.wavelength = wavelength
@@ -29,7 +29,7 @@ def __init__(self, name="", wavelength=None):
2929
self.metadata = {}
3030

3131
def __eq__(self, other):
32-
if not isinstance(other, diffraction_object):
32+
if not isinstance(other, DiffractionObject):
3333
return NotImplemented
3434
self_attributes = [key for key in self.__dict__ if not key.startswith("_")]
3535
other_attributes = [key for key in other.__dict__ if not key.startswith("_")]
@@ -59,8 +59,8 @@ def __add__(self, other):
5959
if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray):
6060
summed.on_tth[1] = self.on_tth[1] + other
6161
summed.on_q[1] = self.on_q[1] + other
62-
elif not isinstance(other, diffraction_object):
63-
raise TypeError("I only know how to sum two Diffraction_object objects")
62+
elif not isinstance(other, DiffractionObject):
63+
raise TypeError("I only know how to sum two DiffractionObject objects")
6464
elif self.on_tth[0].all() != other.on_tth[0].all():
6565
raise RuntimeError(x_grid_emsg)
6666
else:
@@ -73,7 +73,7 @@ def __radd__(self, other):
7373
if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray):
7474
summed.on_tth[1] = self.on_tth[1] + other
7575
summed.on_q[1] = self.on_q[1] + other
76-
elif not isinstance(other, diffraction_object):
76+
elif not isinstance(other, DiffractionObject):
7777
raise TypeError("I only know how to sum two Scattering_object objects")
7878
elif self.on_tth[0].all() != other.on_tth[0].all():
7979
raise RuntimeError(x_grid_emsg)
@@ -87,7 +87,7 @@ def __sub__(self, other):
8787
if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray):
8888
subtracted.on_tth[1] = self.on_tth[1] - other
8989
subtracted.on_q[1] = self.on_q[1] - other
90-
elif not isinstance(other, diffraction_object):
90+
elif not isinstance(other, DiffractionObject):
9191
raise TypeError("I only know how to subtract two Scattering_object objects")
9292
elif self.on_tth[0].all() != other.on_tth[0].all():
9393
raise RuntimeError(x_grid_emsg)
@@ -101,7 +101,7 @@ def __rsub__(self, other):
101101
if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray):
102102
subtracted.on_tth[1] = other - self.on_tth[1]
103103
subtracted.on_q[1] = other - self.on_q[1]
104-
elif not isinstance(other, diffraction_object):
104+
elif not isinstance(other, DiffractionObject):
105105
raise TypeError("I only know how to subtract two Scattering_object objects")
106106
elif self.on_tth[0].all() != other.on_tth[0].all():
107107
raise RuntimeError(x_grid_emsg)
@@ -115,7 +115,7 @@ def __mul__(self, other):
115115
if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray):
116116
multiplied.on_tth[1] = other * self.on_tth[1]
117117
multiplied.on_q[1] = other * self.on_q[1]
118-
elif not isinstance(other, diffraction_object):
118+
elif not isinstance(other, DiffractionObject):
119119
raise TypeError("I only know how to multiply two Scattering_object objects")
120120
elif self.on_tth[0].all() != other.on_tth[0].all():
121121
raise RuntimeError(x_grid_emsg)
@@ -141,7 +141,7 @@ def __truediv__(self, other):
141141
if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray):
142142
divided.on_tth[1] = other / self.on_tth[1]
143143
divided.on_q[1] = other / self.on_q[1]
144-
elif not isinstance(other, diffraction_object):
144+
elif not isinstance(other, DiffractionObject):
145145
raise TypeError("I only know how to multiply two Scattering_object objects")
146146
elif self.on_tth[0].all() != other.on_tth[0].all():
147147
raise RuntimeError(x_grid_emsg)
@@ -389,7 +389,7 @@ def scale_to(self, target_diff_object, xtype=None, xvalue=None):
389389
390390
Parameters
391391
----------
392-
target_diff_object: Diffraction_object
392+
target_diff_object: DiffractionObject
393393
the diffractoin object you want to scale the current one on to
394394
xtype: string, optional. Default is Q
395395
the xtype, from {XQUANTITIES}, that you will specify a point from to scale to
@@ -400,7 +400,7 @@ def scale_to(self, target_diff_object, xtype=None, xvalue=None):
400400
401401
Returns
402402
-------
403-
the rescaled Diffraction_object as a new object
403+
the rescaled DiffractionObject as a new object
404404
405405
"""
406406
scaled = deepcopy(self)
@@ -454,7 +454,7 @@ def dump(self, filepath, xtype=None):
454454

455455
with open(filepath, "w") as f:
456456
f.write(
457-
f"[Diffraction_object]\nname = {self.name}\nwavelength = {self.wavelength}\n"
457+
f"[DiffractionObject]\nname = {self.name}\nwavelength = {self.wavelength}\n"
458458
f"scat_quantity = {self.scat_quantity}\n"
459459
)
460460
for key, value in self.metadata.items():

tests/test_diffraction_objects.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pytest
55
from freezegun import freeze_time
66

7-
from diffpy.utils.scattering_objects.diffraction_objects import diffraction_object
7+
from diffpy.utils.scattering_objects.diffraction_objects import DiffractionObject
88

99
params = [
1010
( # Default
@@ -222,8 +222,8 @@
222222

223223
@pytest.mark.parametrize("inputs1, inputs2, expected", params)
224224
def test_diffraction_objects_equality(inputs1, inputs2, expected):
225-
diffraction_object1 = diffraction_object()
226-
diffraction_object2 = diffraction_object()
225+
diffraction_object1 = DiffractionObject()
226+
diffraction_object2 = DiffractionObject()
227227
diffraction_object1_attributes = [key for key in diffraction_object1.__dict__ if not key.startswith("_")]
228228
for i, attribute in enumerate(diffraction_object1_attributes):
229229
setattr(diffraction_object1, attribute, inputs1[i])
@@ -235,7 +235,7 @@ def test_dump(tmp_path, mocker):
235235
x, y = np.linspace(0, 5, 6), np.linspace(0, 5, 6)
236236
directory = Path(tmp_path)
237237
file = directory / "testfile"
238-
test = diffraction_object()
238+
test = DiffractionObject()
239239
test.wavelength = 1.54
240240
test.name = "test"
241241
test.scat_quantity = "x-ray"
@@ -251,7 +251,7 @@ def test_dump(tmp_path, mocker):
251251
with open(file, "r") as f:
252252
actual = f.read()
253253
expected = (
254-
"[Diffraction_object]\nname = test\nwavelength = 1.54\nscat_quantity = x-ray\nthing1 = 1\n"
254+
"[DiffractionObject]\nname = test\nwavelength = 1.54\nscat_quantity = x-ray\nthing1 = 1\n"
255255
"thing2 = thing2\npackage_info = {'package2': '3.4.5', 'diffpy.utils': '3.3.0'}\n"
256256
"creation_time = 2012-01-14 00:00:00\n\n"
257257
"#### start data\n0.000000000000000000e+00 0.000000000000000000e+00\n"

0 commit comments

Comments
 (0)