Skip to content

Commit e975d65

Browse files
authored
Merge pull request #44 from ycexiao/update-version
chore: update python version requirements
2 parents 5bad459 + e235c2a commit e975d65

9 files changed

Lines changed: 60 additions & 33 deletions

File tree

‎cookiecutter.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"package_dir_name": "diffpy.apps",
1414
"project_short_description": "User applications to help with tasks using diffpy packages",
1515
"project_keywords": "diffraction, PDF, X-ray, neutron",
16-
"minimum_supported_python_version": "3.11",
17-
"maximum_supported_python_version": "3.13",
16+
"minimum_supported_python_version": "3.12",
17+
"maximum_supported_python_version": "3.14",
1818
"project_needs_c_code_compiled": "No",
1919
"project_has_gui_tests": "No"
2020
}

‎news/update-version.rst‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* No news added: Support python>=3.12, <3.14; Replace deprecated methods.
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+
* <news item>
20+
21+
**Security:**
22+
23+
* <news item>

‎pyproject.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ maintainers = [
1515
description = "User applications to help with tasks using diffpy packages"
1616
keywords = ['diffraction', 'PDF', 'X-ray', 'neutron']
1717
readme = "README.rst"
18-
requires-python = ">=3.11, <3.14"
18+
requires-python = ">=3.12, <3.15"
1919
classifiers = [
2020
'Development Status :: 5 - Production/Stable',
2121
'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
]

‎src/diffpy/apps/pdfadapter.py‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
Profile,
1313
)
1414
from diffpy.srfit.pdf import PDFGenerator, PDFParser
15-
from diffpy.srfit.structure import constrainAsSpaceGroup
16-
from diffpy.structure.parsers import getParser
15+
from diffpy.srfit.structure import constrain_as_space_group
16+
from diffpy.structure.parsers import get_parser
1717

1818

1919
class PDFAdapter:
@@ -147,7 +147,7 @@ def initialize_structures(
147147
run_parallel = False
148148
for i, structure_path in enumerate(structure_paths):
149149
name = names[i] if names and i < len(names) else f"G{i+1}"
150-
stru_parser = getParser("cif")
150+
stru_parser = get_parser("cif")
151151
structure = stru_parser.parse(Path(structure_path).read_text())
152152
sg = getattr(stru_parser, "spacegroup", None)
153153
spacegroup = sg.short_name if sg is not None else "P1"
@@ -176,7 +176,7 @@ def initialize_contribution(self, equation=None):
176176
----------
177177
equation : list of str, optional
178178
The list of a single equation passed to
179-
FitContribution.setEquation.
179+
FitContribution.set_equation
180180
181181
Returns
182182
-------
@@ -220,7 +220,9 @@ def initialize_recipe(
220220
recipe.add_constraint(pdfgenerator.qdamp, qdamp)
221221
recipe.add_constraint(pdfgenerator.qbroad, qbroad)
222222
stru_parset = pdfgenerator.phase
223-
spacegroupparams = constrainAsSpaceGroup(stru_parset, spacegroup)
223+
spacegroupparams = constrain_as_space_group(
224+
stru_parset, spacegroup
225+
)
224226
for par in spacegroupparams.xyzpars:
225227
recipe.add_variable(
226228
par, name=f"{pdfgenerator.name}_{par.name}", fixed=False

‎src/diffpy/apps/refinebase/parametric_model.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,8 @@ def create_pdf_model_from_code(
644644
if hasattr(structure, "GetCrystal")
645645
else structure
646646
)
647-
if hasattr(crystal, "GetSpaceGroup"):
648-
spacegroup_symbol = crystal.GetSpaceGroup().GetName()
647+
if hasattr(crystal, "get_space_group"):
648+
spacegroup_symbol = crystal.get_space_group().get_name()
649649
else:
650650
logging.warning(
651651
"Could not determine a space group for the structure named "

‎src/diffpy/apps/refinebase/refinement_session.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def add_profile_from_arrays(
6767
if profile_name is None:
6868
profile_name = str(uuid.uuid4())
6969
profile = Profile()
70-
profile.setObservedProfile(xobs=xarray, yobs=yarray, dyobs=dy)
70+
profile.set_observed_profile(xobs=xarray, yobs=yarray, dyobs=dy)
7171
profile.xpar.name = xname
7272
profile._xname = xname
7373
profile.ypar.name = yname
@@ -531,7 +531,7 @@ def _solve(
531531
par = self.get_variable(eq_or_var_name)["obj"]
532532
par.bound_range(lb, ub)
533533
recipe.free("all")
534-
leastsq(recipe.residual, recipe.getValues())
534+
leastsq(recipe.residual, recipe.get_values())
535535
# NOTE: non-scalar value will raise error in `get_results_string`
536536
try:
537537
result_string = FitResults(recipe).get_results_string()

‎tests/conftest.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ def sine_profile():
3939
xobs = numpy.linspace(-numpy.pi, numpy.pi, 100)
4040
yobs = numpy.sin(xobs) + 1e-3 * numpy.random.normal(size=xobs.shape)
4141
sine_profile = Profile()
42-
sine_profile.setObservedProfile(xobs, yobs)
42+
sine_profile.set_observed_profile(xobs, yobs)
4343
return sine_profile

‎tests/helper.py‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
Profile,
1111
)
1212
from diffpy.srfit.pdf import DebyePDFGenerator, PDFGenerator, PDFParser
13-
from diffpy.srfit.structure import constrainAsSpaceGroup
14-
from diffpy.structure.parsers import getParser
13+
from diffpy.srfit.structure import constrain_as_space_group
14+
from diffpy.structure.parsers import get_parser
1515

1616
_DATA_DIR = Path(__file__).parent / "data"
1717

@@ -49,21 +49,21 @@ def run_ni_example():
4949
QBROAD_I = 0.02
5050
RUN_PARALLEL = True
5151

52-
p_cif = getParser("cif")
53-
stru1 = p_cif.parseFile(structure_path)
52+
p_cif = get_parser("cif")
53+
stru1 = p_cif.parse_file(structure_path)
5454
sg = p_cif.spacegroup.short_name
5555
profile = Profile()
5656
parser = PDFParser()
57-
parser.parseFile(profile_path)
58-
profile.loadParsedData(parser)
59-
profile.setCalculationRange(xmin=PDF_RMIN, xmax=PDF_RMAX, dx=PDF_RSTEP)
57+
parser.parse_file(profile_path)
58+
profile.load_parsed_data(parser)
59+
profile.set_calculation_range(xmin=PDF_RMIN, xmax=PDF_RMAX, dx=PDF_RSTEP)
6060
generator_crystal1 = PDFGenerator("G1")
6161
generator_crystal1.setStructure(stru1, periodic=True)
6262
generator_crystal1.setQmax(QMAX)
6363
generator_crystal1.setQmin(QMIN)
6464
generator_crystal1.delta2.value = DELTA2_I
6565
contribution = FitContribution("crystal")
66-
contribution.addProfileGenerator(generator_crystal1)
66+
contribution.add_profile_generator(generator_crystal1)
6767
if RUN_PARALLEL:
6868
try:
6969
import multiprocessing
@@ -82,28 +82,28 @@ def run_ni_example():
8282
"\nYou don't appear to have the necessary packages for "
8383
"parallelization"
8484
)
85-
contribution.setProfile(profile, xname="r")
86-
contribution.setEquation("s0*G1")
85+
contribution.set_profile(profile, xname="r")
86+
contribution.set_equation("s0*G1")
8787
recipe = FitRecipe()
88-
recipe.addContribution(contribution)
88+
recipe.add_contribution(contribution)
8989
recipe.crystal.G1.qdamp.value = QDAMP_I
9090
recipe.crystal.G1.qbroad.value = QBROAD_I
9191
recipe.crystal.G1.setQmax(QMAX)
9292
recipe.crystal.G1.setQmin(QMIN)
93-
recipe.addVar(contribution.s0, SCALE_I, name="s0")
94-
spacegroupparams = constrainAsSpaceGroup(generator_crystal1.phase, sg)
93+
recipe.add_variable(contribution.s0, SCALE_I, name="s0")
94+
spacegroupparams = constrain_as_space_group(generator_crystal1.phase, sg)
9595
for par in spacegroupparams.latpars:
96-
recipe.addVar(par, value=CUBICLAT_I, fixed=False, name="G1_a")
96+
recipe.add_variable(par, value=CUBICLAT_I, fixed=False, name="G1_a")
9797
for par in spacegroupparams.adppars:
98-
recipe.addVar(par, value=UISO_I, fixed=False, name="G1_Uiso_0")
99-
recipe.addVar(generator_crystal1.delta2, name="G1_delta2")
100-
recipe.addVar(
98+
recipe.add_variable(par, value=UISO_I, fixed=False, name="G1_Uiso_0")
99+
recipe.add_variable(generator_crystal1.delta2, name="G1_delta2")
100+
recipe.add_variable(
101101
generator_crystal1.qdamp,
102102
fixed=False,
103103
name="qdamp",
104104
value=QDAMP_I,
105105
)
106-
recipe.addVar(
106+
recipe.add_variable(
107107
generator_crystal1.qbroad,
108108
fixed=False,
109109
name="qbroad",

‎tests/test_pdfadapter.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ def test_pdfadapter():
3737
adapter.initialize_structures([str(structure_path)])
3838
adapter.initialize_contribution(equation=["s0*G1"])
3939
adapter.initialize_recipe()
40-
adapter.recipe.addVar(list(adapter.recipe._contributions.values())[0].s0)
40+
adapter.recipe.add_variable(
41+
list(adapter.recipe._contributions.values())[0].s0
42+
)
4143
adapter.set_initial_variable_values(initial_pv_dict)
4244
adapter.recipe.fix("all")
4345
for var in variables_to_refine:

0 commit comments

Comments
 (0)