From 0d6b1b8a3a88b5d3203e055be228b84349f68cc0 Mon Sep 17 00:00:00 2001 From: Alison Wu Date: Wed, 6 Nov 2024 19:08:32 -0500 Subject: [PATCH 1/6] moved resample out of parsers --- news/resample-relocation.rst | 23 ++++++++++++++++++++++ src/diffpy/utils/parsers/__init__.py | 8 -------- src/diffpy/utils/{parsers => }/resample.py | 0 tests/test_resample.py | 2 +- 4 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 news/resample-relocation.rst rename src/diffpy/utils/{parsers => }/resample.py (100%) diff --git a/news/resample-relocation.rst b/news/resample-relocation.rst new file mode 100644 index 00000000..f8ffaf7f --- /dev/null +++ b/news/resample-relocation.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* Moved resampler out of parsers, new path is diffpy.utils.resample + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/src/diffpy/utils/parsers/__init__.py b/src/diffpy/utils/parsers/__init__.py index a2104181..cd95dd63 100644 --- a/src/diffpy/utils/parsers/__init__.py +++ b/src/diffpy/utils/parsers/__init__.py @@ -16,12 +16,4 @@ """Various utilities related to data parsing and manipulation. """ -from .loaddata import loadData -from .resample import resample -from .serialization import deserialize_data, serialize_data - -# silence the pyflakes syntax checker -assert loadData or resample or True -assert serialize_data or deserialize_data or True - # End of file diff --git a/src/diffpy/utils/parsers/resample.py b/src/diffpy/utils/resample.py similarity index 100% rename from src/diffpy/utils/parsers/resample.py rename to src/diffpy/utils/resample.py diff --git a/tests/test_resample.py b/tests/test_resample.py index fa9c7e70..cdaee0ae 100644 --- a/tests/test_resample.py +++ b/tests/test_resample.py @@ -1,7 +1,7 @@ import numpy as np import pytest -from diffpy.utils.parsers.resample import wsinterp +from diffpy.utils.resample import wsinterp def test_wsinterp(): From 6a121ccfb351102f849691bc936ad54f263be144 Mon Sep 17 00:00:00 2001 From: Alison Wu Date: Wed, 6 Nov 2024 20:26:05 -0500 Subject: [PATCH 2/6] added back parsers __init__.py to be able to import the functions --- src/diffpy/utils/parsers/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/diffpy/utils/parsers/__init__.py b/src/diffpy/utils/parsers/__init__.py index cd95dd63..2f9b65a4 100644 --- a/src/diffpy/utils/parsers/__init__.py +++ b/src/diffpy/utils/parsers/__init__.py @@ -16,4 +16,11 @@ """Various utilities related to data parsing and manipulation. """ +from .loaddata import loadData +from .serialization import deserialize_data, serialize_data + +# silence the pyflakes syntax checker +assert loadData or True +assert serialize_data or deserialize_data or True + # End of file From 79a2f1e5d0729bc9d5d0317e0341f4bd7f6112c3 Mon Sep 17 00:00:00 2001 From: Alison Wu Date: Thu, 7 Nov 2024 13:04:33 -0500 Subject: [PATCH 3/6] renamed functions and files to PEP8 --- src/diffpy/utils/parsers/__init__.py | 7 ------- .../parsers/{loaddata.py => data_loader.py} | 2 +- .../{serialization.py => serializer.py} | 0 .../utils/{resample.py => resampler.py} | 0 .../scattering_objects/diffraction_objects.py | 16 +++++++-------- .../utils/wx/{gridutils.py => grid_utils.py} | 0 tests/test_diffraction_objects.py | 8 ++++---- tests/test_loaddata.py | 20 +++++++++---------- tests/test_resample.py | 2 +- tests/test_serialization.py | 19 +++++++++--------- 10 files changed, 34 insertions(+), 40 deletions(-) rename src/diffpy/utils/parsers/{loaddata.py => data_loader.py} (99%) rename src/diffpy/utils/parsers/{serialization.py => serializer.py} (100%) rename src/diffpy/utils/{resample.py => resampler.py} (100%) rename src/diffpy/utils/wx/{gridutils.py => grid_utils.py} (100%) diff --git a/src/diffpy/utils/parsers/__init__.py b/src/diffpy/utils/parsers/__init__.py index 2f9b65a4..cd95dd63 100644 --- a/src/diffpy/utils/parsers/__init__.py +++ b/src/diffpy/utils/parsers/__init__.py @@ -16,11 +16,4 @@ """Various utilities related to data parsing and manipulation. """ -from .loaddata import loadData -from .serialization import deserialize_data, serialize_data - -# silence the pyflakes syntax checker -assert loadData or True -assert serialize_data or deserialize_data or True - # End of file diff --git a/src/diffpy/utils/parsers/loaddata.py b/src/diffpy/utils/parsers/data_loader.py similarity index 99% rename from src/diffpy/utils/parsers/loaddata.py rename to src/diffpy/utils/parsers/data_loader.py index 18375d90..f17b8ef9 100644 --- a/src/diffpy/utils/parsers/loaddata.py +++ b/src/diffpy/utils/parsers/data_loader.py @@ -16,7 +16,7 @@ import numpy -def loadData(filename, minrows=10, headers=False, hdel="=", hignore=None, **kwargs): +def load_data(filename, minrows=10, headers=False, hdel="=", hignore=None, **kwargs): """Find and load data from a text file. The data block is identified as the first matrix block of at least minrows rows and constant number of columns. diff --git a/src/diffpy/utils/parsers/serialization.py b/src/diffpy/utils/parsers/serializer.py similarity index 100% rename from src/diffpy/utils/parsers/serialization.py rename to src/diffpy/utils/parsers/serializer.py diff --git a/src/diffpy/utils/resample.py b/src/diffpy/utils/resampler.py similarity index 100% rename from src/diffpy/utils/resample.py rename to src/diffpy/utils/resampler.py diff --git a/src/diffpy/utils/scattering_objects/diffraction_objects.py b/src/diffpy/utils/scattering_objects/diffraction_objects.py index 94d2831a..bb1179e4 100644 --- a/src/diffpy/utils/scattering_objects/diffraction_objects.py +++ b/src/diffpy/utils/scattering_objects/diffraction_objects.py @@ -17,7 +17,7 @@ ) -class Diffraction_object: +class diffraction_object: def __init__(self, name="", wavelength=None): self.name = name self.wavelength = wavelength @@ -29,7 +29,7 @@ def __init__(self, name="", wavelength=None): self.metadata = {} def __eq__(self, other): - if not isinstance(other, Diffraction_object): + if not isinstance(other, diffraction_object): return NotImplemented self_attributes = [key for key in self.__dict__ if not key.startswith("_")] other_attributes = [key for key in other.__dict__ if not key.startswith("_")] @@ -59,7 +59,7 @@ def __add__(self, other): if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray): summed.on_tth[1] = self.on_tth[1] + other summed.on_q[1] = self.on_q[1] + other - elif not isinstance(other, Diffraction_object): + elif not isinstance(other, diffraction_object): raise TypeError("I only know how to sum two Diffraction_object objects") elif self.on_tth[0].all() != other.on_tth[0].all(): raise RuntimeError(x_grid_emsg) @@ -73,7 +73,7 @@ def __radd__(self, other): if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray): summed.on_tth[1] = self.on_tth[1] + other summed.on_q[1] = self.on_q[1] + other - elif not isinstance(other, Diffraction_object): + elif not isinstance(other, diffraction_object): raise TypeError("I only know how to sum two Scattering_object objects") elif self.on_tth[0].all() != other.on_tth[0].all(): raise RuntimeError(x_grid_emsg) @@ -87,7 +87,7 @@ def __sub__(self, other): if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray): subtracted.on_tth[1] = self.on_tth[1] - other subtracted.on_q[1] = self.on_q[1] - other - elif not isinstance(other, Diffraction_object): + elif not isinstance(other, diffraction_object): raise TypeError("I only know how to subtract two Scattering_object objects") elif self.on_tth[0].all() != other.on_tth[0].all(): raise RuntimeError(x_grid_emsg) @@ -101,7 +101,7 @@ def __rsub__(self, other): if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray): subtracted.on_tth[1] = other - self.on_tth[1] subtracted.on_q[1] = other - self.on_q[1] - elif not isinstance(other, Diffraction_object): + elif not isinstance(other, diffraction_object): raise TypeError("I only know how to subtract two Scattering_object objects") elif self.on_tth[0].all() != other.on_tth[0].all(): raise RuntimeError(x_grid_emsg) @@ -115,7 +115,7 @@ def __mul__(self, other): if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray): multiplied.on_tth[1] = other * self.on_tth[1] multiplied.on_q[1] = other * self.on_q[1] - elif not isinstance(other, Diffraction_object): + elif not isinstance(other, diffraction_object): raise TypeError("I only know how to multiply two Scattering_object objects") elif self.on_tth[0].all() != other.on_tth[0].all(): raise RuntimeError(x_grid_emsg) @@ -141,7 +141,7 @@ def __truediv__(self, other): if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray): divided.on_tth[1] = other / self.on_tth[1] divided.on_q[1] = other / self.on_q[1] - elif not isinstance(other, Diffraction_object): + elif not isinstance(other, diffraction_object): raise TypeError("I only know how to multiply two Scattering_object objects") elif self.on_tth[0].all() != other.on_tth[0].all(): raise RuntimeError(x_grid_emsg) diff --git a/src/diffpy/utils/wx/gridutils.py b/src/diffpy/utils/wx/grid_utils.py similarity index 100% rename from src/diffpy/utils/wx/gridutils.py rename to src/diffpy/utils/wx/grid_utils.py diff --git a/tests/test_diffraction_objects.py b/tests/test_diffraction_objects.py index a155b95e..e08daac1 100644 --- a/tests/test_diffraction_objects.py +++ b/tests/test_diffraction_objects.py @@ -4,7 +4,7 @@ import pytest from freezegun import freeze_time -from diffpy.utils.scattering_objects.diffraction_objects import Diffraction_object +from diffpy.utils.scattering_objects.diffraction_objects import diffraction_object params = [ ( # Default @@ -222,8 +222,8 @@ @pytest.mark.parametrize("inputs1, inputs2, expected", params) def test_diffraction_objects_equality(inputs1, inputs2, expected): - diffraction_object1 = Diffraction_object() - diffraction_object2 = Diffraction_object() + diffraction_object1 = diffraction_object() + diffraction_object2 = diffraction_object() diffraction_object1_attributes = [key for key in diffraction_object1.__dict__ if not key.startswith("_")] for i, attribute in enumerate(diffraction_object1_attributes): setattr(diffraction_object1, attribute, inputs1[i]) @@ -235,7 +235,7 @@ def test_dump(tmp_path, mocker): x, y = np.linspace(0, 5, 6), np.linspace(0, 5, 6) directory = Path(tmp_path) file = directory / "testfile" - test = Diffraction_object() + test = diffraction_object() test.wavelength = 1.54 test.name = "test" test.scat_quantity = "x-ray" diff --git a/tests/test_loaddata.py b/tests/test_loaddata.py index 2ca2fa07..6c4c3534 100644 --- a/tests/test_loaddata.py +++ b/tests/test_loaddata.py @@ -8,7 +8,7 @@ import numpy import pytest -from diffpy.utils.parsers import loadData +from diffpy.utils.parsers.data_loader import load_data ############################################################################## @@ -21,17 +21,17 @@ def test_loadData_default(self): """check loadData() with default options""" loaddata01 = self.datafile("loaddata01.txt") d2c = numpy.array([[3, 31], [4, 32], [5, 33]]) - self.assertRaises(IOError, loadData, "doesnotexist") + self.assertRaises(IOError, load_data, "doesnotexist") # the default minrows=10 makes it read from the third line - d = loadData(loaddata01) + d = load_data(loaddata01) self.assertTrue(numpy.array_equal(d2c, d)) # the usecols=(0, 1) would make it read from the third line - d = loadData(loaddata01, minrows=1, usecols=(0, 1)) + d = load_data(loaddata01, minrows=1, usecols=(0, 1)) self.assertTrue(numpy.array_equal(d2c, d)) # check the effect of usecols effect - d = loadData(loaddata01, usecols=(0,)) + d = load_data(loaddata01, usecols=(0,)) self.assertTrue(numpy.array_equal(d2c[:, 0], d)) - d = loadData(loaddata01, usecols=(1,)) + d = load_data(loaddata01, usecols=(1,)) self.assertTrue(numpy.array_equal(d2c[:, 1], d)) return @@ -39,11 +39,11 @@ def test_loadData_1column(self): """check loading of one-column data.""" loaddata01 = self.datafile("loaddata01.txt") d1c = numpy.arange(1, 6) - d = loadData(loaddata01, usecols=[0], minrows=1) + d = load_data(loaddata01, usecols=[0], minrows=1) self.assertTrue(numpy.array_equal(d1c, d)) - d = loadData(loaddata01, usecols=[0], minrows=2) + d = load_data(loaddata01, usecols=[0], minrows=2) self.assertTrue(numpy.array_equal(d1c, d)) - d = loadData(loaddata01, usecols=[0], minrows=3) + d = load_data(loaddata01, usecols=[0], minrows=3) self.assertFalse(numpy.array_equal(d1c, d)) return @@ -52,7 +52,7 @@ def test_loadData_headers(self): loaddatawithheaders = self.datafile("loaddatawithheaders.txt") hignore = ["# ", "// ", "["] # ignore lines beginning with these strings delimiter = ": " # what our data should be separated by - hdata = loadData(loaddatawithheaders, headers=True, hdel=delimiter, hignore=hignore) + hdata = load_data(loaddatawithheaders, headers=True, hdel=delimiter, hignore=hignore) # only fourteen lines of data are formatted properly assert len(hdata) == 14 # check the following are floats diff --git a/tests/test_resample.py b/tests/test_resample.py index cdaee0ae..deddcca2 100644 --- a/tests/test_resample.py +++ b/tests/test_resample.py @@ -1,7 +1,7 @@ import numpy as np import pytest -from diffpy.utils.resample import wsinterp +from diffpy.utils.resampler import wsinterp def test_wsinterp(): diff --git a/tests/test_serialization.py b/tests/test_serialization.py index 51921e01..1d664643 100644 --- a/tests/test_serialization.py +++ b/tests/test_serialization.py @@ -3,7 +3,8 @@ import numpy import pytest -from diffpy.utils.parsers import deserialize_data, loadData, serialize_data +from diffpy.utils.parsers.serializer import deserialize_data, serialize_data +from diffpy.utils.parsers.data_loader import load_data from diffpy.utils.parsers.custom_exceptions import ImproperSizeError, UnsupportedTypeError tests_dir = os.path.dirname(os.path.abspath(locals().get("__file__", "file.py"))) @@ -20,8 +21,8 @@ def test_load_multiple(tmp_path, datafile): for hfname in tlm_list: # gather data using loadData headerfile = os.path.normpath(os.path.join(tests_dir, "testdata", "dbload", hfname)) - hdata = loadData(headerfile, headers=True) - data_table = loadData(headerfile) + hdata = load_data(headerfile, headers=True) + data_table = load_data(headerfile) # check path extraction generated_data = serialize_data(headerfile, hdata, data_table, dt_colnames=["r", "gr"], show_path=True) @@ -50,8 +51,8 @@ def test_exceptions(datafile): loadfile = datafile("loadfile.txt") warningfile = datafile("generatewarnings.txt") nodt = datafile("loaddatawithheaders.txt") - hdata = loadData(loadfile, headers=True) - data_table = loadData(loadfile) + hdata = load_data(loadfile, headers=True) + data_table = load_data(loadfile) # improper file types with pytest.raises(UnsupportedTypeError): @@ -87,15 +88,15 @@ def test_exceptions(datafile): assert numpy.allclose(r_extract[data_name]["r"], r_list) assert numpy.allclose(gr_extract[data_name]["gr"], gr_list) # no datatable - nodt_hdata = loadData(nodt, headers=True) - nodt_dt = loadData(nodt) + nodt_hdata = load_data(nodt, headers=True) + nodt_dt = load_data(nodt) no_dt = serialize_data(nodt, nodt_hdata, nodt_dt, show_path=False) nodt_data_name = list(no_dt.keys())[0] assert numpy.allclose(no_dt[nodt_data_name]["data table"], nodt_dt) # ensure user is warned when columns are overwritten - hdata = loadData(warningfile, headers=True) - data_table = loadData(warningfile) + hdata = load_data(warningfile, headers=True) + data_table = load_data(warningfile) with pytest.warns(RuntimeWarning) as record: serialize_data( warningfile, From 87a5b6de22fe03ffbfe20ed1a489bac3dc942880 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 18:05:11 +0000 Subject: [PATCH 4/6] [pre-commit.ci] auto fixes from pre-commit hooks --- tests/test_serialization.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_serialization.py b/tests/test_serialization.py index 1d664643..b8079aba 100644 --- a/tests/test_serialization.py +++ b/tests/test_serialization.py @@ -3,9 +3,9 @@ import numpy import pytest -from diffpy.utils.parsers.serializer import deserialize_data, serialize_data -from diffpy.utils.parsers.data_loader import load_data from diffpy.utils.parsers.custom_exceptions import ImproperSizeError, UnsupportedTypeError +from diffpy.utils.parsers.data_loader import load_data +from diffpy.utils.parsers.serializer import deserialize_data, serialize_data tests_dir = os.path.dirname(os.path.abspath(locals().get("__file__", "file.py"))) From 2c364fcbcc6c919f2cc6011fdcc826af3bdce92a Mon Sep 17 00:00:00 2001 From: Alison Wu Date: Thu, 7 Nov 2024 13:20:09 -0500 Subject: [PATCH 5/6] fixed diffraction_objects class name --- .../scattering_objects/diffraction_objects.py | 24 +++++++++---------- tests/test_diffraction_objects.py | 10 ++++---- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/diffpy/utils/scattering_objects/diffraction_objects.py b/src/diffpy/utils/scattering_objects/diffraction_objects.py index bb1179e4..cc707f6f 100644 --- a/src/diffpy/utils/scattering_objects/diffraction_objects.py +++ b/src/diffpy/utils/scattering_objects/diffraction_objects.py @@ -17,7 +17,7 @@ ) -class diffraction_object: +class DiffractionObject: def __init__(self, name="", wavelength=None): self.name = name self.wavelength = wavelength @@ -29,7 +29,7 @@ def __init__(self, name="", wavelength=None): self.metadata = {} def __eq__(self, other): - if not isinstance(other, diffraction_object): + if not isinstance(other, DiffractionObject): return NotImplemented self_attributes = [key for key in self.__dict__ if not key.startswith("_")] other_attributes = [key for key in other.__dict__ if not key.startswith("_")] @@ -59,8 +59,8 @@ def __add__(self, other): if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray): summed.on_tth[1] = self.on_tth[1] + other summed.on_q[1] = self.on_q[1] + other - elif not isinstance(other, diffraction_object): - raise TypeError("I only know how to sum two Diffraction_object objects") + elif not isinstance(other, DiffractionObject): + raise TypeError("I only know how to sum two DiffractionObject objects") elif self.on_tth[0].all() != other.on_tth[0].all(): raise RuntimeError(x_grid_emsg) else: @@ -73,7 +73,7 @@ def __radd__(self, other): if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray): summed.on_tth[1] = self.on_tth[1] + other summed.on_q[1] = self.on_q[1] + other - elif not isinstance(other, diffraction_object): + elif not isinstance(other, DiffractionObject): raise TypeError("I only know how to sum two Scattering_object objects") elif self.on_tth[0].all() != other.on_tth[0].all(): raise RuntimeError(x_grid_emsg) @@ -87,7 +87,7 @@ def __sub__(self, other): if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray): subtracted.on_tth[1] = self.on_tth[1] - other subtracted.on_q[1] = self.on_q[1] - other - elif not isinstance(other, diffraction_object): + elif not isinstance(other, DiffractionObject): raise TypeError("I only know how to subtract two Scattering_object objects") elif self.on_tth[0].all() != other.on_tth[0].all(): raise RuntimeError(x_grid_emsg) @@ -101,7 +101,7 @@ def __rsub__(self, other): if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray): subtracted.on_tth[1] = other - self.on_tth[1] subtracted.on_q[1] = other - self.on_q[1] - elif not isinstance(other, diffraction_object): + elif not isinstance(other, DiffractionObject): raise TypeError("I only know how to subtract two Scattering_object objects") elif self.on_tth[0].all() != other.on_tth[0].all(): raise RuntimeError(x_grid_emsg) @@ -115,7 +115,7 @@ def __mul__(self, other): if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray): multiplied.on_tth[1] = other * self.on_tth[1] multiplied.on_q[1] = other * self.on_q[1] - elif not isinstance(other, diffraction_object): + elif not isinstance(other, DiffractionObject): raise TypeError("I only know how to multiply two Scattering_object objects") elif self.on_tth[0].all() != other.on_tth[0].all(): raise RuntimeError(x_grid_emsg) @@ -141,7 +141,7 @@ def __truediv__(self, other): if isinstance(other, int) or isinstance(other, float) or isinstance(other, np.ndarray): divided.on_tth[1] = other / self.on_tth[1] divided.on_q[1] = other / self.on_q[1] - elif not isinstance(other, diffraction_object): + elif not isinstance(other, DiffractionObject): raise TypeError("I only know how to multiply two Scattering_object objects") elif self.on_tth[0].all() != other.on_tth[0].all(): raise RuntimeError(x_grid_emsg) @@ -389,7 +389,7 @@ def scale_to(self, target_diff_object, xtype=None, xvalue=None): Parameters ---------- - target_diff_object: Diffraction_object + target_diff_object: DiffractionObject the diffractoin object you want to scale the current one on to xtype: string, optional. Default is Q 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): Returns ------- - the rescaled Diffraction_object as a new object + the rescaled DiffractionObject as a new object """ scaled = deepcopy(self) @@ -454,7 +454,7 @@ def dump(self, filepath, xtype=None): with open(filepath, "w") as f: f.write( - f"[Diffraction_object]\nname = {self.name}\nwavelength = {self.wavelength}\n" + f"[DiffractionObject]\nname = {self.name}\nwavelength = {self.wavelength}\n" f"scat_quantity = {self.scat_quantity}\n" ) for key, value in self.metadata.items(): diff --git a/tests/test_diffraction_objects.py b/tests/test_diffraction_objects.py index e08daac1..b2225db8 100644 --- a/tests/test_diffraction_objects.py +++ b/tests/test_diffraction_objects.py @@ -4,7 +4,7 @@ import pytest from freezegun import freeze_time -from diffpy.utils.scattering_objects.diffraction_objects import diffraction_object +from diffpy.utils.scattering_objects.diffraction_objects import DiffractionObject params = [ ( # Default @@ -222,8 +222,8 @@ @pytest.mark.parametrize("inputs1, inputs2, expected", params) def test_diffraction_objects_equality(inputs1, inputs2, expected): - diffraction_object1 = diffraction_object() - diffraction_object2 = diffraction_object() + diffraction_object1 = DiffractionObject() + diffraction_object2 = DiffractionObject() diffraction_object1_attributes = [key for key in diffraction_object1.__dict__ if not key.startswith("_")] for i, attribute in enumerate(diffraction_object1_attributes): setattr(diffraction_object1, attribute, inputs1[i]) @@ -235,7 +235,7 @@ def test_dump(tmp_path, mocker): x, y = np.linspace(0, 5, 6), np.linspace(0, 5, 6) directory = Path(tmp_path) file = directory / "testfile" - test = diffraction_object() + test = DiffractionObject() test.wavelength = 1.54 test.name = "test" test.scat_quantity = "x-ray" @@ -251,7 +251,7 @@ def test_dump(tmp_path, mocker): with open(file, "r") as f: actual = f.read() expected = ( - "[Diffraction_object]\nname = test\nwavelength = 1.54\nscat_quantity = x-ray\nthing1 = 1\n" + "[DiffractionObject]\nname = test\nwavelength = 1.54\nscat_quantity = x-ray\nthing1 = 1\n" "thing2 = thing2\npackage_info = {'package2': '3.4.5', 'diffpy.utils': '3.3.0'}\n" "creation_time = 2012-01-14 00:00:00\n\n" "#### start data\n0.000000000000000000e+00 0.000000000000000000e+00\n" From 5f285e02d777800f49377dad013101553f9d8e3c Mon Sep 17 00:00:00 2001 From: Alison Wu Date: Thu, 7 Nov 2024 15:40:20 -0500 Subject: [PATCH 6/6] updated news item --- news/resample-relocation.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/news/resample-relocation.rst b/news/resample-relocation.rst index f8ffaf7f..a7a39550 100644 --- a/news/resample-relocation.rst +++ b/news/resample-relocation.rst @@ -4,7 +4,7 @@ **Changed:** -* Moved resampler out of parsers, new path is diffpy.utils.resample +* Moved resampler out of parsers, new path is diffpy.utils.resampler **Deprecated:** @@ -12,11 +12,11 @@ **Removed:** -* +* Relative imports in parser's __init__.py **Fixed:** -* +* File and function names are now all in PEP8 format **Security:**