Skip to content

Commit 276b82f

Browse files
committed
Update deprecations, support 3.14
1 parent 268435c commit 276b82f

10 files changed

Lines changed: 61 additions & 36 deletions

File tree

docs/source/funcxy.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ kapton background ``background.chi``.
4040
4141
from diffpy.pdfgetx.pdfgetter import PDFGetter
4242
from diffpy.morph.morphpy import morph_arrays
43-
from diffpy.utils.parsers.loaddata import loadData
43+
from diffpy.utils.parsers import load_data
4444
4545
pg = PDFGetter()
4646
@@ -60,8 +60,8 @@ kapton background ``background.chi``.
6060
return (r, gr)
6161
6262
63-
sample_iq = loadData("sample.chi")
64-
target_gr = loadData("target.cgr")
63+
sample_iq = load_data("sample.chi")
64+
target_gr = load_data("target.cgr")
6565
params_to_morph = {
6666
"bgscale": 1.0,
6767
"qmin": 0.0, "qmax": 25.0,
@@ -124,7 +124,7 @@ our wavelength was ``1.11`` angstroms.
124124
import pyFAI.integrator.azimuthal as pyfai
125125
import pyFAI.detectors as pfd
126126
from diffpy.morph.morphpy import morph_arrays
127-
from diffpy.utils.parsers.loaddata import loadData
127+
from diffpy.utils.parsers.load_data import load_data
128128
129129
pattern_2d = np.load("diffraction_image.npy")
130130
wavelength = 0.1110e-9 # in m
@@ -163,8 +163,8 @@ our wavelength was ``1.11`` angstroms.
163163
"cent_offset_y": 0 # in number of pixels
164164
}
165165
166-
sample_chi = loadData("sample.chi")
167-
target_chi = loadData("target.chi")
166+
sample_chi = load_data("sample.chi")
167+
target_chi = load_data("target.chi")
168168
169169
morph_info, morphed_chi = morph_arrays(
170170
sample_chi, target_chi,

news/3.14.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
**Added:**
2+
3+
* <news item>
4+
5+
**Changed:**
6+
7+
* Updated support from 3.11-3.13 to 3.12-3.14.
8+
* Requires diffpy.utils>=3.7.1.
9+
10+
**Deprecated:**
11+
12+
* <news item>
13+
14+
**Removed:**
15+
16+
* <news item>
17+
18+
**Fixed:**
19+
20+
* <news item>
21+
22+
**Security:**
23+
24+
* <news item>

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ maintainers = [
1414
description = "Python package for manipulating and comparing 1D signals."
1515
keywords = ['diffpy', 'pdf', 'data interpretation']
1616
readme = "README.rst"
17-
requires-python = ">=3.11, <3.14"
17+
requires-python = ">=3.12, <3.15"
1818
classifiers = [
1919
'Development Status :: 5 - Production/Stable',
2020
'Environment :: Console',
@@ -25,9 +25,9 @@ classifiers = [
2525
'Operating System :: Microsoft :: Windows',
2626
'Operating System :: POSIX',
2727
'Operating System :: Unix',
28-
'Programming Language :: Python :: 3.11',
2928
'Programming Language :: Python :: 3.12',
3029
'Programming Language :: Python :: 3.13',
30+
'Programming Language :: Python :: 3.14',
3131
'Topic :: Scientific/Engineering :: Physics',
3232
'Topic :: Scientific/Engineering :: Chemistry',
3333
]

requirements/conda.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
numpy
22
scipy
3-
diffpy.utils>=3.6.1
3+
diffpy.utils>=3.7.1
44
matplotlib-base
55
bg-mpl-stylesheets

src/diffpy/morph/morph_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def morph(
245245
chain(x_morph, y_morph, x_target, y_target)
246246

247247
# summary
248-
rw = tools.getRw(chain)
248+
rw = tools.get_rw(chain)
249249
pcc = tools.get_pearson(chain)
250250
# restore rgrid
251251
chain[0] = morphs.Morph()

src/diffpy/morph/morphapp.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,8 @@ def single_morph(
527527
x_target = pargs[4]
528528
y_target = pargs[5]
529529
else:
530-
x_morph, y_morph = getPDFFromFile(pargs[0])
531-
x_target, y_target = getPDFFromFile(pargs[1])
530+
x_morph, y_morph = get_two_column_from_file(pargs[0])
531+
x_target, y_target = get_two_column_from_file(pargs[1])
532532

533533
if y_morph is None:
534534
parser.morph_error(f"No data table found in: {pargs[0]}.", ValueError)
@@ -754,7 +754,7 @@ def single_morph(
754754
io.handle_extrapolation_warnings(stretch_morph)
755755

756756
# Get Rw for the morph range
757-
rw = tools.getRw(chain)
757+
rw = tools.get_rw(chain)
758758
pcc = tools.get_pearson(chain)
759759
# Replace the MorphRGrid with Morph identity
760760
# This removes the r-range morph as mentioned above
@@ -1261,19 +1261,20 @@ def multiple_morphs(parser, opts, pargs, stdout_flag=True, python_wrap=False):
12611261
return morph_results
12621262

12631263

1264-
def getPDFFromFile(fn):
1265-
from diffpy.morph.tools import readPDF
1264+
def get_two_column_from_file(fn):
1265+
"""Open a two column data file and extract the data."""
1266+
from diffpy.morph.tools import read_two_column
12661267

12671268
try:
1268-
r, gr = readPDF(fn)
1269+
x, fx = read_two_column(fn)
12691270
except IOError as errmsg:
12701271
print("%s: %s" % (fn, errmsg), file=sys.stderr)
12711272
sys.exit(1)
12721273
except ValueError:
12731274
print("Cannot read %s" % fn, file=sys.stderr)
12741275
sys.exit(1)
12751276

1276-
return r, gr
1277+
return x, fx
12771278

12781279

12791280
def main():

src/diffpy/morph/tools.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717

1818
import numpy
1919

20-
from diffpy.utils.parsers.loaddata import loadData
20+
from diffpy.utils.parsers import load_data
2121
from diffpy.utils.parsers.serialization import deserialize_data
2222

2323

24-
def estimateScale(y_morph_in, y_target_in):
24+
def estimate_scale(y_morph_in, y_target_in):
2525
"""Set the scale that best matches the morph to the target."""
2626
dot = numpy.dot
2727
scale = dot(y_morph_in, y_target_in) / dot(y_morph_in, y_morph_in)
2828
return scale
2929

3030

31-
def estimateBaselineSlope(r, gr, rmin=None, rmax=None):
31+
def estimate_baseline_slope(r, gr, rmin=None, rmax=None):
3232
"""Estimate the slope of the linear baseline of a PDF.
3333
3434
This fits a slope into the equation slope*r through the bottom of the PDF.
@@ -85,7 +85,7 @@ def chiv(pars):
8585
return slope
8686

8787

88-
def getRw(chain):
88+
def get_rw(chain):
8989
"""Get Rw from the outputs of a morph or chain."""
9090
# Make sure we put these on the proper grid
9191
x_morph, y_morph, x_target, y_target = chain.xyallout
@@ -104,8 +104,8 @@ def get_pearson(chain):
104104
return pcc
105105

106106

107-
def readPDF(fname):
108-
"""Reads an .gr file, loads r and G(r) vectors.
107+
def read_two_column(fname):
108+
"""Reads a two-column data file, loads x and f(x) vectors.
109109
110110
Parameters
111111
----------
@@ -114,11 +114,11 @@ def readPDF(fname):
114114
115115
Returns
116116
-------
117-
r,gr
117+
x,fx
118118
Arrays read from data.
119119
"""
120120

121-
rv = loadData(fname, unpack=True)
121+
rv = load_data(fname, unpack=True)
122122
if len(rv) >= 2:
123123
return rv[:2]
124124
return (None, None)
@@ -207,7 +207,7 @@ def field_sort(
207207
files_field_values = []
208208
if serfile is None:
209209
for path in filepaths:
210-
fhd = loadData(path, headers=True)
210+
fhd = load_data(path, headers=True)
211211
files_field_values.append(
212212
[path, case_insensitive_dictionary_search(field, fhd)]
213213
)

tests/test_morphio.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
single_morph,
1212
)
1313
from diffpy.morph.morphpy import morph_arrays
14-
from diffpy.utils.parsers.loaddata import loadData
14+
from diffpy.utils.parsers import load_data
1515

1616
# Support Python 2
1717
try:
@@ -68,9 +68,9 @@ def are_files_same(file1, file2):
6868
def are_diffs_right(file1, file2, diff_file):
6969
"""Assert that diff_file ordinate data is approximately file1
7070
ordinate data minus file2 ordinate data."""
71-
f1_data = loadData(file1)
72-
f2_data = loadData(file2)
73-
diff_data = loadData(diff_file)
71+
f1_data = load_data(file1)
72+
f2_data = load_data(file2)
73+
diff_data = load_data(diff_file)
7474

7575
xmin = max(min(f1_data[:, 0]), min(f1_data[:, 1]))
7676
xmax = min(max(f2_data[:, 0]), max(f2_data[:, 1]))

tests/test_morphpy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from diffpy.morph.morphapp import create_option_parser, single_morph
99
from diffpy.morph.morphpy import __get_morph_opts__, morph, morph_arrays
10-
from diffpy.morph.tools import getRw
10+
from diffpy.morph.tools import get_rw
1111

1212
thisfile = locals().get("__file__", "file.py")
1313
tests_dir = Path(thisfile).parent.resolve()
@@ -166,7 +166,7 @@ class Chain:
166166
xyallout = grm[:, 0], grm[:, 1], grt[:, 0], grt[:, 1]
167167

168168
chain = Chain()
169-
rw = getRw(chain)
169+
rw = get_rw(chain)
170170
del chain
171171
assert np.allclose(
172172
[rw], [self.morphapp_results[target_file.name]["Rw"]]
@@ -237,7 +237,7 @@ class Chain:
237237
xyallout = grm[:, 0], grm[:, 1], grt[:, 0], grt[:, 1]
238238

239239
chain = Chain()
240-
rw = getRw(chain)
240+
rw = get_rw(chain)
241241
del chain
242242
assert np.allclose(
243243
[rw], [self.morphapp_results[target_file.name]["Rw"]]

tests/test_tools.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def setup(self):
2727
self.rho0 = 0.0917132
2828
return
2929

30-
def test_estimateBaselineSlope(self, setup):
30+
def test_estimate_baseline_slope(self, setup):
3131
"""Check estimateBaselineSlope() using calculated data."""
32-
slope = tools.estimateBaselineSlope(self.x_morph, self.y_morph)
32+
slope = tools.estimate_baseline_slope(self.x_morph, self.y_morph)
3333
slopecalc = -4 * numpy.pi * self.rho0
3434
assert numpy.allclose(slopecalc, slope, 1e-2)
3535
return
@@ -39,7 +39,7 @@ def test_estimateScale(self, setup):
3939
import random
4040

4141
x = random.random()
42-
scale = tools.estimateScale(self.y_morph, x * self.y_morph)
42+
scale = tools.estimate_scale(self.y_morph, x * self.y_morph)
4343
assert x, scale
4444
return
4545

0 commit comments

Comments
 (0)