Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"package_dir_name": "diffpy.apps",
"project_short_description": "User applications to help with tasks using diffpy packages",
"project_keywords": "diffraction, PDF, X-ray, neutron",
"minimum_supported_python_version": "3.11",
"maximum_supported_python_version": "3.13",
"minimum_supported_python_version": "3.12",
"maximum_supported_python_version": "3.14",
"project_needs_c_code_compiled": "No",
"project_has_gui_tests": "No"
}
23 changes: 23 additions & 0 deletions news/update-version.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* No news added: Support python>=3.12, <3.14; Replace deprecated methods.

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ maintainers = [
description = "User applications to help with tasks using diffpy packages"
keywords = ['diffraction', 'PDF', 'X-ray', 'neutron']
readme = "README.rst"
requires-python = ">=3.11, <3.14"
requires-python = ">=3.12, <3.15"
classifiers = [
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
Expand All @@ -25,9 +25,9 @@ classifiers = [
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Operating System :: Unix',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: 3.14',
'Topic :: Scientific/Engineering :: Physics',
'Topic :: Scientific/Engineering :: Chemistry',
]
Expand Down
12 changes: 7 additions & 5 deletions src/diffpy/apps/pdfadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
Profile,
)
from diffpy.srfit.pdf import PDFGenerator, PDFParser
from diffpy.srfit.structure import constrainAsSpaceGroup
from diffpy.structure.parsers import getParser
from diffpy.srfit.structure import constrain_as_space_group
from diffpy.structure.parsers import get_parser


class PDFAdapter:
Expand Down Expand Up @@ -147,7 +147,7 @@ def initialize_structures(
run_parallel = False
for i, structure_path in enumerate(structure_paths):
name = names[i] if names and i < len(names) else f"G{i+1}"
stru_parser = getParser("cif")
stru_parser = get_parser("cif")
structure = stru_parser.parse(Path(structure_path).read_text())
sg = getattr(stru_parser, "spacegroup", None)
spacegroup = sg.short_name if sg is not None else "P1"
Expand Down Expand Up @@ -176,7 +176,7 @@ def initialize_contribution(self, equation=None):
----------
equation : list of str, optional
The list of a single equation passed to
FitContribution.setEquation.
FitContribution.set_equation

Returns
-------
Expand Down Expand Up @@ -220,7 +220,9 @@ def initialize_recipe(
recipe.add_constraint(pdfgenerator.qdamp, qdamp)
recipe.add_constraint(pdfgenerator.qbroad, qbroad)
stru_parset = pdfgenerator.phase
spacegroupparams = constrainAsSpaceGroup(stru_parset, spacegroup)
spacegroupparams = constrain_as_space_group(
stru_parset, spacegroup
)
for par in spacegroupparams.xyzpars:
recipe.add_variable(
par, name=f"{pdfgenerator.name}_{par.name}", fixed=False
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/apps/refinebase/parametric_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,8 @@ def create_pdf_model_from_code(
if hasattr(structure, "GetCrystal")
else structure
)
if hasattr(crystal, "GetSpaceGroup"):
spacegroup_symbol = crystal.GetSpaceGroup().GetName()
if hasattr(crystal, "get_space_group"):
spacegroup_symbol = crystal.get_space_group().get_name()
else:
logging.warning(
"Could not determine a space group for the structure named "
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/apps/refinebase/refinement_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def add_profile_from_arrays(
if profile_name is None:
profile_name = str(uuid.uuid4())
profile = Profile()
profile.setObservedProfile(xobs=xarray, yobs=yarray, dyobs=dy)
profile.set_observed_profile(xobs=xarray, yobs=yarray, dyobs=dy)
profile.xpar.name = xname
profile._xname = xname
profile.ypar.name = yname
Expand Down Expand Up @@ -531,7 +531,7 @@ def _solve(
par = self.get_variable(eq_or_var_name)["obj"]
par.bound_range(lb, ub)
recipe.free("all")
leastsq(recipe.residual, recipe.getValues())
leastsq(recipe.residual, recipe.get_values())
# NOTE: non-scalar value will raise error in `get_results_string`
try:
result_string = FitResults(recipe).get_results_string()
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ def sine_profile():
xobs = numpy.linspace(-numpy.pi, numpy.pi, 100)
yobs = numpy.sin(xobs) + 1e-3 * numpy.random.normal(size=xobs.shape)
sine_profile = Profile()
sine_profile.setObservedProfile(xobs, yobs)
sine_profile.set_observed_profile(xobs, yobs)
return sine_profile
36 changes: 18 additions & 18 deletions tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
Profile,
)
from diffpy.srfit.pdf import DebyePDFGenerator, PDFGenerator, PDFParser
from diffpy.srfit.structure import constrainAsSpaceGroup
from diffpy.structure.parsers import getParser
from diffpy.srfit.structure import constrain_as_space_group
from diffpy.structure.parsers import get_parser

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

Expand Down Expand Up @@ -49,21 +49,21 @@ def run_ni_example():
QBROAD_I = 0.02
RUN_PARALLEL = True

p_cif = getParser("cif")
stru1 = p_cif.parseFile(structure_path)
p_cif = get_parser("cif")
stru1 = p_cif.parse_file(structure_path)
sg = p_cif.spacegroup.short_name
profile = Profile()
parser = PDFParser()
parser.parseFile(profile_path)
profile.loadParsedData(parser)
profile.setCalculationRange(xmin=PDF_RMIN, xmax=PDF_RMAX, dx=PDF_RSTEP)
parser.parse_file(profile_path)
profile.load_parsed_data(parser)
profile.set_calculation_range(xmin=PDF_RMIN, xmax=PDF_RMAX, dx=PDF_RSTEP)
generator_crystal1 = PDFGenerator("G1")
generator_crystal1.setStructure(stru1, periodic=True)
generator_crystal1.setQmax(QMAX)
generator_crystal1.setQmin(QMIN)
generator_crystal1.delta2.value = DELTA2_I
contribution = FitContribution("crystal")
contribution.addProfileGenerator(generator_crystal1)
contribution.add_profile_generator(generator_crystal1)
if RUN_PARALLEL:
try:
import multiprocessing
Expand All @@ -82,28 +82,28 @@ def run_ni_example():
"\nYou don't appear to have the necessary packages for "
"parallelization"
)
contribution.setProfile(profile, xname="r")
contribution.setEquation("s0*G1")
contribution.set_profile(profile, xname="r")
contribution.set_equation("s0*G1")
recipe = FitRecipe()
recipe.addContribution(contribution)
recipe.add_contribution(contribution)
recipe.crystal.G1.qdamp.value = QDAMP_I
recipe.crystal.G1.qbroad.value = QBROAD_I
recipe.crystal.G1.setQmax(QMAX)
recipe.crystal.G1.setQmin(QMIN)
recipe.addVar(contribution.s0, SCALE_I, name="s0")
spacegroupparams = constrainAsSpaceGroup(generator_crystal1.phase, sg)
recipe.add_variable(contribution.s0, SCALE_I, name="s0")
spacegroupparams = constrain_as_space_group(generator_crystal1.phase, sg)
for par in spacegroupparams.latpars:
recipe.addVar(par, value=CUBICLAT_I, fixed=False, name="G1_a")
recipe.add_variable(par, value=CUBICLAT_I, fixed=False, name="G1_a")
for par in spacegroupparams.adppars:
recipe.addVar(par, value=UISO_I, fixed=False, name="G1_Uiso_0")
recipe.addVar(generator_crystal1.delta2, name="G1_delta2")
recipe.addVar(
recipe.add_variable(par, value=UISO_I, fixed=False, name="G1_Uiso_0")
recipe.add_variable(generator_crystal1.delta2, name="G1_delta2")
recipe.add_variable(
generator_crystal1.qdamp,
fixed=False,
name="qdamp",
value=QDAMP_I,
)
recipe.addVar(
recipe.add_variable(
generator_crystal1.qbroad,
fixed=False,
name="qbroad",
Expand Down
4 changes: 3 additions & 1 deletion tests/test_pdfadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def test_pdfadapter():
adapter.initialize_structures([str(structure_path)])
adapter.initialize_contribution(equation=["s0*G1"])
adapter.initialize_recipe()
adapter.recipe.addVar(list(adapter.recipe._contributions.values())[0].s0)
adapter.recipe.add_variable(
list(adapter.recipe._contributions.values())[0].s0
)
adapter.set_initial_variable_values(initial_pv_dict)
adapter.recipe.fix("all")
for var in variables_to_refine:
Expand Down
Loading