Skip to content

Commit fa1dd17

Browse files
authored
Merge pull request #162 from ycexiao/parser-api
fix: import `loadData` and `deserialize_data` directly to adopt new API from `diffpy.utils(3.6.0)`
2 parents ed8641e + bb67d96 commit fa1dd17

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

news/new_parser_api.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* <news item>
4+
5+
**Changed:**
6+
7+
* <news item>
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* import `loadData` and `deserialize_data` directly to integrate with `diffpy.utils(3.6.0)`
20+
21+
**Security:**
22+
23+
* <news item>

src/diffpy/pdfmorph/tools.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
import numpy
2222

23-
import diffpy.utils.parsers as parsers
23+
from diffpy.utils.parsers.loaddata import loadData
24+
from diffpy.utils.parsers.serialization import deserialize_data
2425

2526

2627
def estimateScale(y_morph_in, y_target_in):
@@ -117,7 +118,7 @@ def readPDF(fname):
117118
Arrays read from data.
118119
"""
119120

120-
rv = parsers.loaddata.loadData(fname, unpack=True)
121+
rv = loadData(fname, unpack=True)
121122
if len(rv) >= 2:
122123
return rv[:2]
123124
return (None, None)
@@ -145,7 +146,7 @@ def deserialize(serial_file):
145146
dict
146147
Data read from serial file.
147148
"""
148-
return parsers.serialization.deserialize_data(serial_file)
149+
return deserialize_data(serial_file)
149150

150151

151152
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
199200
files_field_values = []
200201
if serfile is None:
201202
for path in filepaths:
202-
fhd = parsers.loaddata.loadData(path, headers=True)
203+
fhd = loadData(path, headers=True)
203204
files_field_values.append([path, case_insensitive_dictionary_search(field, fhd)])
204205
else:
205206
# deserialize the serial file
206-
des_dict = parsers.serialization.deserialize_data(serfile)
207+
des_dict = deserialize_data(serfile)
207208

208209
# get names of each file to search the serial file
209210
import pathlib

0 commit comments

Comments
 (0)