diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0e4a84d..9573476 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ ci: submodules: false repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v6.0.0 hooks: - id: check-yaml - id: end-of-file-fixer @@ -21,31 +21,31 @@ repos: - id: check-toml - id: check-added-large-files - repo: https://github.com/psf/black - rev: 24.4.2 + rev: 26.3.1 hooks: - id: black - repo: https://github.com/pycqa/flake8 - rev: 7.0.0 + rev: 7.3.0 hooks: - id: flake8 - repo: https://github.com/pycqa/isort - rev: 5.13.2 + rev: 9.0.0a3 hooks: - id: isort args: ["--profile", "black"] - repo: https://github.com/kynan/nbstripout - rev: 0.7.1 + rev: 0.9.1 hooks: - id: nbstripout - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v6.0.0 hooks: - id: no-commit-to-branch name: Prevent Commit to Main Branch args: ["--branch", "main"] stages: [pre-commit] - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + rev: v2.4.2 hooks: - id: codespell additional_dependencies: @@ -58,8 +58,8 @@ repos: additional_dependencies: - "prettier@^3.2.4" # docformatter - PEP 257 compliant docstring formatter - - repo: https://github.com/s-weigand/docformatter - rev: 5757c5190d95e5449f102ace83df92e7d3b06c6c + - repo: https://github.com/PyCQA/docformatter + rev: v1.7.8 hooks: - id: docformatter additional_dependencies: [tomli] diff --git a/news/cpp-version-update.rst b/news/cpp-version-update.rst new file mode 100644 index 0000000..8df5ec8 --- /dev/null +++ b/news/cpp-version-update.rst @@ -0,0 +1,24 @@ +**Added:** + +* + +**Changed:** + +* updated cpp minimum version to c++23. +* replaced boost smart pointer usages with stl implementations. + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/news/precommit-deps-update.rst b/news/precommit-deps-update.rst new file mode 100644 index 0000000..343a74b --- /dev/null +++ b/news/precommit-deps-update.rst @@ -0,0 +1,23 @@ +**Added:** + +* No news needed: updating pre-commit hooks, black, flake8, isort, nbstripout, codespell and docformatter. Not user facing. + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/pyproject.toml b/pyproject.toml index 840710d..894051c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,10 @@ [build-system] -requires = ["setuptools>=62.0", "setuptools-git-versioning>=2.0", "numpy"] +requires = [ + "setuptools>=62.0", + "setuptools-git-versioning>=2.0", + "numpy", + "nanobind", +] build-backend = "setuptools.build_meta" [project] diff --git a/requirements/conda.txt b/requirements/conda.txt index 0f11dbe..2944258 100644 --- a/requirements/conda.txt +++ b/requirements/conda.txt @@ -4,3 +4,4 @@ libobjcryst pyobjcryst diffpy.structure periodictable +nanobind diff --git a/setup.py b/setup.py index ab1f858..a254f78 100644 --- a/setup.py +++ b/setup.py @@ -14,6 +14,23 @@ import numpy from setuptools import Extension, setup +from setuptools.command.build_ext import build_ext + + +def get_nanobind_config(): + import nanobind + + package_dir = Path(nanobind.__file__).parent + return { + "include_dirs": [ + nanobind.include_dir(), + str(package_dir / "ext" / "robin_map" / "include"), + ], + "source": str(Path(nanobind.source_dir()) / "nb_combined.cpp"), + } + + +nanobind_macros = [("NB_COMPACT_ASSERTIONS", None)] def get_boost_libraries(): @@ -90,11 +107,13 @@ def get_objcryst_libraries(): if os.name == "nt": - compile_args = ["/std:c++14"] + compile_args = ["/std:c++23"] + nanobind_compile_args = ["/std:c++23"] macros = [("_USE_MATH_DEFINES", None)] extra_link_args = ["/FORCE:MULTIPLE"] else: - compile_args = ["-std=c++11"] + compile_args = ["-std=c++23"] + nanobind_compile_args = ["-std=c++23", "-fno-strict-aliasing"] macros = [] extra_link_args = [] @@ -112,13 +131,44 @@ def get_objcryst_libraries(): } +class build_ext_with_nanobind(build_ext): + def build_extension(self, ext): + nanobind_source = getattr(ext, "nanobind_source", None) + if not nanobind_source: + super().build_extension(ext) + return + + original_extra_objects = list(ext.extra_objects or []) + try: + nanobind_objects = self.compiler.compile( + [nanobind_source], + output_dir=self.build_temp, + macros=(ext.define_macros or []) + nanobind_macros, + include_dirs=ext.include_dirs, + debug=self.debug, + extra_postargs=nanobind_compile_args, + depends=ext.depends, + ) + ext.extra_objects = original_extra_objects + nanobind_objects + super().build_extension(ext) + finally: + ext.extra_objects = original_extra_objects + + def create_extensions(): "Initialize Extension objects for the setup function." + nanobind_cfg = get_nanobind_config() ext = Extension( "diffpy.srreal.srreal_ext", glob.glob("src/extensions/*.cpp"), - **ext_kws, + **{ + **ext_kws, + "include_dirs": ( + ext_kws["include_dirs"] + nanobind_cfg["include_dirs"] + ), + }, ) + ext.nanobind_source = nanobind_cfg["source"] return [ext] @@ -130,4 +180,7 @@ def ext_modules(): if __name__ == "__main__": - setup(ext_modules=ext_modules()) + setup( + cmdclass={"build_ext": build_ext_with_nanobind}, + ext_modules=ext_modules(), + ) diff --git a/src/diffpy/__init__.py b/src/diffpy/__init__.py index 67de525..23aceba 100644 --- a/src/diffpy/__init__.py +++ b/src/diffpy/__init__.py @@ -14,7 +14,6 @@ ############################################################################## """Blank namespace package for module diffpy.""" - from pkgutil import extend_path __path__ = extend_path(__path__, __name__) diff --git a/src/diffpy/srreal/_cleanup.py b/src/diffpy/srreal/_cleanup.py index 19fdffd..d5082ad 100644 --- a/src/diffpy/srreal/_cleanup.py +++ b/src/diffpy/srreal/_cleanup.py @@ -24,7 +24,6 @@ class prototypes is implemented in libdiffpy. Any Python-extended classes a call of _registerThisType. """ - import atexit import weakref diff --git a/src/diffpy/srreal/_final_imports.py b/src/diffpy/srreal/_final_imports.py index b61e0dc..e9c7792 100644 --- a/src/diffpy/srreal/_final_imports.py +++ b/src/diffpy/srreal/_final_imports.py @@ -15,14 +15,16 @@ """Finalize tweak of classes from the extension module srreal_ext. This private module handles loading of Python-level tweaks of the -extension-defined classes. Any client that imports this module -must call the `import_now` function. If this module is not loaded -by the time of srreal_ext initialization, `import_now` is executed -from srreal_ext. +extension-defined classes. Any client that imports this module must +call the `import_now` function. If this module is not loaded by the +time of srreal_ext initialization, `import_now` is executed from +srreal_ext. This avoids unresolvable import dependencies for any order of imports. """ +_import_now_called = False + def import_now(): """Import all Python modules that tweak extension-defined @@ -46,6 +48,3 @@ def import_now(): import_module("diffpy.srreal.pdfcalculator") import_module("diffpy.srreal.structureconverters") return - - -_import_now_called = False diff --git a/src/diffpy/srreal/atomradiitable.py b/src/diffpy/srreal/atomradiitable.py index bdc012c..c649445 100644 --- a/src/diffpy/srreal/atomradiitable.py +++ b/src/diffpy/srreal/atomradiitable.py @@ -14,7 +14,6 @@ ############################################################################## """Class AtomRadiiTable -- storage of empirical atom radii.""" - # exported items, these also makes them show in pydoc. __all__ = ["AtomRadiiTable", "ConstantRadiiTable", "CovalentRadiiTable"] @@ -66,8 +65,9 @@ def clone(self): return copy.copy(self) def type(self): - """Unique string identifier of the CovalentRadiiTable type. This - is used for class registration and as an argument for the + """Unique string identifier of the CovalentRadiiTable type. + + This is used for class registration and as an argument for the createByType function. Return string. diff --git a/src/diffpy/srreal/attributes.py b/src/diffpy/srreal/attributes.py index 3e188ca..59060f6 100644 --- a/src/diffpy/srreal/attributes.py +++ b/src/diffpy/srreal/attributes.py @@ -13,7 +13,7 @@ # ############################################################################## """class Attributes -- wrapper to C++ class diffpy::Attributes - A base to PairQuantity and quite a few other classes. +A base to PairQuantity and quite a few other classes. """ __all__ = ["Attributes"] diff --git a/src/diffpy/srreal/bondcalculator.py b/src/diffpy/srreal/bondcalculator.py index 0fede96..93b3a8f 100644 --- a/src/diffpy/srreal/bondcalculator.py +++ b/src/diffpy/srreal/bondcalculator.py @@ -14,7 +14,6 @@ ############################################################################## """Class BondCalculator -- distances between atoms in the structure.""" - # exported items, these also makes them show in pydoc. __all__ = ["BondCalculator"] @@ -28,14 +27,12 @@ BondCalculator.rmin = propertyFromExtDoubleAttr( "rmin", - """Lower bound for the bond distances. - [0 A]""", + "Lower bound for the bond distances. [0 A]", ) BondCalculator.rmax = propertyFromExtDoubleAttr( "rmax", - """Upper bound for the bond distances. - [5 A]""", + "Upper bound for the bond distances. [5 A]", ) diff --git a/src/diffpy/srreal/bvparameterstable.py b/src/diffpy/srreal/bvparameterstable.py index 6d6d924..4766b4d 100644 --- a/src/diffpy/srreal/bvparameterstable.py +++ b/src/diffpy/srreal/bvparameterstable.py @@ -15,7 +15,6 @@ """Class BVParametersTable -- storage of bond valence parameters class BVParam -- bond valence data associated with specific cation-anion pair.""" - # exported items, these also makes them show in pydoc. __all__ = ["BVParam", "BVParametersTable"] diff --git a/src/diffpy/srreal/bvscalculator.py b/src/diffpy/srreal/bvscalculator.py index 855cf87..060bfcf 100644 --- a/src/diffpy/srreal/bvscalculator.py +++ b/src/diffpy/srreal/bvscalculator.py @@ -14,7 +14,6 @@ ############################################################################## """Class BVSCalculator -- bond valence sums calculator.""" - # exported items __all__ = ["BVSCalculator"] @@ -28,30 +27,32 @@ BVSCalculator.valenceprecision = propertyFromExtDoubleAttr( "valenceprecision", - """Cutoff value for valence contributions at long distances. - [1e-5]""", + "Cutoff value for valence contributions at long distances. [1e-5]", ) BVSCalculator.rmaxused = propertyFromExtDoubleAttr( "rmaxused", - """Effective bound for bond lengths, where valence contributions - become smaller than valenceprecission, read-only. Always smaller or - equal to rmax. The value depends on ions present in the structure. - """, + ( + "Effective bound for bond lengths, where valence contributions" + " become smaller than valenceprecission, read-only." + " Always smaller or equal to rmax." + " The value depends on ions present in the structure." + ), ) BVSCalculator.rmin = propertyFromExtDoubleAttr( "rmin", - """Lower bound for the summed bond lengths. - [0 A]""", + "Lower bound for the summed bond lengths. [0 A]", ) BVSCalculator.rmax = propertyFromExtDoubleAttr( "rmax", - """Upper bound for the summed bond lengths. The calculation is - actually cut off much earlier when valence contributions get below - valenceprecission. See also rmaxused and valenceprecission. - [1e6 A]""", + ( + "Upper bound for the summed bond lengths." + " The calculation is actually cut off much earlier when" + " valence contributions get below valenceprecission." + " See also rmaxused and valenceprecission. [1e6 A]" + ), ) diff --git a/src/diffpy/srreal/eventticker.py b/src/diffpy/srreal/eventticker.py index 58d9556..7ed53c2 100644 --- a/src/diffpy/srreal/eventticker.py +++ b/src/diffpy/srreal/eventticker.py @@ -15,7 +15,6 @@ """Class EventTicker -- storage of modification times of dependent objects.""" - # exported items __all__ = ["EventTicker"] diff --git a/src/diffpy/srreal/overlapcalculator.py b/src/diffpy/srreal/overlapcalculator.py index 6abd4b4..a9c88d1 100644 --- a/src/diffpy/srreal/overlapcalculator.py +++ b/src/diffpy/srreal/overlapcalculator.py @@ -15,7 +15,6 @@ """Class OverlapCalculator -- calculator of atom overlaps in a structure.""" - # exported items, these also makes them show in pydoc. __all__ = ["OverlapCalculator"] @@ -29,22 +28,21 @@ OverlapCalculator.rmin = propertyFromExtDoubleAttr( "rmin", - """Lower bound for the bond distances. - [0 A]""", + "Lower bound for the bond distances. [0 A]", ) OverlapCalculator.rmax = propertyFromExtDoubleAttr( "rmax", - """Upper bound for the bond distances. - [5 A]""", + "Upper bound for the bond distances. [5 A]", ) OverlapCalculator.rmaxused = propertyFromExtDoubleAttr( "rmaxused", - """Effective upper bound for the bond distances. - rmaxused equals either a double of the maximum atom radius - in the structure or rmax. - """, + ( + "Effective upper bound for the bond distances." + " rmaxused equals either a double of the maximum" + " atom radius in the structure or rmax." + ), ) # method overrides that support keyword arguments diff --git a/src/diffpy/srreal/pairquantity.py b/src/diffpy/srreal/pairquantity.py index 7097e7c..62f729b 100644 --- a/src/diffpy/srreal/pairquantity.py +++ b/src/diffpy/srreal/pairquantity.py @@ -15,7 +15,6 @@ """Class PairQuantity -- base class for Python defined calculators.""" - # exported items __all__ = ["PairQuantity"] diff --git a/src/diffpy/srreal/parallel.py b/src/diffpy/srreal/parallel.py index 45aa39c..ca80098 100644 --- a/src/diffpy/srreal/parallel.py +++ b/src/diffpy/srreal/parallel.py @@ -16,7 +16,6 @@ into parallel calculators. """ - # exported items __all__ = ["createParallelCalculator"] @@ -48,8 +47,10 @@ def createParallelCalculator(pqobj, ncpu, pmap): """ class ParallelPairQuantity(Attributes): - """Class for running parallel calculations. This is a proxy - class to the wrapper PairQuantity type with the same interface. + """Class for running parallel calculations. + + This is a proxy class to the wrapper PairQuantity type + with the same interface. Instance data: @@ -144,7 +145,7 @@ def parallel_eval(stru): @property def evaluatortype(self): - """str : Type of evaluation procedure. + """Str : Type of evaluation procedure. Parallel calculations allow only the 'BASIC' type. """ @@ -166,11 +167,9 @@ def evaluatortype(self, value): # create proxy methods to all public methods and some protected methods - proxy_forced = set( - """_getDoubleAttr _setDoubleAttr _hasDoubleAttr + proxy_forced = set("""_getDoubleAttr _setDoubleAttr _hasDoubleAttr _namesOfDoubleAttributes _namesOfWritableDoubleAttributes - """.split() - ) + """.split()) def _make_proxymethod(name, f): def proxymethod(self, *args, **kwargs): diff --git a/src/diffpy/srreal/pdfbaseline.py b/src/diffpy/srreal/pdfbaseline.py index d3d2e56..23a6a48 100644 --- a/src/diffpy/srreal/pdfbaseline.py +++ b/src/diffpy/srreal/pdfbaseline.py @@ -17,7 +17,6 @@ PDFBaseline, ZeroBaseline, LinearBaseline """ - # exported items __all__ = """ PDFBaseline makePDFBaseline @@ -40,8 +39,10 @@ LinearBaseline.slope = propertyFromExtDoubleAttr( "slope", - """Slope of an unscaled linear baseline. For crystal structures it - is preset to (-4 * pi * rho0).""", + ( + "Slope of an unscaled linear baseline. For crystal structures it" + " is preset to (-4 * pi * rho0)." + ), ) # Python functions wrapper diff --git a/src/diffpy/srreal/pdfcalculator.py b/src/diffpy/srreal/pdfcalculator.py index d4f1c1f..0ed0835 100644 --- a/src/diffpy/srreal/pdfcalculator.py +++ b/src/diffpy/srreal/pdfcalculator.py @@ -88,77 +88,78 @@ def _defineCommonInterface(cls): """This function defines shared properties of PDF calculator classes.""" - cls.scale = propertyFromExtDoubleAttr( "scale", - """Scale factor of the calculated PDF. Active for ScaleEnvelope. - [1.0 unitless]""", + ( + "Scale factor of the calculated PDF." + " Active for ScaleEnvelope. [1.0 unitless]" + ), ) cls.delta1 = propertyFromExtDoubleAttr( "delta1", - """Coefficient for (1/r) contribution to the peak sharpening. - Active for JeongPeakWidth model. - [0 A]""", + ( + "Coefficient for (1/r) contribution to the peak sharpening." + " Active for JeongPeakWidth model. [0 A]" + ), ) cls.delta2 = propertyFromExtDoubleAttr( "delta2", - """Coefficient for (1/r**2) contribution to the peak sharpening. - Active for JeongPeakWidth model. - [0 A**2]""", + ( + "Coefficient for (1/r**2) contribution to the peak sharpening." + " Active for JeongPeakWidth model. [0 A**2]" + ), ) cls.qdamp = propertyFromExtDoubleAttr( "qdamp", - """PDF Gaussian dampening factor due to limited Q-resolution. - Not applied when equal to zero. Active for QResolutionEnvelope. - [0 1/A]""", + ( + "PDF Gaussian dampening factor due to limited Q-resolution." + " Not applied when equal to zero." + " Active for QResolutionEnvelope. [0 1/A]" + ), ) cls.qbroad = propertyFromExtDoubleAttr( "qbroad", - """PDF peak broadening from increased intensity noise at high Q. - Not applied when equal zero. Active for JeongPeakWidth model. - [0 1/A]""", + ( + "PDF peak broadening from increased intensity noise at high Q." + " Not applied when equal zero." + " Active for JeongPeakWidth model. [0 1/A]" + ), ) cls.extendedrmin = propertyFromExtDoubleAttr( "extendedrmin", - """Low boundary of the extended r-range, read-only. - [A]""", + "Low boundary of the extended r-range, read-only. [A]", ) cls.extendedrmax = propertyFromExtDoubleAttr( "extendedrmax", - """Upper boundary of the extended r-range, read-only. - [A]""", + "Upper boundary of the extended r-range, read-only. [A]", ) - cls.maxextension = propertyFromExtDoubleAttr( "maxextension", - """Maximum extension of the r-range that accounts for contributions - from the out of range peaks. - [10 A]""", + ( + "Maximum extension of the r-range that accounts for" + " contributions from the out of range peaks. [10 A]" + ), ) - cls.rmin = propertyFromExtDoubleAttr( "rmin", - """Lower bound of the r-grid for PDF calculation. - [0 A]""", + "Lower bound of the r-grid for PDF calculation. [0 A]", ) - cls.rmax = propertyFromExtDoubleAttr( "rmax", - """Upper bound of the r-grid for PDF calculation. - [10 A]""", + "Upper bound of the r-grid for PDF calculation. [10 A]", ) - cls.rstep = propertyFromExtDoubleAttr( "rstep", - """Spacing in the calculated r-grid. r-values are at the - multiples of rstep. - [0.01 A]""", + ( + "Spacing in the calculated r-grid." + " r-values are at the multiples of rstep. [0.01 A]" + ), ) def _call_kwargs(self, structure=None, **kwargs): @@ -197,36 +198,36 @@ def _call_kwargs(self, structure=None, **kwargs): # shared interface of the PDF calculator classes _defineCommonInterface(DebyePDFCalculator) - # Property wrappers to double attributes of the C++ DebyePDFCalculator DebyePDFCalculator.debyeprecision = propertyFromExtDoubleAttr( "debyeprecision", - """Cutoff amplitude for the sine contributions to the F(Q). - [1e-6 unitless]""", + "Cutoff amplitude for the sine contributions to the F(Q). [1e-6 unitless]", ) DebyePDFCalculator.qmin = propertyFromExtDoubleAttr( "qmin", - """Lower bound of the Q-grid for the calculated F(Q). - Affects the shape envelope. - [0 1/A] - """, + ( + "Lower bound of the Q-grid for the calculated F(Q)." + " Affects the shape envelope. [0 1/A]" + ), ) DebyePDFCalculator.qmax = propertyFromExtDoubleAttr( "qmax", - """Upper bound of the Q-grid for the calculated F(Q). - Affects the termination ripples. - [25 1/A] - """, + ( + "Upper bound of the Q-grid for the calculated F(Q)." + " Affects the termination ripples. [25 1/A]" + ), ) DebyePDFCalculator.qstep = propertyFromExtDoubleAttr( "qstep", - """Spacing in the Q-grid. Q-values are at the multiples of qstep. - [PI/extendedrmax A] unless user overridden. - See also setOptimumQstep, isOptimumQstep.""", + ( + "Spacing in the Q-grid." + " Q-values are at the multiples of qstep. [PI/extendedrmax A]" + " unless user overridden. See also setOptimumQstep, isOptimumQstep." + ), ) # method overrides to support optional keyword arguments @@ -248,7 +249,6 @@ def _init_kwargs0(self, **kwargs): DebyePDFCalculator.__boostpython__init = DebyePDFCalculator.__init__ DebyePDFCalculator.__init__ = _init_kwargs0 - # End of class DebyePDFCalculator # PDFCalculator -------------------------------------------------------------- @@ -261,53 +261,62 @@ def _init_kwargs0(self, **kwargs): PDFCalculator.peakprecision = propertyFromExtDoubleAttr( "peakprecision", - """Cutoff amplitude of the peak tail relative to the peak maximum. - [3.33e-6 unitless]""", + ( + "Cutoff amplitude of the peak tail relative to the peak maximum." + " [3.33e-6 unitless]" + ), ) - PDFCalculator.qmin = propertyFromExtDoubleAttr( "qmin", - """Lower bound of the experimental Q-range used. - Affects the shape envelope. - [0 1/A]""", + ( + "Lower bound of the experimental Q-range used." + " Affects the shape envelope. [0 1/A]" + ), ) - PDFCalculator.qmax = propertyFromExtDoubleAttr( "qmax", - """Upper bound of the experimental Q-range used. - Affects the termination ripples. Not used when zero. - [0 1/A]""", + ( + "Upper bound of the experimental Q-range used." + " Affects the termination ripples. Not used when zero. [0 1/A]" + ), ) - PDFCalculator.qstep = propertyFromExtDoubleAttr( "qstep", - """Spacing in the Q-grid. Q-values are at the multiples of qstep. - The value is padded by rsteps so that PI/qstep > extendedrmax and - PI/(qstep * rstep) is a power of 2. Read-only. - [PI/(padded extendedrmax) A]""", + ( + "Spacing in the Q-grid." + " Q-values are at the multiples of qstep. The value is padded" + " by rsteps so that PI/qstep > extendedrmax and" + " PI/(qstep * rstep) is a power of 2. Read-only." + " [PI/(padded extendedrmax) A]" + ), ) PDFCalculator.slope = propertyFromExtDoubleAttr( "slope", - """Slope of the linear PDF background. Assigned according to - number density of the evaluated structure at each PDF calculation. - Active for LinearBaseline. - [-4*pi*numdensity unitless]""", + ( + "Slope of the linear PDF background." + " Assigned according to number density of the evaluated" + " structure at each PDF calculation. Active for LinearBaseline." + " [-4*pi*numdensity unitless]" + ), ) PDFCalculator.spdiameter = propertyFromExtDoubleAttr( "spdiameter", - """Spherical particle diameter for PDF shape damping correction. - Not used when zero. Active for SphericalShapeEnvelope. - [0 A]""", + ( + "Spherical particle diameter for PDF shape damping correction." + " Not used when zero. Active for SphericalShapeEnvelope. [0 A]" + ), ) PDFCalculator.stepcut = propertyFromExtDoubleAttr( "stepcut", - """r-boundary for a step cutoff of the calculated PDF. - Not used when negative or zero. Active for StepCutEnvelope. - Not used when zero. Active for StepCutEnvelope. - [0 A]""", + ( + "r-boundary for a step cutoff of the calculated PDF." + " Not used when negative or zero. Active for StepCutEnvelope." + " Not used when zero. Active for StepCutEnvelope." + " [0 A]" + ), ) # method overrides to support optional keyword arguments diff --git a/src/diffpy/srreal/pdfenvelope.py b/src/diffpy/srreal/pdfenvelope.py index a8f68a4..08369f0 100644 --- a/src/diffpy/srreal/pdfenvelope.py +++ b/src/diffpy/srreal/pdfenvelope.py @@ -18,7 +18,6 @@ SphericalShapeEnvelope, StepCutEnvelope """ - # exported items __all__ = """ PDFEnvelope makePDFEnvelope @@ -51,26 +50,22 @@ QResolutionEnvelope.qdamp = propertyFromExtDoubleAttr( "qdamp", - """Dampening parameter in the Gaussian envelope function. - """, + "Dampening parameter in the Gaussian envelope function.", ) ScaleEnvelope.scale = propertyFromExtDoubleAttr( "scale", - """Overall scale for a uniform scaling envelope. - """, + "Overall scale for a uniform scaling envelope.", ) SphericalShapeEnvelope.spdiameter = propertyFromExtDoubleAttr( "spdiameter", - """Particle diameter in Angstroms for a spherical shape damping. - """, + "Particle diameter in Angstroms for a spherical shape damping.", ) StepCutEnvelope.stepcut = propertyFromExtDoubleAttr( "stepcut", - """Cutoff for a step-function envelope. - """, + "Cutoff for a step-function envelope.", ) # Python functions wrapper diff --git a/src/diffpy/srreal/peakprofile.py b/src/diffpy/srreal/peakprofile.py index 7692e1d..765dabc 100644 --- a/src/diffpy/srreal/peakprofile.py +++ b/src/diffpy/srreal/peakprofile.py @@ -18,7 +18,6 @@ GaussianProfile, CroppedGaussianProfile """ - # exported items __all__ = ["PeakProfile", "GaussianProfile", "CroppedGaussianProfile"] @@ -41,9 +40,11 @@ PeakProfile.peakprecision = propertyFromExtDoubleAttr( "peakprecision", - """Profile amplitude relative to the peak maximum for evaluating peak - bounds xboundlo and xboundhi. [3.33e-6 unitless] - """, + ( + "Profile amplitude relative to the peak maximum for evaluating " + "peak bounds xboundlo and xboundhi.\n\n" + "[3.33e-6 unitless]" + ), ) # Import delayed tweaks of the extension classes. diff --git a/src/diffpy/srreal/peakwidthmodel.py b/src/diffpy/srreal/peakwidthmodel.py index 7c73e8e..debefc0 100644 --- a/src/diffpy/srreal/peakwidthmodel.py +++ b/src/diffpy/srreal/peakwidthmodel.py @@ -18,7 +18,6 @@ ConstantPeakWidth, DebyeWallerPeakWidth, JeongPeakWidth """ - # exported items __all__ = [ "PeakWidthModel", @@ -42,20 +41,17 @@ ConstantPeakWidth.width = propertyFromExtDoubleAttr( "width", - """Constant FWHM value returned by this model. - """, + "Constant FWHM value returned by this model.", ) ConstantPeakWidth.bisowidth = propertyFromExtDoubleAttr( "bisowidth", - """Equivalent uniform Biso for this constant `width`. - """, + "Equivalent uniform Biso for this constant `width`.", ) ConstantPeakWidth.uisowidth = propertyFromExtDoubleAttr( "uisowidth", - """Equivalent uniform Uiso for this constant `width`. - """, + "Equivalent uniform Uiso for this constant `width`.", ) JeongPeakWidth.delta1 = propertyFromExtDoubleAttr( diff --git a/src/diffpy/srreal/scatteringfactortable.py b/src/diffpy/srreal/scatteringfactortable.py index 9fa232a..95acac4 100644 --- a/src/diffpy/srreal/scatteringfactortable.py +++ b/src/diffpy/srreal/scatteringfactortable.py @@ -15,7 +15,6 @@ """Class ScatteringFactorTable -- scattering factors for atoms, ions and isotopes.""" - # exported items, these also makes them show in pydoc. __all__ = [ "ScatteringFactorTable", diff --git a/src/diffpy/srreal/sfaverage.py b/src/diffpy/srreal/sfaverage.py index d524b0c..3f12e8c 100644 --- a/src/diffpy/srreal/sfaverage.py +++ b/src/diffpy/srreal/sfaverage.py @@ -33,7 +33,6 @@ dpdfc.scatteringfactortable, dpdfc.qgrid) """ - # class SFAverage ------------------------------------------------------------ diff --git a/src/diffpy/srreal/wraputils.py b/src/diffpy/srreal/wraputils.py index b3a5ee6..4236e81 100644 --- a/src/diffpy/srreal/wraputils.py +++ b/src/diffpy/srreal/wraputils.py @@ -15,7 +15,6 @@ """Local utilities helpful for tweaking interfaces to boost python classes.""" - import copy # Routines ------------------------------------------------------------------- @@ -111,9 +110,10 @@ def clone(self): return copy.copy(self) def type(self): - """Unique string identifier of this functor type. The - string is used for class registration and as an argument for - the createByType function. + """Unique string identifier of this functor type. + + The string is used for class registration and as an argument + for the createByType function. Return string identifier. """ diff --git a/src/extensions/srreal_pickling.hpp b/src/extensions/srreal_pickling.hpp index 17068f4..7acf544 100644 --- a/src/extensions/srreal_pickling.hpp +++ b/src/extensions/srreal_pickling.hpp @@ -245,7 +245,7 @@ class StructureAdapterPickleSuite : public boost::python::pickle_suite static bool frompython( diffpy::srreal::StructureAdapterPtr adpt) { - return bool(boost::dynamic_pointer_cast(adpt)); + return bool(std::dynamic_pointer_cast(adpt)); } }; // class StructureAdapterPickleSuite diff --git a/src/extensions/wrap_AtomicStructureAdapter.cpp b/src/extensions/wrap_AtomicStructureAdapter.cpp index e3ce6b3..e6b3953 100644 --- a/src/extensions/wrap_AtomicStructureAdapter.cpp +++ b/src/extensions/wrap_AtomicStructureAdapter.cpp @@ -390,7 +390,7 @@ class MakeWrapper : public T, public wrapper_srreal // Wrapper helpers for class AtomicStructureAdapter typedef MakeWrapper AtomicStructureAdapterWrap; -typedef boost::shared_ptr AtomicStructureAdapterWrapPtr; +typedef std::shared_ptr AtomicStructureAdapterWrapPtr; class atomadapter_indexing : public vector_indexing_suite< AtomicStructureAdapter, false, atomadapter_indexing> @@ -406,7 +406,7 @@ class atomadapter_indexing : public vector_indexing_suite< // of any additional structure data. StructureAdapterPtr rv = container.clone(); AtomicStructureAdapterPtr rva; - rva = boost::static_pointer_cast(rv); + rva = std::static_pointer_cast(rv); // handle index ranges for a valid and empty slice if (from <= to) { @@ -458,7 +458,7 @@ void atomadapter_reserve(AtomicStructureAdapter& adpt, int sz) // Wrapper helpers for class PeriodicStructureAdapter typedef MakeWrapper PeriodicStructureAdapterWrap; -typedef boost::shared_ptr PeriodicStructureAdapterWrapPtr; +typedef std::shared_ptr PeriodicStructureAdapterWrapPtr; python::tuple periodicadapter_getlatpar(const PeriodicStructureAdapter& adpt) { @@ -471,7 +471,7 @@ python::tuple periodicadapter_getlatpar(const PeriodicStructureAdapter& adpt) // Wrapper helpers for class CrystalStructureAdapter typedef MakeWrapper CrystalStructureAdapterWrap; -typedef boost::shared_ptr CrystalStructureAdapterWrapPtr; +typedef std::shared_ptr CrystalStructureAdapterWrapPtr; double crystaladapter_getsymmetryprecision(const CrystalStructureAdapter& adpt) diff --git a/src/extensions/wrap_StructureAdapter.cpp b/src/extensions/wrap_StructureAdapter.cpp index 7a1a60c..170737f 100644 --- a/src/extensions/wrap_StructureAdapter.cpp +++ b/src/extensions/wrap_StructureAdapter.cpp @@ -446,7 +446,7 @@ class StructureProxyPickleSuite : public boost::python::pickle_suite diffpy::srreal::StructureAdapterPtr adpt) { using namespace boost; - shared_ptr tadpt = dynamic_pointer_cast(adpt); + std::shared_ptr tadpt = std::dynamic_pointer_cast(adpt); StructureAdapterPtr srcadpt = tadpt->getSourceStructure(); python::tuple rv = python::make_tuple(srcadpt); return rv; @@ -540,7 +540,7 @@ void wrap_StructureAdapter() register_ptr_to_python(); implicitly_convertible(); - typedef boost::shared_ptr + typedef std::shared_ptr NoMetaStructureAdapterPtr; class_, NoMetaStructureAdapterPtr>( @@ -550,7 +550,7 @@ void wrap_StructureAdapter() .def_pickle(StructureProxyPickleSuite()) ; - typedef boost::shared_ptr + typedef std::shared_ptr NoSymmetryStructureAdapterPtr; class_, NoSymmetryStructureAdapterPtr>( diff --git a/tests/test_atomradiitable.py b/tests/test_atomradiitable.py index c69b6ed..83beedf 100644 --- a/tests/test_atomradiitable.py +++ b/tests/test_atomradiitable.py @@ -2,7 +2,6 @@ """Unit tests for the AtomRadiiTable class.""" - import pickle import unittest diff --git a/tests/test_attributes.py b/tests/test_attributes.py index 573ccf8..64800de 100644 --- a/tests/test_attributes.py +++ b/tests/test_attributes.py @@ -1,8 +1,6 @@ #!/usr/bin/env python -"""Unit tests for the wrapped diffpy::Attributes -""" - +"""Unit tests for the wrapped diffpy::Attributes""" import gc import unittest diff --git a/tests/test_bondcalculator.py b/tests/test_bondcalculator.py index 8dd39ad..508c748 100644 --- a/tests/test_bondcalculator.py +++ b/tests/test_bondcalculator.py @@ -2,7 +2,6 @@ """Unit tests for diffpy.srreal.bondcalculator.""" - import pickle import unittest diff --git a/tests/test_bvscalculator.py b/tests/test_bvscalculator.py index f15172f..6424dc9 100644 --- a/tests/test_bvscalculator.py +++ b/tests/test_bvscalculator.py @@ -2,7 +2,6 @@ """Unit tests for diffpy.srreal.bvscalculator.""" - import pickle import unittest diff --git a/tests/test_debyepdfcalculator.py b/tests/test_debyepdfcalculator.py index 7a41f66..140cab5 100644 --- a/tests/test_debyepdfcalculator.py +++ b/tests/test_debyepdfcalculator.py @@ -2,7 +2,6 @@ """Unit tests for pdfcalculator.py.""" - import pickle import unittest import warnings diff --git a/tests/test_overlapcalculator.py b/tests/test_overlapcalculator.py index 2010130..8c8c8f1 100644 --- a/tests/test_overlapcalculator.py +++ b/tests/test_overlapcalculator.py @@ -2,7 +2,6 @@ """Unit tests for diffpy.srreal.overlapcalculator.""" - import copy import pickle import unittest diff --git a/tests/test_parallel.py b/tests/test_parallel.py index b4b53b1..dae110b 100644 --- a/tests/test_parallel.py +++ b/tests/test_parallel.py @@ -2,7 +2,6 @@ """Unit tests for diffpy.srreal.parallel.""" - import multiprocessing import unittest diff --git a/tests/test_pdfbaseline.py b/tests/test_pdfbaseline.py index e9aff06..f5a992c 100644 --- a/tests/test_pdfbaseline.py +++ b/tests/test_pdfbaseline.py @@ -3,7 +3,6 @@ """Unit tests for the PDFBaseline class from diffpy.srreal.pdfcalculator.""" - import pickle import unittest diff --git a/tests/test_pdfcalcobjcryst.py b/tests/test_pdfcalcobjcryst.py index d0ef6da..37d54b3 100644 --- a/tests/test_pdfcalcobjcryst.py +++ b/tests/test_pdfcalcobjcryst.py @@ -2,7 +2,6 @@ """Unit tests for pdfcalculator.py on ObjCryst crystal structures.""" - import re import unittest diff --git a/tests/test_pdfcalculator.py b/tests/test_pdfcalculator.py index 28b3198..d6516b5 100644 --- a/tests/test_pdfcalculator.py +++ b/tests/test_pdfcalculator.py @@ -2,7 +2,6 @@ """Unit tests for diffpy.srreal.pdfcalculator.""" - import pickle import unittest diff --git a/tests/test_pdfenvelope.py b/tests/test_pdfenvelope.py index ff8d95a..51a1318 100644 --- a/tests/test_pdfenvelope.py +++ b/tests/test_pdfenvelope.py @@ -3,7 +3,6 @@ """Unit tests for the PDFEnvelope class from diffpy.srreal.pdfcalculator.""" - import pickle import unittest diff --git a/tests/test_peakprofile.py b/tests/test_peakprofile.py index dfc59ed..13aec50 100644 --- a/tests/test_peakprofile.py +++ b/tests/test_peakprofile.py @@ -3,7 +3,6 @@ """Unit tests for the PeakProfile classes from diffpy.srreal.peakprofile.""" - import pickle import unittest diff --git a/tests/test_peakwidthmodel.py b/tests/test_peakwidthmodel.py index 2b5bd85..b69c172 100644 --- a/tests/test_peakwidthmodel.py +++ b/tests/test_peakwidthmodel.py @@ -3,7 +3,6 @@ """Unit tests for the PeakWidthModel classes from diffpy.srreal.peakwidthmodel.""" - import pickle import unittest diff --git a/tests/test_scatteringfactortable.py b/tests/test_scatteringfactortable.py index 097d412..444a437 100644 --- a/tests/test_scatteringfactortable.py +++ b/tests/test_scatteringfactortable.py @@ -2,7 +2,6 @@ """Unit tests for diffpy.srreal.scatteringfactortable.""" - import pickle import unittest diff --git a/tests/test_sfaverage.py b/tests/test_sfaverage.py index bff8c80..d576bf5 100644 --- a/tests/test_sfaverage.py +++ b/tests/test_sfaverage.py @@ -2,7 +2,6 @@ """Unit tests for diffpy.srreal.sfaverage.""" - import unittest import numpy diff --git a/tests/test_structureadapter.py b/tests/test_structureadapter.py index 910faae..cd22528 100644 --- a/tests/test_structureadapter.py +++ b/tests/test_structureadapter.py @@ -2,7 +2,6 @@ """Unit tests for diffpy.srreal.structureadapter.""" - import pickle import unittest diff --git a/tests/testutils.py b/tests/testutils.py index cee8d01..3c14268 100644 --- a/tests/testutils.py +++ b/tests/testutils.py @@ -2,7 +2,6 @@ """Helper routines for running other unit tests.""" - import copy import pickle