diff --git a/cookiecutter.json b/cookiecutter.json index ca35864..505d983 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -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" } diff --git a/news/update-version.rst b/news/update-version.rst new file mode 100644 index 0000000..2808e10 --- /dev/null +++ b/news/update-version.rst @@ -0,0 +1,23 @@ +**Added:** + +* No news added: Support python>=3.12, <3.14; Replace deprecated methods. + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/pyproject.toml b/pyproject.toml index 1c5c1e9..ab1a4f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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', @@ -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', ] diff --git a/src/diffpy/apps/pdfadapter.py b/src/diffpy/apps/pdfadapter.py index e9875eb..1fe8276 100644 --- a/src/diffpy/apps/pdfadapter.py +++ b/src/diffpy/apps/pdfadapter.py @@ -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: @@ -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" @@ -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 ------- @@ -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 diff --git a/src/diffpy/apps/refinebase/parametric_model.py b/src/diffpy/apps/refinebase/parametric_model.py index c1c1979..ca8ddd3 100644 --- a/src/diffpy/apps/refinebase/parametric_model.py +++ b/src/diffpy/apps/refinebase/parametric_model.py @@ -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 " diff --git a/src/diffpy/apps/refinebase/refinement_session.py b/src/diffpy/apps/refinebase/refinement_session.py index 79195e3..1253655 100644 --- a/src/diffpy/apps/refinebase/refinement_session.py +++ b/src/diffpy/apps/refinebase/refinement_session.py @@ -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 @@ -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() diff --git a/tests/conftest.py b/tests/conftest.py index e60c74a..cd237de 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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 diff --git a/tests/helper.py b/tests/helper.py index 27ba197..733beb8 100644 --- a/tests/helper.py +++ b/tests/helper.py @@ -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" @@ -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 @@ -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", diff --git a/tests/test_pdfadapter.py b/tests/test_pdfadapter.py index 2addf9b..612435f 100644 --- a/tests/test_pdfadapter.py +++ b/tests/test_pdfadapter.py @@ -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: