From aa8d8e069311e7412db537a7f563e226b2dd8ffa Mon Sep 17 00:00:00 2001 From: Yuchen Ethan Xiao Date: Sat, 8 Feb 2025 11:05:41 -0500 Subject: [PATCH 1/3] fix: use new `parsers` api --- news/new_parser_api.rst | 23 +++++++++++++++++++++++ src/diffpy/pdfmorph/tools.py | 11 ++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 news/new_parser_api.rst diff --git a/news/new_parser_api.rst b/news/new_parser_api.rst new file mode 100644 index 00000000..6ea08788 --- /dev/null +++ b/news/new_parser_api.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* change the way importing modules in `diffpy.utils.parsers` + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/src/diffpy/pdfmorph/tools.py b/src/diffpy/pdfmorph/tools.py index e1023d96..5f4239a7 100644 --- a/src/diffpy/pdfmorph/tools.py +++ b/src/diffpy/pdfmorph/tools.py @@ -20,7 +20,8 @@ import numpy -import diffpy.utils.parsers as parsers +from diffpy.utils.parsers.loaddata import loadData +from diffpy.utils.parsers.serialization import deserialize_data def estimateScale(y_morph_in, y_target_in): @@ -117,7 +118,7 @@ def readPDF(fname): Arrays read from data. """ - rv = parsers.loaddata.loadData(fname, unpack=True) + rv = loadData(fname, unpack=True) if len(rv) >= 2: return rv[:2] return (None, None) @@ -145,7 +146,7 @@ def deserialize(serial_file): dict Data read from serial file. """ - return parsers.serialization.deserialize_data(serial_file) + return deserialize_data(serial_file) def case_insensitive_dictionary_search(key: str, dictionary: dict): @@ -199,11 +200,11 @@ def field_sort(filepaths: list, field, reverse=False, serfile=None, get_field_va files_field_values = [] if serfile is None: for path in filepaths: - fhd = parsers.loaddata.loadData(path, headers=True) + fhd = loadData(path, headers=True) files_field_values.append([path, case_insensitive_dictionary_search(field, fhd)]) else: # deserialize the serial file - des_dict = parsers.serialization.deserialize_data(serfile) + des_dict = deserialize_data(serfile) # get names of each file to search the serial file import pathlib From f2566310d8a55e64c21012d89d66b3a51baa59de Mon Sep 17 00:00:00 2001 From: Yuchen Ethan Xiao Date: Sat, 8 Feb 2025 13:15:10 -0500 Subject: [PATCH 2/3] docs: update news --- news/new_parser_api.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/new_parser_api.rst b/news/new_parser_api.rst index 6ea08788..ba0e8dfa 100644 --- a/news/new_parser_api.rst +++ b/news/new_parser_api.rst @@ -4,7 +4,7 @@ **Changed:** -* change the way importing modules in `diffpy.utils.parsers` +* import `loadData` and `deserialize_data` directly to integrate with `diffpy.utils(3.6.0)` **Deprecated:** From bb67d96e9e73d3a7d04020d575f002c79117085c Mon Sep 17 00:00:00 2001 From: Yuchen Ethan Xiao Date: Sat, 8 Feb 2025 13:26:01 -0500 Subject: [PATCH 3/3] docs: add `fix` news --- news/new_parser_api.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/news/new_parser_api.rst b/news/new_parser_api.rst index ba0e8dfa..cd9139b3 100644 --- a/news/new_parser_api.rst +++ b/news/new_parser_api.rst @@ -4,7 +4,7 @@ **Changed:** -* import `loadData` and `deserialize_data` directly to integrate with `diffpy.utils(3.6.0)` +* **Deprecated:** @@ -16,7 +16,7 @@ **Fixed:** -* +* import `loadData` and `deserialize_data` directly to integrate with `diffpy.utils(3.6.0)` **Security:**