From 518ff7dfd132dd28996f573b02452cc4197fd428 Mon Sep 17 00:00:00 2001 From: Tieqiong Zhang Date: Tue, 7 Jan 2025 21:43:40 -0500 Subject: [PATCH 1/4] style: using new pcmt --- .codecov.yml | 8 +- .github/ISSUE_TEMPLATE/release_checklist.md | 13 +- .../workflows/build-wheel-release-upload.yml | 2 +- .github/workflows/check-news-item.yml | 2 +- .pre-commit-config.yaml | 38 ++-- doc/source/examples/Ni_calculation.py | 3 +- doc/source/examples/Ni_refinement.py | 2 +- setup.py | 1 - src/diffpy/__init__.py | 1 - src/diffpy/pdffit2/__init__.py | 1 - src/diffpy/pdffit2/ipy_ext.py | 4 +- src/diffpy/pdffit2/output.py | 3 +- src/diffpy/pdffit2/pdffit.py | 179 +++++++++--------- src/diffpy/pdffit2/version.py | 1 - tests/test_exceptions.py | 142 +++++++------- tests/test_pdffit.py | 59 +++--- tests/test_phase_fractions.py | 3 +- tests/test_shape_factors.py | 17 +- tests/test_version.py | 6 +- 19 files changed, 247 insertions(+), 238 deletions(-) diff --git a/.codecov.yml b/.codecov.yml index 5a94096e..4af5eb24 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1,14 +1,14 @@ coverage: status: - project: # more options at https://docs.codecov.com/docs/commit-status + project: # more options at https://docs.codecov.com/docs/commit-status default: target: auto # use the coverage from the base commit, fail if coverage is lower - threshold: 0% # allow the coverage to drop by + threshold: 0% # allow the coverage to drop by comment: layout: " diff, flags, files" behavior: default require_changes: false - require_base: false # [true :: must have a base report to post] - require_head: false # [true :: must have a head report to post] + require_base: false # [true :: must have a base report to post] + require_head: false # [true :: must have a head report to post] hide_project_coverage: false # [true :: only show coverage on the git diff aka patch coverage] diff --git a/.github/ISSUE_TEMPLATE/release_checklist.md b/.github/ISSUE_TEMPLATE/release_checklist.md index ba1d40ce..f2df0e96 100644 --- a/.github/ISSUE_TEMPLATE/release_checklist.md +++ b/.github/ISSUE_TEMPLATE/release_checklist.md @@ -12,20 +12,21 @@ assignees: "" - [ ] All the badges on the README are passing. - [ ] License information is verified as correct. If you are unsure, please comment below. - [ ] Locally rendered documentation contains all appropriate pages, including API references (check no modules are - missing), tutorials, and other human written text is up-to-date with any changes in the code. + missing), tutorials, and other human written text is up-to-date with any changes in the code. - [ ] Installation instructions in the README, documentation and on the website (e.g., diffpy.org) are updated. - [ ] Successfully run any tutorial examples or do functional testing with the latest Python version. - [ ] Grammar and writing quality are checked (no typos). Please mention @sbillinge here when you are ready for PyPI/GitHub release. Include any additional comments necessary, such as version information and details about the pre-release here: -### PyPI/GitHub full-release preparation checklist: +### PyPI/GitHub full-release preparation checklist: + - [ ] Create a new conda environment and install the rc from pypi (`pip install =??`) - [ ] License information at Pypi is verified as correct. - [ ] Docs deployed successfully to `.github.io` - [ ] Successfully run all tests, tutorial examples or do functional testing -Please let @sbillinge know that all checks are done and package is ready for full release. +Please let @sbillinge know that all checks are done and package is ready for full release. ### conda-forge release preparation checklist: @@ -33,12 +34,12 @@ Please let @sbillinge know that all checks are done and package is ready for fu - [ ] Ensure that the full release has appeared on Pypi successfully - [ ] New package dependencies listed in `conda.txt` and `test.txt` are added to `meta.yaml` in the feedstock. -- [ ] Close any open issues on the feedstock. Reach out to @bobleesj if you have questions +- [ ] Close any open issues on the feedstock. Reach out to @bobleesj if you have questions - [ ] let @sbillinge and @bobleesj when this is ready ### Post-release checklist -- [ ] Run tutorial examples and conduct functional testing using the installation guide in the README. Attach screenshots/results as comments. -- [ ] Documentation (README, tutorials, API references, and websites) is deployed without broken links or missing figures. +- [ ] Run tutorial examples and conduct functional testing using the installation guide in the README. Attach screenshots/results as comments. +- [ ] Documentation (README, tutorials, API references, and websites) is deployed without broken links or missing figures. diff --git a/.github/workflows/build-wheel-release-upload.yml b/.github/workflows/build-wheel-release-upload.yml index 76aa3e49..c6ed1365 100644 --- a/.github/workflows/build-wheel-release-upload.yml +++ b/.github/workflows/build-wheel-release-upload.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: push: tags: - - '*' # Trigger on all tags initially, but tag and release privilege are verified in _build-wheel-release-upload.yml + - "*" # Trigger on all tags initially, but tag and release privilege are verified in _build-wheel-release-upload.yml jobs: release: diff --git a/.github/workflows/check-news-item.yml b/.github/workflows/check-news-item.yml index 7a766a5c..01849907 100644 --- a/.github/workflows/check-news-item.yml +++ b/.github/workflows/check-news-item.yml @@ -3,7 +3,7 @@ name: Check for News on: pull_request_target: branches: - - main + - main jobs: check-news-item: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9cf0556f..0e4a84d1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,14 @@ default_language_version: - python: python3 + python: python3 ci: - autofix_commit_msg: | - [pre-commit.ci] auto fixes from pre-commit hooks - autofix_prs: true - autoupdate_branch: 'pre-commit-autoupdate' - autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate' - autoupdate_schedule: monthly - skip: [no-commit-to-branch] - submodules: false + autofix_commit_msg: | + [pre-commit.ci] auto fixes from pre-commit hooks + autofix_prs: true + autoupdate_branch: "pre-commit-autoupdate" + autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate" + autoupdate_schedule: monthly + skip: [no-commit-to-branch] + submodules: false repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 @@ -47,6 +47,20 @@ repos: - repo: https://github.com/codespell-project/codespell rev: v2.3.0 hooks: - - id: codespell - additional_dependencies: - - tomli + - id: codespell + additional_dependencies: + - tomli + # prettier - multi formatter for .json, .yml, and .md files + - repo: https://github.com/pre-commit/mirrors-prettier + rev: f12edd9c7be1c20cfa42420fd0e6df71e42b51ea # frozen: v4.0.0-alpha.8 + hooks: + - id: prettier + additional_dependencies: + - "prettier@^3.2.4" + # docformatter - PEP 257 compliant docstring formatter + - repo: https://github.com/s-weigand/docformatter + rev: 5757c5190d95e5449f102ace83df92e7d3b06c6c + hooks: + - id: docformatter + additional_dependencies: [tomli] + args: [--in-place, --config, ./pyproject.toml] diff --git a/doc/source/examples/Ni_calculation.py b/doc/source/examples/Ni_calculation.py index dfd26adc..8aff35d1 100755 --- a/doc/source/examples/Ni_calculation.py +++ b/doc/source/examples/Ni_calculation.py @@ -1,7 +1,8 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +"""Calculate PDF of FCC nickel. -"""Calculate PDF of FCC nickel. Save data to Ni_calculation.cgr and plot it using matplotlib. +Save data to Ni_calculation.cgr and plot it using matplotlib. """ import matplotlib.pyplot as plt diff --git a/doc/source/examples/Ni_refinement.py b/doc/source/examples/Ni_refinement.py index 8c81cf1b..67d93a3a 100755 --- a/doc/source/examples/Ni_refinement.py +++ b/doc/source/examples/Ni_refinement.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- - """Perform simple refinement of Ni structure to the experimental x-ray PDF. + Save fitted curve, refined structure and results summary. """ diff --git a/setup.py b/setup.py index afe2a0c1..5a8b756d 100755 --- a/setup.py +++ b/setup.py @@ -1,7 +1,6 @@ #!/usr/bin/env python # Extensions script for diffpy.pdffit2 - """PDFfit2 - real space structure refinement engine Packages: diffpy.pdffit2 diff --git a/src/diffpy/__init__.py b/src/diffpy/__init__.py index e1ae0400..5b3ab1b5 100644 --- a/src/diffpy/__init__.py +++ b/src/diffpy/__init__.py @@ -14,7 +14,6 @@ # See LICENSE.rst for license information. # ############################################################################## - """diffpy - tools for structure analysis by diffraction. Blank namespace package for module diffpy.""" diff --git a/src/diffpy/pdffit2/__init__.py b/src/diffpy/pdffit2/__init__.py index 61af1f1d..dc8aec45 100644 --- a/src/diffpy/pdffit2/__init__.py +++ b/src/diffpy/pdffit2/__init__.py @@ -14,7 +14,6 @@ # See LICENSE.rst for license information. # ############################################################################## - """PDFfit2 - real space structure refinement program.""" # WARNING: Do NOT remove the isort: off/on comments in this file. diff --git a/src/diffpy/pdffit2/ipy_ext.py b/src/diffpy/pdffit2/ipy_ext.py index 4546967e..ac2b5475 100644 --- a/src/diffpy/pdffit2/ipy_ext.py +++ b/src/diffpy/pdffit2/ipy_ext.py @@ -1,7 +1,7 @@ #!/usr/bin/env python -"""This module defines functions within IPython session to simulate -the old pdffit2 interactive session. +"""This module defines functions within IPython session to simulate the old +pdffit2 interactive session. Usage: %load_ext diffpy.pdffit2.ipy_ext """ diff --git a/src/diffpy/pdffit2/output.py b/src/diffpy/pdffit2/output.py index 6d1247cf..f24c28e9 100644 --- a/src/diffpy/pdffit2/output.py +++ b/src/diffpy/pdffit2/output.py @@ -12,8 +12,8 @@ # See LICENSE.txt for license information. # ############################################################################## - """Take care of sending engine output to given file-like object. + The output file is stored in local module variable stdout. """ @@ -28,6 +28,7 @@ def redirect_stdout(dst): """Redirect PDFfit2 standard output to a file-like object dst. + The dst value is stored in module variable stdout. """ from diffpy.pdffit2.pdffit2 import redirect_stdout diff --git a/src/diffpy/pdffit2/pdffit.py b/src/diffpy/pdffit2/pdffit.py index 11f6f253..4d683a90 100644 --- a/src/diffpy/pdffit2/pdffit.py +++ b/src/diffpy/pdffit2/pdffit.py @@ -12,7 +12,6 @@ # See LICENSE.txt for license information. # ############################################################################## - """PdfFit class for fitting pdf data to a model.""" from __future__ import print_function @@ -119,12 +118,13 @@ class PdfFit(object): def _exportAll(self, namespace): """_exportAll(self, namespace) --> Export all 'public' class methods - into namespace. + into namespace. - This function allows for a module-level PdfFit object which doesn't have - to be referenced when calling a method. This function makes old (python) - scripts compatible with this class. At the top of the script, create a - pdffit object, and then call this method. Usually, namespace = locals(). + This function allows for a module-level PdfFit object which + doesn't have to be referenced when calling a method. This + function makes old (python) scripts compatible with this class. + At the top of the script, create a pdffit object, and then call + this method. Usually, namespace = locals(). """ # string aliases (var = "var") for a in itertools.chain(self.selalias, self.FCON, self.Sctp): @@ -186,8 +186,8 @@ def read_struct(self, struct): return def read_struct_string(self, struct, name=""): - """read_struct_string(struct, name = "") --> Read structure from - a string into memory. + """read_struct_string(struct, name = "") --> Read structure from a + string into memory. struct -- string containing the contents of the structure file name -- tag with which to label structure @@ -218,8 +218,8 @@ def read_data(self, data, stype, qmax, qdamp): return def read_data_string(self, data, stype, qmax, qdamp, name=""): - """read_data_string(data, stype, qmax, qdamp, name = "") --> Read - pdf data from a string into memory. + """read_data_string(data, stype, qmax, qdamp, name = "") --> Read pdf + data from a string into memory. data -- string containing the contents of the data file stype -- 'X' (xray) or 'N' (neutron) @@ -254,7 +254,7 @@ def read_data_lists(self, stype, qmax, qdamp, r_data, Gr_data, dGr_data=None, na return def pdfrange(self, iset, rmin, rmax): - """pdfrange(iset, rmin, rmax) --> Set the range of the fit. + """Pdfrange(iset, rmin, rmax) --> Set the range of the fit. iset -- data set to consider rmin -- minimum r-value of fit @@ -266,15 +266,15 @@ def pdfrange(self, iset, rmin, rmax): return def reset(self): - """reset() --> Clear all stored fit, structure, and parameter data.""" + """Reset() --> Clear all stored fit, structure, and parameter data.""" self.stru_files = [] self.data_files = [] pdffit2.reset(self._handle) return def alloc(self, stype, qmax, qdamp, rmin, rmax, bin): - """alloc(stype, qmax, qdamp, rmin, rmax, bin) --> Allocate space - for a PDF calculation. + """Alloc(stype, qmax, qdamp, rmin, rmax, bin) --> Allocate space for a + PDF calculation. The structure from which to calculate the PDF must first be imported with the read_struct() or read_struct_string() method. @@ -294,7 +294,7 @@ def alloc(self, stype, qmax, qdamp, rmin, rmax, bin): return def calc(self): - """calc() --> Calculate the PDF of the imported structure. + """Calc() --> Calculate the PDF of the imported structure. Space for the calculation must first be allocated with the alloc() method. @@ -309,7 +309,7 @@ def calc(self): return def refine(self, toler=0.00000001): - """refine(toler = 0.00000001) --> Fit the theory to the imported data. + """Refine(toler = 0.00000001) --> Fit the theory to the imported data. toler -- tolerance of the fit @@ -433,8 +433,8 @@ def get_structure(self, ip): return stru def save_struct(self, ip, fname): - """save_struct(ip, fname) --> Save structure resulting from fit - to file. + """save_struct(ip, fname) --> Save structure resulting from fit to + file. ip -- phase to save @@ -469,7 +469,7 @@ def show_struct(self, ip): return def constrain(self, var, par, fcon=None): - """constrain(var, par[, fcon]) --> Constrain a variable to a parameter. + """Constrain(var, par[, fcon]) --> Constrain a variable to a parameter. A variable can be constrained to a number or equation string. var -- variable to constrain, such as x(1) @@ -502,7 +502,7 @@ def constrain(self, var, par, fcon=None): return def setpar(self, par, val): - """setpar(par, val) --> Set value of constrained parameter. + """Setpar(par, val) --> Set value of constrained parameter. val -- Either a numerical value or a reference to a variable @@ -521,7 +521,7 @@ def setpar(self, par, val): return def setvar(self, var, val): - """setvar(var, val) --> Set the value of a variable. + """Setvar(var, val) --> Set the value of a variable. Raises: pdffit2.unassignedError if variable does not yet exist @@ -532,7 +532,7 @@ def setvar(self, var, val): return def getvar(self, var): - """getvar(var) --> Get stored value of a variable. + """Getvar(var) --> Get stored value of a variable. Raises: pdffit2.unassignedError if variable does not yet exist @@ -543,9 +543,10 @@ def getvar(self, var): return retval def getrw(self): - """getrw() --> Get normalized total error of the fit rw. + """Getrw() --> Get normalized total error of the fit rw. - getrw calculates total fit error summed for all datasets in the fit. + getrw calculates total fit error summed for all datasets in the + fit. Return float. """ @@ -553,7 +554,7 @@ def getrw(self): return rw def getcrw(self): - """getcrw() --> Get cumulative Rw for the current dataset. + """Getcrw() --> Get cumulative Rw for the current dataset. Cumulative Rw is a list of Rw partial sums cost values evaluated against observed PDF data in the error sums evaluated against @@ -568,7 +569,7 @@ def getcrw(self): return crw def getR(self): - """getR() --> Get r-points used in the fit. + """GetR() --> Get r-points used in the fit. This function should only be called after data has been loaded or calculated. Before a refinement, the list of r-points will reflect the @@ -641,7 +642,8 @@ def get_atoms(self, ip=None): return rv def get_atom_types(self, ip=None): - """get_atom_types() --> Ordered unique element symbols in the structure. + """get_atom_types() --> Ordered unique element symbols in the + structure. ip -- index of phase to get the elements from (starting from 1) when ip is not given, use current phase @@ -660,14 +662,14 @@ def get_atom_types(self, ip=None): return rv def getpar(self, par): - """getpar(par) --> Get value of parameter. + """Getpar(par) --> Get value of parameter. Raises: ValueError if parameter does not exists """ return pdffit2.getpar(self._handle, par) def fixpar(self, par): - """fixpar(par) --> Fix a parameter. + """Fixpar(par) --> Fix a parameter. Fixed parameters are not fitted in a refinement. Passed parameter can be 'ALL', in which case all parameters are fixed. @@ -680,7 +682,7 @@ def fixpar(self, par): return def freepar(self, par): - """freepar(par) --> Free a parameter. + """Freepar(par) --> Free a parameter. Freed parameters are fitted in a refinement. Passed parameter can be 'ALL', in which case all parameters are freed. @@ -693,7 +695,7 @@ def freepar(self, par): return def setphase(self, ip): - """setphase(ip) --> Switch to phase ip. + """Setphase(ip) --> Switch to phase ip. ip -- index of the phase starting at 1. @@ -706,7 +708,7 @@ def setphase(self, ip): return def setdata(self, iset): - """setdata(iset) --> Set the data set in focus. + """Setdata(iset) --> Set the data set in focus. iset -- integer index of data set starting at 1. @@ -716,7 +718,7 @@ def setdata(self, iset): return def psel(self, ip): - """psel(ip) --> Include phase ip in calculation of total PDF + """Psel(ip) --> Include phase ip in calculation of total PDF. psel('ALL') selects all phases for PDF calculation. @@ -728,7 +730,7 @@ def psel(self, ip): return def pdesel(self, ip): - """pdesel(ip) --> Exclude phase ip from calculation of total PDF. + """Pdesel(ip) --> Exclude phase ip from calculation of total PDF. pdesel('ALL') excludes all phases from PDF calculation. @@ -802,7 +804,7 @@ def selectNone(self, ip, ijchar): return def bang(self, i, j, k): - """bang(i, j, k) --> Show bond angle defined by atoms i, j, k. + """Bang(i, j, k) --> Show bond angle defined by atoms i, j, k. No return value. Use bond_angle() to get the result. @@ -825,9 +827,9 @@ def bang(self, i, j, k): return def bond_angle(self, i, j, k): - """bond_angle(i, j, k) --> bond angle defined by atoms i, j, k. - Angle is calculated using the shortest ji and jk lengths with - respect to periodic boundary conditions. + """bond_angle(i, j, k) --> bond angle defined by atoms i, j, k. Angle + is calculated using the shortest ji and jk lengths with respect to + periodic boundary conditions. i, j, k -- atom indices starting at 1 @@ -840,7 +842,7 @@ def bond_angle(self, i, j, k): return rv def blen(self, *args): - """blen(i, j) --> Show bond length defined by atoms i and j. + """Blen(i, j) --> Show bond length defined by atoms i and j. i -- index of the first atom starting at 1 j -- index of the second atom starting at 1 @@ -942,8 +944,8 @@ def bond_length_types(self, a1, a2, lb, ub): return rv def show_scat(self, stype): - """show_scat(stype) --> Print scattering length for all atoms in - the current phase. + """show_scat(stype) --> Print scattering length for all atoms in the + current phase. stype -- 'X' (xray) or 'N' (neutron). @@ -953,8 +955,8 @@ def show_scat(self, stype): return def get_scat_string(self, stype): - """get_scat_string(stype) --> Get string with scattering factors - of all atoms in the current phase. + """get_scat_string(stype) --> Get string with scattering factors of all + atoms in the current phase. stype -- 'X' (xray) or 'N' (neutron). @@ -966,10 +968,10 @@ def get_scat_string(self, stype): return pdffit2.get_scat_string(self._handle, six.b(stype)) def get_scat(self, stype, element): - """get_scat(stype, element) --> Get active scattering factor for - given element. If scattering factor has been changed using - set_scat the result may depend on the active phase. When no - phase has been loaded, return the standard value. + """get_scat(stype, element) --> Get active scattering factor for given + element. If scattering factor has been changed using set_scat the + result may depend on the active phase. When no phase has been loaded, + return the standard value. stype -- 'X' (xray) or 'N' (neutron). element -- case-insensitive element symbol such as "Na" or "CL" @@ -983,9 +985,9 @@ def get_scat(self, stype, element): return rv def set_scat(self, stype, element, value): - """set_scat(stype, element, value) --> Set custom scattering factor - for given element. The new scattering factor applies only for the - current phase, in other phases it keeps its default value. + """set_scat(stype, element, value) --> Set custom scattering factor for + given element. The new scattering factor applies only for the current + phase, in other phases it keeps its default value. stype -- 'X' (xray) or 'N' (neutron). element -- case-insensitive element symbol such as "Na" or "CL" @@ -1003,9 +1005,9 @@ def set_scat(self, stype, element, value): return def reset_scat(self, element): - """reset_scat(stype, element) --> Reset scattering factors for - given element to their standard values. The reset_scat applies - only for the current phase. + """reset_scat(stype, element) --> Reset scattering factors for given + element to their standard values. The reset_scat applies only for the + current phase. element -- case-insensitive element symbol such as "Na" or "CL" Raises: @@ -1063,15 +1065,11 @@ def phase_fractions(self): # Begin refinable variables. def lat(n): - """lat(n) --> Get reference to lattice variable n. + """Lat(n) --> Get reference to lattice variable n. - n can be an integer or a string representing the lattice variable. - 1 <==> 'a' - 2 <==> 'b' - 3 <==> 'c' - 4 <==> 'alpha' - 5 <==> 'beta' - 6 <==> 'gamma' + n can be an integer or a string representing the lattice + variable. 1 <==> 'a' 2 <==> 'b' 3 <==> 'c' 4 <==> 'alpha' 5 <==> + 'beta' 6 <==> 'gamma' """ LatParams = {"a": 1, "b": 2, "c": 3, "alpha": 4, "beta": 5, "gamma": 6} if isinstance(n, six.string_types): @@ -1081,25 +1079,25 @@ def lat(n): lat = staticmethod(lat) def x(i): - """x(i) --> Get reference to x-value of atom i.""" + """X(i) --> Get reference to x-value of atom i.""" return "x(%i)" % i x = staticmethod(x) def y(i): - """y(i) --> Get reference to y-value of atom i.""" + """Y(i) --> Get reference to y-value of atom i.""" return "y(%i)" % i y = staticmethod(y) def z(i): - """z(i) --> Get reference to z-value of atom i.""" + """Z(i) --> Get reference to z-value of atom i.""" return "z(%i)" % i z = staticmethod(z) def u11(i): - """u11(i) --> Get reference to U(1,1) for atom i. + """U11(i) --> Get reference to U(1,1) for atom i. U is the anisotropic thermal factor tensor. """ @@ -1108,7 +1106,7 @@ def u11(i): u11 = staticmethod(u11) def u22(i): - """u22(i) --> Get reference to U(2,2) for atom i. + """U22(i) --> Get reference to U(2,2) for atom i. U is the anisotropic thermal factor tensor. """ @@ -1117,7 +1115,7 @@ def u22(i): u22 = staticmethod(u22) def u33(i): - """u33(i) --> Get reference to U(3,3) for atom i. + """U33(i) --> Get reference to U(3,3) for atom i. U is the anisotropic thermal factor tensor. """ @@ -1126,7 +1124,7 @@ def u33(i): u33 = staticmethod(u33) def u12(i): - """u12(i) --> Get reference to U(1,2) for atom i. + """U12(i) --> Get reference to U(1,2) for atom i. U is the anisotropic thermal factor tensor. """ @@ -1135,7 +1133,7 @@ def u12(i): u12 = staticmethod(u12) def u13(i): - """u13(i) --> Get reference to U(1,3) for atom i. + """U13(i) --> Get reference to U(1,3) for atom i. U is the anisotropic thermal factor tensor. """ @@ -1144,7 +1142,7 @@ def u13(i): u13 = staticmethod(u13) def u23(i): - """u23(i) --> Get reference to U(2,3) for atom i. + """U23(i) --> Get reference to U(2,3) for atom i. U is the anisotropic thermal factor tensor. """ @@ -1153,48 +1151,49 @@ def u23(i): u23 = staticmethod(u23) def occ(i): - """occ(i) --> Get reference to occupancy of atom i.""" + """Occ(i) --> Get reference to occupancy of atom i.""" return "occ(%i)" % i occ = staticmethod(occ) def pscale(): - """pscale() --> Get reference to pscale. + """Pscale() --> Get reference to pscale. - pscale is the fraction of the total structure that the current phase - represents. + pscale is the fraction of the total structure that the current + phase represents. """ return "pscale" pscale = staticmethod(pscale) def sratio(): - """sratio() --> Get reference to sigma ratio. + """Sratio() --> Get reference to sigma ratio. - The sigma ratio determines the reduction in the Debye-Waller factor for - distances below rcut. + The sigma ratio determines the reduction in the Debye-Waller + factor for distances below rcut. """ return "sratio" sratio = staticmethod(sratio) def delta1(): - """delta1() --> Get reference to 1/R peak sharpening factor.""" + """Delta1() --> Get reference to 1/R peak sharpening factor.""" return "delta1" delta1 = staticmethod(delta1) def delta2(): - """delta2() --> Reference to (1/R^2) sharpening factor. - The phenomenological correlation constant in the Debye-Waller factor. - The (1/R^2) peak sharpening factor. + """Delta2() --> Reference to (1/R^2) sharpening factor. + + The phenomenological correlation constant in the Debye-Waller + factor. The (1/R^2) peak sharpening factor. """ return "delta2" delta2 = staticmethod(delta2) def dscale(): - """dscale() --> Get reference to dscale. + """Dscale() --> Get reference to dscale. The data scale factor. """ @@ -1203,7 +1202,7 @@ def dscale(): dscale = staticmethod(dscale) def qdamp(): - """qdamp() --> Get reference to qdamp. + """Qdamp() --> Get reference to qdamp. Qdamp controls PDF damping due to instrument Q-resolution. """ @@ -1212,7 +1211,7 @@ def qdamp(): qdamp = staticmethod(qdamp) def qbroad(): - """qbroad() --> Get reference to qbroad. + """Qbroad() --> Get reference to qbroad. Quadratic peak broadening factor. """ @@ -1221,7 +1220,7 @@ def qbroad(): qbroad = staticmethod(qbroad) def spdiameter(): - """spdiameter() --> Get reference to spdiameter (phase property). + """Spdiameter() --> Get reference to spdiameter (phase property). Diameter value for the spherical particle PDF correction. Spherical envelope is not applied when spdiameter equals 0. @@ -1231,11 +1230,11 @@ def spdiameter(): spdiameter = staticmethod(spdiameter) def stepcut(): - """stepcut() --> Get reference to stepcut (phase property). + """Stepcut() --> Get reference to stepcut (phase property). - stepcut is cutoff radius for empirical step-function PDF envelope. - stepcut can be used to approximate loss of pair correlations - in amorphous phase. stepcut cannot be refined. + stepcut is cutoff radius for empirical step-function PDF + envelope. stepcut can be used to approximate loss of pair + correlations in amorphous phase. stepcut cannot be refined. Step cutoff is not applied when stepcut equals 0. """ @@ -1244,7 +1243,7 @@ def stepcut(): stepcut = staticmethod(stepcut) def rcut(): - """rcut() --> Get reference to rcut. + """Rcut() --> Get reference to rcut. rcut is the value of r below which peak sharpening, defined by the sigma ratio (sratio), applies. rcut cannot be refined. diff --git a/src/diffpy/pdffit2/version.py b/src/diffpy/pdffit2/version.py index 60d34a97..2ed4ab87 100644 --- a/src/diffpy/pdffit2/version.py +++ b/src/diffpy/pdffit2/version.py @@ -12,7 +12,6 @@ # See LICENSE.rst for license information. # ############################################################################## - """Definition of __version__.""" # We do not use the other three variables, but can be added back if needed. diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index f2f245ce..012b76d3 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -33,15 +33,15 @@ def tearDown(self): del self.P def test_IOError(self): - """raise IOError when structure file does not exist""" + """Raise IOError when structure file does not exist.""" self.assertRaises(IOError, self.P.read_struct, "Nofile.stru") def test_structureError(self): - """raise pdffit2.structureError when structure is malformed""" + """Raise pdffit2.structureError when structure is malformed.""" self.assertRaises(pdffit2.structureError, self.P.read_struct, self.datafile("badNi.stru")) def test_structureErrorZeroVolume(self): - """raise pdffit2.structureError when unit cell volume is negative""" + """Raise pdffit2.structureError when unit cell volume is negative.""" # I don't know how to test for this, but it's in the library code self.assertRaises(pdffit2.structureError, self.P.read_struct, self.datafile("badNiZeroVolume.stru")) @@ -58,11 +58,11 @@ def tearDown(self): del self.P def test_IOError(self): - """raise IOError when data file does not exist""" + """Raise IOError when data file does not exist.""" self.assertRaises(IOError, self.P.read_data, "Nofile.dat", "X", 25.0, 0.5) def test_dataError(self): - """raise pdffit2.dataError when data has improper spacing""" + """Raise pdffit2.dataError when data has improper spacing.""" self.assertRaises(pdffit2.dataError, self.P.read_data, self.datafile("badNi.dat"), "X", 25.0, 0.5) @@ -82,25 +82,25 @@ def tearDown(self): del self.P def test_ValueError1(self): - """raise ValueError when lists are of different length""" + """Raise ValueError when lists are of different length.""" self.assertRaises( ValueError, self.P.read_data_lists, "X", self.qmax, self.qdamp, self.r_data, self.Gr_data ) def test_ValueError2(self): - """raise ValueError when qmax < 0""" + """Raise ValueError when qmax < 0.""" self.assertRaises( ValueError, self.P.read_data_lists, "X", -self.qmax, self.qdamp, self.r_data, self.Gr_data ) def test_ValueError3(self): - """raise ValueError when qdamp < 0""" + """Raise ValueError when qdamp < 0.""" self.assertRaises( ValueError, self.P.read_data_lists, "X", self.qmax, -self.qdamp, self.r_data, self.Gr_data ) def test_dataError(self): - """raise pdffit2.dataError when data has improper spacing""" + """Raise pdffit2.dataError when data has improper spacing.""" r_data = [0.1, 0.52, 0.2] self.assertRaises( pdffit2.dataError, self.P.read_data_lists, "X", self.qmax, self.qdamp, r_data, self.Gr_data @@ -122,16 +122,16 @@ def tearDown(self): del self.P def test_ValueError1(self): - """raise ValueError when iset does not exist""" + """Raise ValueError when iset does not exist.""" self.assertRaises(ValueError, self.P.pdfrange, self.iset, self.rmin, self.rmax) def test_ValueError2(self): - """raise ValueError when rmax < rmin""" + """Raise ValueError when rmax < rmin.""" self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.5) self.assertRaises(ValueError, self.P.pdfrange, self.iset, self.rmax, self.rmin) def test_ValueError3(self): - """raise ValueError when range outside of data""" + """Raise ValueError when range outside of data.""" self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.5) self.assertRaises(ValueError, self.P.pdfrange, self.iset, -self.rmin, self.rmax) @@ -153,37 +153,37 @@ def tearDown(self): del self.P def test_ValueError1(self): - """raise ValueError when qmax < 0""" + """Raise ValueError when qmax < 0.""" self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.alloc, "X", -self.qmax, self.qdamp, self.rmin, self.rmax, self.bin) def test_ValueError2(self): - """raise ValueError when qdamp < 0""" + """Raise ValueError when qdamp < 0.""" self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.alloc, "X", self.qmax, -self.qdamp, self.rmin, self.rmax, self.bin) def test_ValueError3(self): - """raise ValueError when rmin < 0""" + """Raise ValueError when rmin < 0.""" self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.alloc, "X", self.qmax, self.qdamp, -self.rmin, self.rmax, self.bin) def test_ValueError4(self): - """raise ValueError when rmax < 0""" + """Raise ValueError when rmax < 0.""" self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.alloc, "X", self.qmax, self.qdamp, self.rmin, -self.rmax, self.bin) def test_ValueError5(self): - """raise ValueError when bin < 0""" + """Raise ValueError when bin < 0.""" self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.alloc, "X", self.qmax, self.qdamp, self.rmin, self.rmax, -self.bin) def test_ValueError6(self): - """raise ValueError when rmax < rmin""" + """Raise ValueError when rmax < rmin.""" self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.alloc, "X", self.qmax, self.qdamp, self.rmax, self.rmin, self.bin) def test_ValueError7(self): - """raise ValueError when qdamp < 0""" + """Raise ValueError when qdamp < 0.""" self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.alloc, "X", self.qmax, self.qdamp, self.rmin, self.rmax, -self.bin) @@ -201,7 +201,7 @@ def tearDown(self): del self.P def test_unassignedError(self): - """raise pdffit2.unassignedError when no space has been allocated""" + """Raise pdffit2.unassignedError when no space has been allocated.""" self.assertRaises(pdffit2.unassignedError, self.P.calc) @@ -261,14 +261,14 @@ def tearDown(self): del self.P def test_IOError(self): - """raise IOError when structure cannot be saved""" + """Raise IOError when structure cannot be saved.""" self.P.read_struct(self.datafile("Ni.stru")) self.P.alloc("X", 30.0, 0.05, 2, 10, 100) self.P.calc() self.assertRaises(IOError, self.P.save_pdf, 1, "nodir183160/" + self.strufile) def test_unassignedError(self): - """raise pdffit2.unassignedError when structure is undefined""" + """Raise pdffit2.unassignedError when structure is undefined.""" self.assertRaises(pdffit2.unassignedError, self.P.save_pdf, 1, self.strufile) @@ -285,7 +285,7 @@ def tearDown(self): del self.P def test_IOError(self): - """raise IOError when dif cannot be saved""" + """Raise IOError when dif cannot be saved.""" self.P.read_struct(self.datafile("Ni.stru")) self.P.alloc("X", 30.0, 0.05, 2, 10, 100) self.P.calc() @@ -293,7 +293,7 @@ def test_IOError(self): self.assertRaises(IOError, self.P.save_dif, 1, "nodir183160/" + self.strufile) def test_unassignedError(self): - """raise pdffit2.unassignedError when structure is undefined""" + """Raise pdffit2.unassignedError when structure is undefined.""" self.assertRaises(pdffit2.unassignedError, self.P.save_dif, 1, self.strufile) @@ -310,7 +310,7 @@ def tearDown(self): del self.P def test_IOError(self): - """raise IOError when residual file cannot be saved""" + """Raise IOError when residual file cannot be saved.""" self.P.read_struct(self.datafile("Ni.stru")) self.P.read_data(self.datafile("Ni.dat"), "X", 30.0, 0.0) self.P.constrain(self.P.lat(1), 1) @@ -320,7 +320,7 @@ def test_IOError(self): self.assertRaises(IOError, self.P.save_res, "nodir183160/" + self.resfile) def test_unassignedError(self): - """raise pdffit2.unassignedError when structure is undefined""" + """Raise pdffit2.unassignedError when structure is undefined.""" self.assertRaises(pdffit2.unassignedError, self.P.save_res, self.resfile) @@ -339,12 +339,12 @@ def tearDown(self): del self.P def test_IOError(self): - """raise IOError when structure cannot be saved""" + """Raise IOError when structure cannot be saved.""" self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(IOError, self.P.save_struct, 1, "nodir183160/" + self.strufile) def test_unassignedError(self): - """raise pdffit2.unassignedError when structure is undefined""" + """Raise pdffit2.unassignedError when structure is undefined.""" self.assertRaises(pdffit2.unassignedError, self.P.save_struct, 1, self.strufile) @@ -363,7 +363,7 @@ def tearDown(self): return def test_constraintError(self): - """raise constraintError when constraint is bad""" + """Raise constraintError when constraint is bad.""" self.P.read_struct(self.datafile("Ni.stru")) self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.P.constrain("x(1)", "junk+@1") @@ -373,12 +373,12 @@ def test_constraintError(self): return def test_unassignedError(self): - """raise pdffit2.unassignedError when variable is undefined""" + """Raise pdffit2.unassignedError when variable is undefined.""" self.assertRaises(pdffit2.unassignedError, self.P.constrain, self.P.x(1), self.par) return def test_ValueError(self): - """raise ValueError when a variable index does not exist""" + """Raise ValueError when a variable index does not exist.""" self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.constrain, self.P.x(6), self.par) return @@ -406,11 +406,11 @@ def tearDown(self): del self.P def test_unassignedError(self): - """raise pdffit2.unassignedError when variable is undefined""" + """Raise pdffit2.unassignedError when variable is undefined.""" self.assertRaises(pdffit2.unassignedError, self.P.setvar, self.P.lat(1), self.val) def test_ValueError(self): - """raise ValueError when a variable index does not exist""" + """Raise ValueError when a variable index does not exist.""" self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.setvar, self.P.lat(7), self.val) @@ -427,11 +427,11 @@ def tearDown(self): del self.P def test_unassignedError(self): - """raise pdffit2.unassignedError when variable is undefined""" + """Raise pdffit2.unassignedError when variable is undefined.""" self.assertRaises(pdffit2.unassignedError, self.P.getvar, self.P.pscale()) def test_ValueError(self): - """raise ValueError when a variable index does not exist""" + """Raise ValueError when a variable index does not exist.""" self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.getvar, self.P.lat(7)) @@ -444,7 +444,7 @@ def tearDown(self): del self.P def test_unassignedError(self): - """raise pdffit2.unassignedError when data does not exist""" + """Raise pdffit2.unassignedError when data does not exist.""" self.assertRaises(pdffit2.unassignedError, self.P.getR) @@ -456,7 +456,7 @@ def tearDown(self): del self.P def test_unassignedError(self): - """raise pdffit2.unassignedError when data does not exist""" + """Raise pdffit2.unassignedError when data does not exist.""" self.assertRaises(pdffit2.unassignedError, self.P.getpdf_fit) @@ -468,7 +468,7 @@ def tearDown(self): del self.P def test_unassignedError(self): - """raise pdffit2.unassignedError when data does not exist""" + """Raise pdffit2.unassignedError when data does not exist.""" self.assertRaises(pdffit2.unassignedError, self.P.getpdf_obs) @@ -480,7 +480,7 @@ def tearDown(self): del self.P def test_unassignedError(self): - """raise pdffit2.unassignedError when data does not exist""" + """Raise pdffit2.unassignedError when data does not exist.""" self.assertRaises(pdffit2.unassignedError, self.P.getpdf_diff) @@ -492,7 +492,7 @@ def tearDown(self): del self.P def test_unassignedError(self): - """raise pdffit2.unassignedError when data does not exist""" + """Raise pdffit2.unassignedError when data does not exist.""" self.assertRaises(pdffit2.unassignedError, self.P.get_atoms) @@ -508,11 +508,11 @@ def tearDown(self): del self.P def test_unassignedError1(self): - """raise pdffit2.unassignedError when parameter does not exist""" + """Raise pdffit2.unassignedError when parameter does not exist.""" self.assertRaises(pdffit2.unassignedError, self.P.getpar, 1) def test_unassignedError2(self): - """raise pdffit2.unassignedError when parameter does not exist""" + """Raise pdffit2.unassignedError when parameter does not exist.""" self.P.read_struct(self.datafile("Ni.stru")) self.P.constrain(self.P.lat(1), 2) self.assertRaises(pdffit2.unassignedError, self.P.getpar, 1) @@ -527,11 +527,11 @@ def tearDown(self): del self.P def test_unassignedError(self): - """raise pdffit2.unassignedError when phase does not exist""" + """Raise pdffit2.unassignedError when phase does not exist.""" self.assertRaises(pdffit2.unassignedError, self.P.pdesel, self.ip) def test_unassignedError2(self): - """raise pdffit2.unassignedError when phase does not exist""" + """Raise pdffit2.unassignedError when phase does not exist.""" self.assertRaises(pdffit2.unassignedError, self.P.pdesel, self.ip) @@ -548,11 +548,11 @@ def tearDown(self): del self.P def test_unassignedError1(self): - """raise pdffit2.unassignedError when phase does not exist""" + """Raise pdffit2.unassignedError when phase does not exist.""" self.assertRaises(pdffit2.unassignedError, self.P.pdesel, self.ip) def test_unassignedError2(self): - """raise pdffit2.unassignedError when phase does not exist""" + """Raise pdffit2.unassignedError when phase does not exist.""" self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(pdffit2.unassignedError, self.P.pdesel, self.ip) @@ -571,11 +571,11 @@ def tearDown(self): del self.P def test_unassignedError1(self): - """raise pdffit2.unassignedError when set does not exist""" + """Raise pdffit2.unassignedError when set does not exist.""" self.assertRaises(pdffit2.unassignedError, self.P.selectAtomType, self.iset, "i", "Ni", True) def test_unassignedError2(self): - """raise pdffit2.unassignedError when set does not exist""" + """Raise pdffit2.unassignedError when set does not exist.""" self.P.read_struct(self.datafile("Ni.stru")) # selectAtomType should pass with one phase defined self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) @@ -585,7 +585,7 @@ def test_unassignedError2(self): self.assertRaises(pdffit2.unassignedError, self.P.selectAtomType, 2, "i", "Ca", True) def test_ijcharValueError(self): - """raise ValueError when ijchar is neither 'i' nor 'j'""" + """Raise ValueError when ijchar is neither 'i' nor 'j'.""" self.P.read_struct(self.datafile("Ni.stru")) self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.P.selectAtomType(self.iset, "i", "Ni", True) @@ -607,11 +607,11 @@ def tearDown(self): del self.P def test_unassignedError1(self): - """raise pdffit2.unassignedError when set does not exist""" + """Raise pdffit2.unassignedError when set does not exist.""" self.assertRaises(pdffit2.unassignedError, self.P.selectAtomIndex, self.iset, "i", self.i, True) def test_unassignedError2(self): - """raise pdffit2.unassignedError when set does not exist""" + """Raise pdffit2.unassignedError when set does not exist.""" self.P.read_struct(self.datafile("Ni.stru")) # pass for phase 1 self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) @@ -621,7 +621,7 @@ def test_unassignedError2(self): self.assertRaises(pdffit2.unassignedError, self.P.selectAtomIndex, 2, "i", 1, True) def test_ValueError(self): - """raise ValueError when selected atom does not exist""" + """Raise ValueError when selected atom does not exist.""" self.P.read_struct(self.datafile("Ni.stru")) self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.assertRaises(ValueError, self.P.selectAtomIndex, self.iset, "i", 6, True) @@ -641,11 +641,11 @@ def tearDown(self): del self.P def test_unassignedError1(self): - """raise pdffit2.unassignedError when set does not exist""" + """Raise pdffit2.unassignedError when set does not exist.""" self.assertRaises(pdffit2.unassignedError, self.P.selectAll, self.iset, "i") def test_unassignedError2(self): - """raise pdffit2.unassignedError when set does not exist""" + """Raise pdffit2.unassignedError when set does not exist.""" self.P.read_struct(self.datafile("Ni.stru")) # fail when there is no dataset self.assertRaises(pdffit2.unassignedError, self.P.selectAll, self.iset, "i") @@ -672,11 +672,11 @@ def tearDown(self): del self.P def test_unassignedError1(self): - """raise pdffit2.unassignedError when set does not exist""" + """Raise pdffit2.unassignedError when set does not exist.""" self.assertRaises(pdffit2.unassignedError, self.P.selectNone, self.iset, "i") def test_unassignedError2(self): - """raise pdffit2.unassignedError when set does not exist""" + """Raise pdffit2.unassignedError when set does not exist.""" self.P.read_struct(self.datafile("Ni.stru")) # fail when there is no dataset self.assertRaises(pdffit2.unassignedError, self.P.selectNone, self.iset, "i") @@ -704,22 +704,22 @@ def tearDown(self): del self.P def test_unassignedError(self): - """raise pdffit2.unassignedError when phase does not exist""" + """Raise pdffit2.unassignedError when phase does not exist.""" self.assertRaises(pdffit2.unassignedError, self.P.bang, self.a1, self.a2, self.a3) def test_ValueError1(self): - """raise ValueError when selected atom(s) does not exist""" + """Raise ValueError when selected atom(s) does not exist.""" self.P.read_struct(self.datafile("Ni.stru")) self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.assertRaises(ValueError, self.P.bang, 0, self.a2, self.a3) def test_ValueError2(self): - """raise ValueError when selected atom(s) does not exist""" + """Raise ValueError when selected atom(s) does not exist.""" self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.bang, self.a1, -1, self.a3) def test_ValueError3(self): - """raise ValueError when selected atom(s) does not exist""" + """Raise ValueError when selected atom(s) does not exist.""" self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.bang, self.a1, self.a2, 6) @@ -738,21 +738,21 @@ def tearDown(self): del self.P def test_unassignedError(self): - """raise pdffit2.unassignedError when no data exists""" + """Raise pdffit2.unassignedError when no data exists.""" self.assertRaises(pdffit2.unassignedError, self.P.blen, self.a1, self.a2) def test_ValueError1(self): - """raise ValueError when selected atom(s) does not exist""" + """Raise ValueError when selected atom(s) does not exist.""" self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.blen, 0, self.a2) def test_ValueError2(self): - """raise ValueError when selected atom(s) does not exist""" + """Raise ValueError when selected atom(s) does not exist.""" self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.blen, self.a1, 6) def test_ValueError3(self): - """raise ValueError when selected atom(s) does not exist""" + """Raise ValueError when selected atom(s) does not exist.""" self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.blen, 0, 6) @@ -765,7 +765,7 @@ def tearDown(self): del self.P def test_unassignedError(self): - """raise pdffit2.unassignedError when phase does not exist""" + """Raise pdffit2.unassignedError when phase does not exist.""" self.assertRaises(pdffit2.unassignedError, self.P.show_scat, "X") @@ -796,7 +796,7 @@ def tearDown(self): del self.P def test_unassignedError(self): - """raise pdffit2.unassignedError when no atoms exist""" + """Raise pdffit2.unassignedError when no atoms exist.""" self.assertRaises(pdffit2.unassignedError, self.P.num_atoms) @@ -812,7 +812,7 @@ def tearDown(self): del self.P def test_unassignedError(self): - """raise pdffit2.unassignedError when parameter does not exist""" + """Raise pdffit2.unassignedError when parameter does not exist.""" self.P.read_struct(self.datafile("Ni.stru")) self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.assertRaises(pdffit2.unassignedError, self.P.fixpar, 1) @@ -830,7 +830,7 @@ def tearDown(self): del self.P def test_unassignedError(self): - """raise pdffit2.unassignedError when parameter does not exist""" + """Raise pdffit2.unassignedError when parameter does not exist.""" self.P.read_struct(self.datafile("Ni.stru")) self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.assertRaises(pdffit2.unassignedError, self.P.freepar, 1) @@ -848,7 +848,7 @@ def tearDown(self): del self.P def test_unassignedError(self): - """raise pdffit2.unassignedError when phase does not exist""" + """Raise pdffit2.unassignedError when phase does not exist.""" self.P.read_struct(self.datafile("Ni.stru")) self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.assertRaises(pdffit2.unassignedError, self.P.setphase, 2) @@ -866,7 +866,7 @@ def tearDown(self): del self.P def test_unassignedError(self): - """raise pdffit2.unassignedError when data set does not exist""" + """Raise pdffit2.unassignedError when data set does not exist.""" self.P.read_struct(self.datafile("Ni.stru")) self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.assertRaises(pdffit2.unassignedError, self.P.setdata, 2) @@ -880,7 +880,7 @@ def tearDown(self): del self.P def test_unassignedError(self): - """raise pdffit2.unassignedError when data does not exist""" + """Raise pdffit2.unassignedError when data does not exist.""" self.assertRaises(pdffit2.unassignedError, self.P.getcrw) diff --git a/tests/test_pdffit.py b/tests/test_pdffit.py index 68c06833..508f29f5 100644 --- a/tests/test_pdffit.py +++ b/tests/test_pdffit.py @@ -1,7 +1,6 @@ #!/usr/bin/env python -"""Unit tests for PdfFit.py -""" +"""Unit tests for PdfFit.py.""" import unittest @@ -47,7 +46,7 @@ def test__exportAll(self): # return def test_add_structure(self): - """check PdfFit.add_structure()""" + """Check PdfFit.add_structure()""" ni = loadStructure(self.datafile("Ni.stru")) self.P.add_structure(ni) self.assertEqual(4, self.P.num_atoms()) @@ -69,7 +68,7 @@ def test_add_structure(self): # return def test_read_data_string(self): - """check PdfFit.read_data_string()""" + """Check PdfFit.read_data_string()""" pf = self.P with open(self.datafile("300K.gr")) as fp: s = fp.read() @@ -98,7 +97,7 @@ def test_read_data_string(self): # return def test_alloc(self): - """check PdfFit.alloc()""" + """Check PdfFit.alloc()""" # alloc and read_struct can be called in any order. self.P.alloc("X", 25, 0.0, 0.01, 10, 1000) # without a structure calculated PDF is all zero @@ -169,7 +168,7 @@ def test_alloc(self): # return def test_get_structure(self): - """check PdfFit.get_structure()""" + """Check PdfFit.get_structure()""" self.P.read_struct(self.datafile("Ni.stru")) self.P.read_struct(self.datafile("PbScW25TiO3.stru")) stru1 = self.P.get_structure(1) @@ -201,7 +200,7 @@ def test_get_structure(self): # return def test_setpar(self): - """check PdfFit.setpar()""" + """Check PdfFit.setpar()""" pf = self.P pf.read_struct(self.datafile("Ni.stru")) pf.setpar(1, "lat(1)") @@ -213,7 +212,7 @@ def test_setpar(self): return def test_setvar(self): - """check PdfFit.setvar()""" + """Check PdfFit.setvar()""" pf = self.P pf.read_struct(self.datafile("Ni.stru")) pf.setvar(pf.delta1, 1.2) @@ -253,7 +252,7 @@ def test_setvar(self): # return def test_get_atoms(self): - """check PdfFit.get_atoms()""" + """Check PdfFit.get_atoms()""" self.P.read_struct(self.datafile("Ni.stru")) self.P.read_struct(self.datafile("PbScW25TiO3.stru")) self.P.setphase(1) @@ -264,7 +263,7 @@ def test_get_atoms(self): return def test_get_atom_types(self): - """check PdfFit.get_atom_types()""" + """Check PdfFit.get_atom_types()""" self.P.read_struct(self.datafile("Ni.stru")) self.P.read_struct(self.datafile("PbScW25TiO3.stru")) self.P.setphase(1) @@ -275,7 +274,7 @@ def test_get_atom_types(self): return def test_num_phases(self): - """check PdfFit.num_phases()""" + """Check PdfFit.num_phases()""" self.assertEqual(0, self.P.num_phases()) self.P.read_struct(self.datafile("Ni.stru")) self.assertEqual(1, self.P.num_phases()) @@ -286,7 +285,7 @@ def test_num_phases(self): return def test_num_datasets(self): - """check PdfFit.num_datasets()""" + """Check PdfFit.num_datasets()""" self.assertEqual(0, self.P.num_datasets()) self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.5) self.assertEqual(1, self.P.num_datasets()) @@ -306,7 +305,7 @@ def test_num_datasets(self): return def test_getcrw(self): - """check PdfFit.getcrw()""" + """Check PdfFit.getcrw()""" import numpy self.assertEqual(0, self.P.num_datasets()) @@ -339,7 +338,7 @@ def test_getcrw(self): return def test_getcrw_two_datasets(self): - """check that getcrw() and getrw() are consistent for two datasets.""" + """Check that getcrw() and getrw() are consistent for two datasets.""" self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.P.pdfrange(1, 2, 8) self.P.read_data(self.datafile("300K.gr"), "N", 32.0, 0.0) @@ -365,13 +364,13 @@ def test_getcrw_two_datasets(self): # return def test_fixpar(self): - """check PdfFit.fixpar()""" + """Check PdfFit.fixpar()""" self.P.fixpar("all") self.assertRaises(TypeError, self.P.fixpar, "x") return def test_freepar(self): - """check PdfFit.freepar()""" + """Check PdfFit.freepar()""" self.P.freepar("all") self.assertRaises(TypeError, self.P.freepar, "x") return @@ -387,7 +386,7 @@ def test_freepar(self): # return # def test_psel(self): - """check PdfFit.psel()""" + """Check PdfFit.psel()""" def doalloc(): self.P.alloc("X", 30.0, 0.05, 2, 10, 100) @@ -427,7 +426,7 @@ def doalloc(): return def test_pdesel(self): - """check PdfFit.pdesel()""" + """Check PdfFit.pdesel()""" def doalloc(): self.P.alloc("X", 30.0, 0.05, 2, 10, 100) @@ -487,7 +486,7 @@ def doalloc(): # return def test_bond_angle(self): - """check PdfFit.bond_angle()""" + """Check PdfFit.bond_angle()""" self.P.read_struct(self.datafile("Ni.stru")) a, e = self.P.bond_angle(1, 2, 3) self.assertAlmostEqual(60.0, a, self.places) @@ -504,7 +503,7 @@ def test_bang(self): return def test_bond_length_atoms(self): - """check PdfFit.bond_length_atoms()""" + """Check PdfFit.bond_length_atoms()""" self.P.read_struct(self.datafile("Ni.stru")) self.P.read_struct(self.datafile("PbScW25TiO3.stru")) dij, ddij = self.P.bond_length_atoms(1, 5) @@ -514,7 +513,7 @@ def test_bond_length_atoms(self): return def test_bond_length_types(self): - """check PdfFit.bond_length_types()""" + """Check PdfFit.bond_length_types()""" self.P.read_struct(self.datafile("Ni.stru")) self.P.read_struct(self.datafile("PbScW25TiO3.stru")) dPbO = self.P.bond_length_types("Pb", "O", 0.1, 3.0) @@ -556,7 +555,7 @@ def test_bond_length_types(self): return def test_blen(self): - """check PdfFit.blen()""" + """Check PdfFit.blen()""" self.P.read_struct(self.datafile("PbScW25TiO3.stru")) blen = self.P.blen o = self.capture_output(blen, 1, 5).strip() @@ -587,7 +586,7 @@ def test_blen(self): # return def test_get_scat(self): - """check PdfFit.get_scat()""" + """Check PdfFit.get_scat()""" # x-ray scattering factors fPb = self.P.get_scat("X", "Pb") self.assertEqual(82.0, fPb) @@ -604,7 +603,7 @@ def test_get_scat(self): return def test_set_scat(self): - """check PdfFit.set_scat()""" + """Check PdfFit.set_scat()""" # raises exception when no phase exists self.assertRaises(pdffit2.unassignedError, self.P.set_scat, "N", "Ti", -11) # check if it is local to phase @@ -626,7 +625,7 @@ def test_set_scat(self): return def test_reset_scat(self): - """check PdfFit.reset_scat()""" + """Check PdfFit.reset_scat()""" # raises exception when no phase exists self.assertRaises(pdffit2.unassignedError, self.P.reset_scat, "Ti") # check if it is local to phase @@ -649,7 +648,7 @@ def test_reset_scat(self): return def test_num_atoms(self): - """check PdfFit.num_atoms()""" + """Check PdfFit.num_atoms()""" self.P.read_struct(self.datafile("Ni.stru")) self.assertEqual(4, self.P.num_atoms()) self.P.read_struct(self.datafile("PbScW25TiO3.stru")) @@ -661,7 +660,7 @@ def test_num_atoms(self): return def test_lat(self): - """check PdfFit.lat()""" + """Check PdfFit.lat()""" pf = self.P pf.read_struct(self.datafile("Ni.stru")) for i in ("a", "b", "c", 1, 2, 3): @@ -671,7 +670,7 @@ def test_lat(self): return def test_xyz(self): - """check PdfFit.x() PdfFit.y(), PdfFit.z()""" + """Check PdfFit.x() PdfFit.y(), PdfFit.z()""" pf = self.P pf.read_struct(self.datafile("Ni.stru")) self.assertEqual(0.5, pf.getvar(pf.x(3))) @@ -680,7 +679,7 @@ def test_xyz(self): return def test_uij(self): - """check PdfFit.uij()""" + """Check PdfFit.uij()""" ni = loadStructure(self.datafile("Ni.stru")) ni[2].anisotropy = True ni[2].U11, ni[2].U22, ni[2].U33 = 1, 2, 3 @@ -696,7 +695,7 @@ def test_uij(self): return def test_occ(self): - """check PdfFit.occ()""" + """Check PdfFit.occ()""" pf = self.P pf.read_struct(self.datafile("Ni.stru")) for i in range(1, 5): diff --git a/tests/test_phase_fractions.py b/tests/test_phase_fractions.py index d4df1c60..62c9c8e5 100644 --- a/tests/test_phase_fractions.py +++ b/tests/test_phase_fractions.py @@ -1,7 +1,6 @@ #!/usr/bin/env python -"""Unit tests for phase fraction calculations. -""" +"""Unit tests for phase fraction calculations.""" import unittest diff --git a/tests/test_shape_factors.py b/tests/test_shape_factors.py index dd0a0e9c..62d13844 100644 --- a/tests/test_shape_factors.py +++ b/tests/test_shape_factors.py @@ -1,7 +1,6 @@ #!/usr/bin/env python -"""Unit tests for particle shape envelope factors. -""" +"""Unit tests for particle shape envelope factors.""" import unittest @@ -13,7 +12,7 @@ def spherefactor(r, d): - """Calculate spherical envelope correction + """Calculate spherical envelope correction. r -- PDF radius d -- diameter of spherical particle @@ -44,7 +43,7 @@ def tearDown(self): return def test_calculation(self): - """check calculation of sphere envelope factor""" + """Check calculation of sphere envelope factor.""" self.P.read_struct(self.datafile("Ni.stru")) self.P.alloc("X", 0.0, 0.05, 0.1, 10, 200) self.P.calc() @@ -60,7 +59,7 @@ def test_calculation(self): return def test_refinement(self): - """check refinement of sphere envelope factor""" + """Check refinement of sphere envelope factor.""" dcheck = 8.0 dstart = 12.0 self.P.read_struct(self.datafile("Ni.stru")) @@ -83,7 +82,7 @@ def test_refinement(self): return def test_twophase_calculation(self): - """check PDF calculation for 2 phases with different spdiameters""" + """Check PDF calculation for 2 phases with different spdiameters.""" d1 = 6 d2 = 9 self.P.read_struct(self.datafile("Ni.stru")) @@ -114,7 +113,7 @@ def test_twophase_calculation(self): return def test_twophase_refinement(self): - """check PDF refinement of 2 phases that have different spdiameter.""" + """Check PDF refinement of 2 phases that have different spdiameter.""" dcheck1 = 8.0 dstart1 = 8.2 dcheck2 = 6.0 @@ -199,7 +198,7 @@ def tearDown(self): return def test_stepcut_calculation(self): - """check calculation of sphere envelope factor""" + """Check calculation of sphere envelope factor.""" self.P.read_struct(self.datafile("Ni.stru")) self.P.alloc("X", 0.0, 0.05, 0.1, 10, 200) self.P.calc() @@ -216,7 +215,7 @@ def test_stepcut_calculation(self): return def test_twophase_stepcut_calculation(self): - """check PDF calculation for 2 phases with different spdiameters""" + """Check PDF calculation for 2 phases with different spdiameters.""" d1 = 6 d2 = 9 self.P.read_struct(self.datafile("Ni.stru")) diff --git a/tests/test_version.py b/tests/test_version.py index e3ac3668..b9b25b07 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -1,10 +1,10 @@ -"""Unit tests for __version__.py -""" +"""Unit tests for __version__.py.""" import diffpy.pdffit2 def test_package_version(): - """Ensure the package version is defined and not set to the initial placeholder.""" + """Ensure the package version is defined and not set to the initial + placeholder.""" assert hasattr(diffpy.pdffit2, "__version__") assert diffpy.pdffit2.__version__ != "0.0.0" From b1e694429c9a435d502f8f561ca0395fc1e16ee2 Mon Sep 17 00:00:00 2001 From: Tieqiong Zhang Date: Tue, 7 Jan 2025 21:50:01 -0500 Subject: [PATCH 2/4] more pcmt --- .github/workflows/matrix-and-codecov-on-merge-to-main.yml | 2 +- .github/workflows/wheel.yml | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/matrix-and-codecov-on-merge-to-main.yml b/.github/workflows/matrix-and-codecov-on-merge-to-main.yml index 091c71be..f9edf589 100644 --- a/.github/workflows/matrix-and-codecov-on-merge-to-main.yml +++ b/.github/workflows/matrix-and-codecov-on-merge-to-main.yml @@ -23,7 +23,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-13, macos-14] python-version: ["3.11", "3.12"] env: - LATEST_PYTHON_VERSION: "3.12" + LATEST_PYTHON_VERSION: "3.12" steps: - name: Check out diffpy.pdffit2 uses: actions/checkout@v4 diff --git a/.github/workflows/wheel.yml b/.github/workflows/wheel.yml index be7d237d..48bca0d4 100644 --- a/.github/workflows/wheel.yml +++ b/.github/workflows/wheel.yml @@ -7,10 +7,9 @@ on: jobs: build_wheels: - defaults: - run: - shell: bash -l {0} + run: + shell: bash -l {0} name: Build wheel ${{ matrix.python[0] }}-${{ matrix.buildplat[0] }} runs-on: ${{ matrix.buildplat[0] }} From 3c42e8c71df6563d8099d691133e029615fc23f1 Mon Sep 17 00:00:00 2001 From: Tieqiong Zhang Date: Tue, 7 Jan 2025 21:52:42 -0500 Subject: [PATCH 3/4] add news --- news/pcmt.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 news/pcmt.rst diff --git a/news/pcmt.rst b/news/pcmt.rst new file mode 100644 index 00000000..0c23f0f0 --- /dev/null +++ b/news/pcmt.rst @@ -0,0 +1,23 @@ +**Added:** + +* no news: precommit and style check + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* From 3d40d9ba6c91c41b7811f00fe6e2e017489f07a4 Mon Sep 17 00:00:00 2001 From: Tieqiong Zhang Date: Wed, 8 Jan 2025 13:55:15 -0500 Subject: [PATCH 4/4] Revert "more pcmt" This reverts commit b1e694429c9a435d502f8f561ca0395fc1e16ee2. --- .github/workflows/matrix-and-codecov-on-merge-to-main.yml | 2 +- .github/workflows/wheel.yml | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/matrix-and-codecov-on-merge-to-main.yml b/.github/workflows/matrix-and-codecov-on-merge-to-main.yml index f9edf589..091c71be 100644 --- a/.github/workflows/matrix-and-codecov-on-merge-to-main.yml +++ b/.github/workflows/matrix-and-codecov-on-merge-to-main.yml @@ -23,7 +23,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-13, macos-14] python-version: ["3.11", "3.12"] env: - LATEST_PYTHON_VERSION: "3.12" + LATEST_PYTHON_VERSION: "3.12" steps: - name: Check out diffpy.pdffit2 uses: actions/checkout@v4 diff --git a/.github/workflows/wheel.yml b/.github/workflows/wheel.yml index 48bca0d4..be7d237d 100644 --- a/.github/workflows/wheel.yml +++ b/.github/workflows/wheel.yml @@ -7,9 +7,10 @@ on: jobs: build_wheels: + defaults: - run: - shell: bash -l {0} + run: + shell: bash -l {0} name: Build wheel ${{ matrix.python[0] }}-${{ matrix.buildplat[0] }} runs-on: ${{ matrix.buildplat[0] }}