From 1843c4ad72515659a25fe817ed6a947e4ce49e37 Mon Sep 17 00:00:00 2001 From: stevenhua0320 Date: Mon, 27 Apr 2026 17:56:14 -0400 Subject: [PATCH 1/2] chore: change email and instruction --- CODE-OF-CONDUCT.rst | 2 +- LICENSE-PDFgui.rst | 2 +- LICENSE.rst | 2 +- README.rst | 5 ++++- docs/source/license.rst | 2 +- news/email.rst | 23 +++++++++++++++++++++++ 6 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 news/email.rst diff --git a/CODE-OF-CONDUCT.rst b/CODE-OF-CONDUCT.rst index e8199ca..25fafe2 100644 --- a/CODE-OF-CONDUCT.rst +++ b/CODE-OF-CONDUCT.rst @@ -67,7 +67,7 @@ Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at -sb2896@columbia.edu. All complaints will be reviewed and investigated promptly and fairly. +sbillinge@ucsb.edu. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the reporter of any incident. diff --git a/LICENSE-PDFgui.rst b/LICENSE-PDFgui.rst index 27488fe..06492c6 100644 --- a/LICENSE-PDFgui.rst +++ b/LICENSE-PDFgui.rst @@ -24,7 +24,7 @@ program by citing the following paper in your publication: For more information please visit the diffpy web-page at http://www.diffpy.org or email Luke Granlund at luke.r.granlund@gmail.com, or Prof. Simon -Billinge at sb2896@columbia.edu. +Billinge at sbillinge@ucsb.edu. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/LICENSE.rst b/LICENSE.rst index 3c8ea03..4fc1a93 100644 --- a/LICENSE.rst +++ b/LICENSE.rst @@ -17,7 +17,7 @@ program by citing the following paper in your publication: For more information please visit the diffpy web-page at http://www.diffpy.org or email Luke Granlund at luke.r.granlund@gmail.com, or Prof. Simon -Billinge at sb2896@columbia.edu. +Billinge at sbillinge@ucsb.edu. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/README.rst b/README.rst index 68ee72e..705b9f6 100644 --- a/README.rst +++ b/README.rst @@ -102,7 +102,9 @@ The following creates and activates a new environment named ``diffpy.srmise_env` conda create -n diffpy.srmise_env diffpy.srmise conda activate diffpy.srmise_env -The output should print the latest version displayed on the badges above. +You can also install diffpy.srmise in another activated environment with :: + + conda install -c conda-forge diffpy.srmise If the above does not work, you can use ``pip`` to download and install the latest release from `Python Package Index `_. @@ -120,6 +122,7 @@ This package also provides command-line utilities. To check the software has bee diffpy.srmise --version +The output should print the latest version displayed on the badges above. You can also type the following command to verify the installation. :: python -c "import diffpy.srmise; print(diffpy.srmise.__version__)" diff --git a/docs/source/license.rst b/docs/source/license.rst index e37f8fb..259a68d 100644 --- a/docs/source/license.rst +++ b/docs/source/license.rst @@ -29,7 +29,7 @@ program by citing the following paper in your publication: For more information please visit the diffpy web-page at http://www.diffpy.org or email Luke Granlund at luke.r.granlund@gmail.com, or Prof. Simon -Billinge at sb2896@columbia.edu. +Billinge at sbillinge@ucsb.edu. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/news/email.rst b/news/email.rst new file mode 100644 index 0000000..c979bae --- /dev/null +++ b/news/email.rst @@ -0,0 +1,23 @@ +**Added:** + +* No News Added: change email to the right one and add instruction to install in existing env + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* From 919e15e44352d7982c149004999ba78385babc02 Mon Sep 17 00:00:00 2001 From: stevenhua0320 Date: Mon, 27 Apr 2026 19:16:33 -0400 Subject: [PATCH 2/2] build: replace docformatter with ruff and make auto-fix --- .pre-commit-config.yaml | 11 ++++---- docs/examples/multimodel-unknown-dG2.py | 2 +- pyproject.toml | 9 ++++--- src/diffpy/srmise/__init__.py | 3 ++- src/diffpy/srmise/applications/extract.py | 4 +-- src/diffpy/srmise/applications/plot.py | 4 +-- src/diffpy/srmise/basefunction.py | 8 +++--- src/diffpy/srmise/baselines/base.py | 12 ++++----- src/diffpy/srmise/baselines/polynomial.py | 4 ++- src/diffpy/srmise/dataclusters.py | 4 ++- src/diffpy/srmise/modelcluster.py | 21 ++++++++------- src/diffpy/srmise/modelevaluators/aic.py | 4 --- src/diffpy/srmise/modelevaluators/aicc.py | 5 +--- src/diffpy/srmise/modelevaluators/base.py | 1 - src/diffpy/srmise/modelparts.py | 5 +++- src/diffpy/srmise/multimodelselection.py | 7 ++--- src/diffpy/srmise/pdfdataset.py | 1 + src/diffpy/srmise/pdfpeakextraction.py | 4 --- src/diffpy/srmise/peakextraction.py | 6 +++-- src/diffpy/srmise/peaks/base.py | 14 ++++++---- src/diffpy/srmise/peaks/gaussian.py | 3 ++- src/diffpy/srmise/peaks/gaussianoverr.py | 6 ++++- src/diffpy/srmise/peaks/terminationripples.py | 3 ++- src/diffpy/srmise/peakstability.py | 1 - src/diffpy/srmise/srmiseerrors.py | 26 +++++++++---------- src/diffpy/srmise/srmiselog.py | 7 ++++- tests/test_version.py | 3 ++- 27 files changed, 98 insertions(+), 80 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0e4a84d..7df7325 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -57,10 +57,9 @@ repos: - id: prettier additional_dependencies: - "prettier@^3.2.4" - # docformatter - PEP 257 compliant docstring formatter - - repo: https://github.com/s-weigand/docformatter - rev: 5757c5190d95e5449f102ace83df92e7d3b06c6c + # ruff - An extremely fast Python linter and code formatter, written in Rust. + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.15.12 hooks: - - id: docformatter - additional_dependencies: [tomli] - args: [--in-place, --config, ./pyproject.toml] + - id: ruff-check + args: [--fix] diff --git a/docs/examples/multimodel-unknown-dG2.py b/docs/examples/multimodel-unknown-dG2.py index 7e56a4f..a45ff25 100644 --- a/docs/examples/multimodel-unknown-dG2.py +++ b/docs/examples/multimodel-unknown-dG2.py @@ -140,7 +140,7 @@ def run(plot=True): dG = ms.dgs[np.argmax(cls_probs)] best_dGs.append(dG) - print("\n--------- Best models for at least one dG ---------" % dG) + print(f"\n--------- Best models for at least one dG: {dG} ---------") print(" Best dG Model Class Free AIC Prob File") for dG in best_dGs: diff --git a/pyproject.toml b/pyproject.toml index 0dd7456..b132bbe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,10 +60,11 @@ exclude-file = ".codespell/ignore_lines.txt" ignore-words = ".codespell/ignore_words.txt" skip = "*.cif,*.dat" -[tool.docformatter] -recursive = true -wrap-summaries = 72 -wrap-descriptions = 72 +[tool.ruff] +line-length = 115 + +[tool.ruff.lint.pydocstyle] +convention = "numpy" [tool.black] line-length = 115 diff --git a/src/diffpy/srmise/__init__.py b/src/diffpy/srmise/__init__.py index 34d9ab1..299db09 100644 --- a/src/diffpy/srmise/__init__.py +++ b/src/diffpy/srmise/__init__.py @@ -13,7 +13,8 @@ # ############################################################################## """Peak extraction and peak fitting tool for atomic pair distribution -functions.""" +functions. +""" # package version from diffpy.srmise.version import __version__ # noqa diff --git a/src/diffpy/srmise/applications/extract.py b/src/diffpy/srmise/applications/extract.py index a3214e7..3dd4eaa 100755 --- a/src/diffpy/srmise/applications/extract.py +++ b/src/diffpy/srmise/applications/extract.py @@ -35,7 +35,6 @@ def _baseline_namespace(): def main(): """Default SrMise entry-point.""" - usage = ( "usage: %prog pdf_file [options]\n" "pdf_file is a file containing a PDF (accepts several " @@ -624,7 +623,8 @@ def parsepars(mp, parseq): a float with the character 'c' appended. If 'c' is appended, that parameter will be fixed. - Parameters: + Parameters + ---------- mp - A ModelPart instance parseq - A sequence of string """ diff --git a/src/diffpy/srmise/applications/plot.py b/src/diffpy/srmise/applications/plot.py index 64703fa..b4d28c0 100755 --- a/src/diffpy/srmise/applications/plot.py +++ b/src/diffpy/srmise/applications/plot.py @@ -556,8 +556,8 @@ def on_draw(event): def readcompare(filename): """Returns a list of distances read from filename, otherwise - None.""" - + None. + """ # TODO: Make this safer try: datastring = open(filename, "rb").read() diff --git a/src/diffpy/srmise/basefunction.py b/src/diffpy/srmise/basefunction.py index 1876788..861a85d 100644 --- a/src/diffpy/srmise/basefunction.py +++ b/src/diffpy/srmise/basefunction.py @@ -12,7 +12,8 @@ # ############################################################################## """Defines BaseFunction, the base class for mathematical functions in -srmise.""" +srmise. +""" import logging import re @@ -30,7 +31,7 @@ class BaseFunction(object): sequences. Attributes - ------------- + ---------- parameterdict : dict The dictionary mapping string keys to their index in the sequence of parameters. These keys apply only to the @@ -102,7 +103,6 @@ def __init__( The class (not instance) which implements caching of BaseFunction evaluations. """ - self.parameterdict = parameterdict self.npars = len(self.parameterdict) @@ -448,6 +448,7 @@ def factory(functionstr, baselist): The list of BaseFunction (or subclass) instances. Returns + ------- Basefunction instance The BaseFunction instance based on the parameter strings """ @@ -505,6 +506,7 @@ def safefunctionlist(fs): is guaranteed to be safe for saving/reinstantiating peak functions. Parameters + ---------- fs: List of BaseFunction instances. """ fsafe = [] diff --git a/src/diffpy/srmise/baselines/base.py b/src/diffpy/srmise/baselines/base.py index b1e9a06..fabf835 100644 --- a/src/diffpy/srmise/baselines/base.py +++ b/src/diffpy/srmise/baselines/base.py @@ -128,14 +128,15 @@ def getmodule(self): class Baseline(ModelPart): """Represents a baseline associated with a BaselineFunction - subclass.""" + subclass. + """ def __init__(self, owner, pars, free=None, removable=False, static_owner=False): """Initialize the BaselineComponent instance with specified configurations. - Parameters - ---------- + Parameters + ---------- owner : BaselineFunction subclass instance The owner object which is an instance of a subclass of BaselineFunction. pars : array-like @@ -151,8 +152,8 @@ def __init__(self, owner, pars, free=None, removable=False, static_owner=False): Determines if the owner of the baseline can be altered using the ` changeowner()` method. Defaults to False. - Notes - ----- + Notes + ----- - The `free` and `removable` parameters are independent; a baseline can be marked as removable even if some of its parameters are fixed (`free` is False). In such cases, the baseline may be removed during peak extraction, but the fixed @@ -171,7 +172,6 @@ def factory(baselinestr, ownerlist): ownerlist : array-like The list of BaseFunctions that owner is in """ - data = baselinestr.strip().splitlines() # dictionary of parameters diff --git a/src/diffpy/srmise/baselines/polynomial.py b/src/diffpy/srmise/baselines/polynomial.py index 13ca878..df0f379 100644 --- a/src/diffpy/srmise/baselines/polynomial.py +++ b/src/diffpy/srmise/baselines/polynomial.py @@ -24,7 +24,8 @@ class Polynomial(BaselineFunction): """Methods for evaluation and parameter estimation of a polynomial - baseline.""" + baseline. + """ def __init__(self, degree, Cache=None): """Initialize a polynomial function of degree d. @@ -166,6 +167,7 @@ def _transform_parametersraw(self, pars, in_format, out_format): """Convert parameter values from in_format to out_format. Parameters + ---------- pars : array-like The sequence of parameters in_format : str diff --git a/src/diffpy/srmise/dataclusters.py b/src/diffpy/srmise/dataclusters.py index 364ef30..c79d5fb 100644 --- a/src/diffpy/srmise/dataclusters.py +++ b/src/diffpy/srmise/dataclusters.py @@ -12,7 +12,8 @@ # ############################################################################## """Defines class to partition sequences representing the x and y axis -into peak-like clusters.""" +into peak-like clusters. +""" import logging @@ -434,6 +435,7 @@ def cut(self, idx): """Return slice(s) for data given cluster index (or indices). Parameters + ---------- idx - Cluster index (or sequence of indices). """ data_ids = self.clusters[idx] diff --git a/src/diffpy/srmise/modelcluster.py b/src/diffpy/srmise/modelcluster.py index abefffb..c1a64c5 100644 --- a/src/diffpy/srmise/modelcluster.py +++ b/src/diffpy/srmise/modelcluster.py @@ -266,11 +266,11 @@ def getvalue(self, i): """Return value of parameter i. The variable may be specified as an integer, or as a two- - component tuple of integers (l, m) which indicate the mth - parameter of modelpart l. + component tuple of integers ``(part_idx, param_idx)`` indicating + the ``param_idx``-th parameter of model part ``part_idx``. """ - (l, m) = i if i in self.pmap else self.ipmap[i] - return self.model[l][m] + part_idx, param_idx = i if i in self.pmap else self.ipmap[i] + return self.model[part_idx][param_idx] def getuncertainty(self, i): """Return uncertainty of parameter i. @@ -288,7 +288,7 @@ def getuncertainty(self, i): float The uncertainty of variable at index i. """ - (l, m) = i if i in self.pmap else self.ipmap[i] + part_idx, param_idx = i if i in self.pmap else self.ipmap[i] return np.sqrt(self.getcovariance(i, i)) def getcovariance(self, i, j): @@ -369,7 +369,8 @@ def correlationwarning(self, threshold=0.8): def __str__(self): """Return string of value (uncertainty) pairs for all - parameters.""" + parameters. + """ if self.model is None or self.cov is None: return "Model and/or Covariance matrix undefined." lines = [] @@ -799,16 +800,16 @@ def join_adjacent(m1, m2): The new ModelCluster instance between m1 and m2. """ # Check for members that must be shared. - if not (m1.r_data is m2.r_data): + if m1.r_data is not m2.r_data: emsg = "Cannot join ModelClusters that do not share r_data." raise ValueError(emsg) - if not (m1.y_data is m2.y_data): + if m1.y_data is not m2.y_data: emsg = "Cannot join ModelClusters that do not share y_data." raise ValueError(emsg) - if not (m1.y_error is m2.y_error): + if m1.y_error is not m2.y_error: emsg = "Cannot join ModelClusters that do not share y_error." raise ValueError(emsg) - if not (m1.error_method is m2.error_method): + if m1.error_method is not m2.error_method: emsg = "Cannot join ModelClusters that do not share error_method." raise ValueError(emsg) if not (m1.baseline == m2.baseline): diff --git a/src/diffpy/srmise/modelevaluators/aic.py b/src/diffpy/srmise/modelevaluators/aic.py index 1fd7d5e..ec3cbf0 100644 --- a/src/diffpy/srmise/modelevaluators/aic.py +++ b/src/diffpy/srmise/modelevaluators/aic.py @@ -103,7 +103,6 @@ def minpoints(self, npars): int The minimum number of points required to make an estimate of a model's quality. """ - return 1 def parpenalty(self, k): @@ -120,7 +119,6 @@ def parpenalty(self, k): float The penalty cost for adding k parameters to the current model cluster. """ - # Weight the penalty for additional parameters. # If this isn't 1 there had better be a good reason. fudgefactor = 1.0 @@ -151,7 +149,6 @@ def growth_justified(self, fit, k_prime): bool Whether adding k_prime parameters to the given model is justified. """ - if self.chisq is None: self.chisq = self.chi_squared(fit.value(), fit.y_cluster, fit.error_cluster) @@ -187,7 +184,6 @@ def akaikeweights(aics): array-like The sequence of Akaike weights """ - aic_stats = np.array([aic.stat for aic in aics]) aic_min = min(aic_stats) return np.exp(-(aic_stats - aic_min) / 2.0) diff --git a/src/diffpy/srmise/modelevaluators/aicc.py b/src/diffpy/srmise/modelevaluators/aicc.py index 66d49fc..f0e4196 100644 --- a/src/diffpy/srmise/modelevaluators/aicc.py +++ b/src/diffpy/srmise/modelevaluators/aicc.py @@ -55,6 +55,7 @@ def evaluate(self, fit, count_fixed=False, kshift=0): small sample size). Parameters + ---------- fit: A ModelCluster The ModelCluster to evaluate. count_fixed : bool @@ -102,7 +103,6 @@ def minpoints(self, npars): int The minimum number of points required to make an estimate of a model's quality. """ - # From the denominator of AICc, it is clear that the first positive finite contribution to # parameter cost is at n>=k+2 return npars + 2 @@ -124,7 +124,6 @@ def parpenalty(self, k, n): float The cost for adding k parameters to the current model cluster. """ - # Weight the penalty for additional parameters. # If this isn't 1 there had better be a good reason. fudgefactor = 1.0 @@ -152,7 +151,6 @@ def growth_justified(self, fit, k_prime): bool Whether the current model cluster is justified or not. """ - if self.chisq is None: self.chisq = self.chi_squared(fit.value(), fit.y_cluster, fit.error_cluster) @@ -188,7 +186,6 @@ def akaikeweights(aics): array-like The sequence of Akaike weights """ - aic_stats = np.array([aic.stat for aic in aics]) aic_min = min(aic_stats) return np.exp(-(aic_stats - aic_min) / 2.0) diff --git a/src/diffpy/srmise/modelevaluators/base.py b/src/diffpy/srmise/modelevaluators/base.py index a55df58..1da3f34 100644 --- a/src/diffpy/srmise/modelevaluators/base.py +++ b/src/diffpy/srmise/modelevaluators/base.py @@ -142,7 +142,6 @@ def chi_squared(self, expected, observed, error): error : float The error statistic. """ - self.chisq = np.sum((expected - observed) ** 2 / error**2) return self.chisq diff --git a/src/diffpy/srmise/modelparts.py b/src/diffpy/srmise/modelparts.py index c58a7cd..d4d17ae 100644 --- a/src/diffpy/srmise/modelparts.py +++ b/src/diffpy/srmise/modelparts.py @@ -307,6 +307,7 @@ def residual_jacobian(self, freepars, r, y_expected, y_error, range=None): """Calculate the Jacobian of freepars. Parameters + ---------- freepars : array-like The sequence of free parameters r : array-like @@ -438,6 +439,7 @@ def transform(self, in_format="internal", out_format="internal"): """Transforms format of parameters in this modelpart. Parameters + ---------- in_format : str The format the parameters are already in. out_format : str @@ -460,7 +462,7 @@ class ModelPart(object): """Represents a single part (instance of some function) of a model. Attributes - ------- + ---------- pars : array-like The array containing the parameters of this model part free : array-like @@ -502,6 +504,7 @@ def __init__(self, owner, pars, free=None, removable=True, static_owner=False): """Constructor for instance members. Parameters + ---------- owner : BaseFunction subclass The instance of a BaseFunction subclass pars : array-like diff --git a/src/diffpy/srmise/multimodelselection.py b/src/diffpy/srmise/multimodelselection.py index 8e97afd..91cd34c 100644 --- a/src/diffpy/srmise/multimodelselection.py +++ b/src/diffpy/srmise/multimodelselection.py @@ -34,7 +34,8 @@ def eatkwds(*args, **kwds): class MultimodelSelection(PeakStability): """Quick and dirty multimodel selection using AIC and its - offspring.""" + offspring. + """ def __init__(self): """""" @@ -198,7 +199,8 @@ def makeaicprobs(self): def makesortedprobs(self): """Make probabilities for the sequence of AICs in a sorted - order.""" + order. + """ self.sortedprobs = {} for dg in self.dgs: @@ -610,7 +612,6 @@ def plot3dclassprobs(self, **kwds): "cbaxis" - The colorbar axis, if it exists. "cb" - The colorbar, if it exists. """ - from matplotlib import cm, colorbar, colors from matplotlib.collections import PolyCollection diff --git a/src/diffpy/srmise/pdfdataset.py b/src/diffpy/srmise/pdfdataset.py index 2d72878..3965fe3 100644 --- a/src/diffpy/srmise/pdfdataset.py +++ b/src/diffpy/srmise/pdfdataset.py @@ -225,6 +225,7 @@ def readStr(self, datastring): string of raw data Returns + ------- self """ self.clear() diff --git a/src/diffpy/srmise/pdfpeakextraction.py b/src/diffpy/srmise/pdfpeakextraction.py index 6f04cc6..3744bb8 100644 --- a/src/diffpy/srmise/pdfpeakextraction.py +++ b/src/diffpy/srmise/pdfpeakextraction.py @@ -570,7 +570,6 @@ def fit(self, **kwds): ModelCovariance instance The fitted ModelCovariance instance. """ - self.clearcalc() # Make sure all required extraction variables have some value @@ -664,7 +663,6 @@ def readmetadata(self, metastr): ------- None """ - # filename res = re.search(r"^filename=(.*)$", metastr, re.M) if res: @@ -758,7 +756,6 @@ def writepwastr(self, comments): ------- None """ - if self.extracted is None: emsg = "Cannot write summary: Peak Extraction has not been performed." raise SrMiseError(emsg) @@ -1068,7 +1065,6 @@ def stdratio(data): an array of length floor(len(data)/2)-1. The ith element is equivalent to std(data[:i+2])/std(data[i+2:2i+4]). """ - limit = int(np.floor(len(data) / 2)) std_left = np.zeros(limit) std_right = np.zeros(limit) diff --git a/src/diffpy/srmise/peakextraction.py b/src/diffpy/srmise/peakextraction.py index c120766..48e3419 100644 --- a/src/diffpy/srmise/peakextraction.py +++ b/src/diffpy/srmise/peakextraction.py @@ -69,6 +69,7 @@ def __init__(self, newvars=[]): """Initialize PeakExtraction object. Parameters + ---------- newvars : array-like Sequence of strings that represent additional extraction parameters. """ @@ -718,7 +719,8 @@ def writesummary(self): def getrangeslice(self): """Convert the ranges in terms of x-coordinates to a slice - object.""" + object. + """ low_idx = 0 while self.x[low_idx] < max(self.x[0], self.rng[0]): low_idx += 1 @@ -820,6 +822,7 @@ def extract_single(self, recursion_depth=1): specified by error_method. Parameters + ---------- recursion_depth: (1) Tracks recursion with extract_single. """ self.clearcalc() @@ -1366,7 +1369,6 @@ def fit_single(self): Return ModelCovariance instance summarizing results. """ - self.clearcalc() # Make sure all required extraction variables have some value diff --git a/src/diffpy/srmise/peaks/base.py b/src/diffpy/srmise/peaks/base.py index a8b2c35..7e57c10 100644 --- a/src/diffpy/srmise/peaks/base.py +++ b/src/diffpy/srmise/peaks/base.py @@ -135,7 +135,8 @@ def __init__(self, *args, **kwds): def argsort(self, key="position"): """Return sequence of indices which sort peaks in order - specified by key.""" + specified by key. + """ keypars = np.array([p[key] for p in self]) # In normal use the peaks will already be sorted, so check for it. sorted = True @@ -156,7 +157,8 @@ def match_at(self, x, y): very close to x, or other issues may prevent optimal results. If the peaks cannot be scaled at all they are left unchanged. - Parameters: + Parameters + ---------- x: (float) Position at which to match. y: (float) Height to match. @@ -213,7 +215,8 @@ def sort(self, reverse=False, key="position"): class Peak(ModelPart): """Represents a single peak associated with a PeakFunction - subclass.""" + subclass. + """ def __init__(self, owner, pars, free=None, removable=True, static_owner=False): """Set instance members. @@ -241,6 +244,7 @@ def scale_at(self, x, scale): the peak is not adjusted. Parameters + ---------- x: (float) Position of the border scale: (float > 0) Amount by which to scale. @@ -270,11 +274,11 @@ def scale_at(self, x, scale): def factory(peakstr, ownerlist): """Instantiate a Peak from a string. - Parameters: + Parameters + ---------- peakstr: string representing peak ownerlist: List of BaseFunctions that owner is in """ - data = peakstr.strip().splitlines() # dictionary of parameters diff --git a/src/diffpy/srmise/peaks/gaussian.py b/src/diffpy/srmise/peaks/gaussian.py index b992b2f..2c9b713 100644 --- a/src/diffpy/srmise/peaks/gaussian.py +++ b/src/diffpy/srmise/peaks/gaussian.py @@ -46,7 +46,8 @@ class Gaussian(PeakFunction): # equivalent to 3 standard deviations. def __init__(self, maxwidth, Cache=None): """Maxwidth defined as full width at half maximum for the - corresponding Gaussian, which is physically relevant.""" + corresponding Gaussian, which is physically relevant. + """ parameterdict = {"position": 0, "width": 1, "area": 2} formats = ["internal", "pwa", "mu_sigma_area"] default_formats = { diff --git a/src/diffpy/srmise/peaks/gaussianoverr.py b/src/diffpy/srmise/peaks/gaussianoverr.py index c8f29d0..c47191a 100644 --- a/src/diffpy/srmise/peaks/gaussianoverr.py +++ b/src/diffpy/srmise/peaks/gaussianoverr.py @@ -46,7 +46,8 @@ class GaussianOverR(PeakFunction): # equivalent to 3 standard deviations. def __init__(self, maxwidth, Cache=None): """Maxwidth defined as full width at half maximum for the - corresponding Gaussian, which is physically relevant.""" + corresponding Gaussian, which is physically relevant. + """ parameterdict = {"position": 0, "width": 1, "area": 2} formats = ["internal", "pwa", "mu_sigma_area"] default_formats = { @@ -274,6 +275,7 @@ def _jacobianraw(self, pars, r, free): Determines which derivatives need to be computed. A `True` value indicates that the derivative with respect to the corresponding parameter in `pars` should be calculated; `False` indicates no evaluation is needed. + Returns ------- jacobian : ndarray @@ -320,6 +322,7 @@ def _transform_derivativesraw(self, pars, in_format, out_format): to out_format. Parameters + ---------- pars: Sequence of parameters in_format: A format defined for this class out_format: A format defined for this class @@ -462,6 +465,7 @@ def _valueraw(self, pars, r): - pars[2]: Multiplicative constant 'a', equivalent to the peak area of the Gaussian when integrated. r : array_like or float Radial distances or a single value at which the Gaussian is to be evaluated. + Returns ------- float diff --git a/src/diffpy/srmise/peaks/terminationripples.py b/src/diffpy/srmise/peaks/terminationripples.py index 7a4a7d3..315e02a 100644 --- a/src/diffpy/srmise/peaks/terminationripples.py +++ b/src/diffpy/srmise/peaks/terminationripples.py @@ -24,7 +24,8 @@ class TerminationRipples(PeakFunction): """Methods for evaluation and parameter estimation of a peak - function with termination ripples.""" + function with termination ripples. + """ def __init__(self, base, qmax, extension=4.0, supersample=5.0, Cache=None): """Peak function constructor which adds termination ripples to diff --git a/src/diffpy/srmise/peakstability.py b/src/diffpy/srmise/peakstability.py index ebeede1..77e3928 100644 --- a/src/diffpy/srmise/peakstability.py +++ b/src/diffpy/srmise/peakstability.py @@ -200,7 +200,6 @@ def run(self, err, savecovs=False): boolean to determine to save covariance matrix. Default is False. If savecovs is True, return the covariance matrix for each final fit. """ - self.results = [] covs = [] for i, e in enumerate(err): diff --git a/src/diffpy/srmise/srmiseerrors.py b/src/diffpy/srmise/srmiseerrors.py index 22e8948..cdd8f71 100644 --- a/src/diffpy/srmise/srmiseerrors.py +++ b/src/diffpy/srmise/srmiseerrors.py @@ -34,7 +34,7 @@ class SrMiseError(Exception): """Superclass of all diffpy.srmise exceptions.""" def __init__(self, info): - """initialize. + """Initialize. info: description string """ @@ -55,7 +55,7 @@ class SrMiseDataFormatError(SrMiseError): """ def __init__(self, info): - """initialize. + """Initialize. info -- description string """ @@ -69,7 +69,7 @@ class SrMiseEstimationError(SrMiseError): """ def __init__(self, info): - """initialize. + """Initialize. info -- description string """ @@ -83,7 +83,7 @@ class SrMiseFileError(SrMiseError): """ def __init__(self, info): - """initialize. + """Initialize. info -- description string """ @@ -97,7 +97,7 @@ class SrMiseFitError(SrMiseError): """ def __init__(self, info): - """initialize. + """Initialize. info -- description string """ @@ -111,7 +111,7 @@ class SrMiseLogError(SrMiseError): """ def __init__(self, info): - """initialize. + """Initialize. info -- description string """ @@ -125,7 +125,7 @@ class SrMiseModelEvaluatorError(SrMiseError): """ def __init__(self, info): - """initialize. + """Initialize. info -- description string """ @@ -139,7 +139,7 @@ class SrMiseQmaxError(SrMiseError): """ def __init__(self, info): - """initialize. + """Initialize. info -- description string """ @@ -153,7 +153,7 @@ class SrMiseScalingError(SrMiseError): """ def __init__(self, info): - """initialize. + """Initialize. info -- description string """ @@ -167,7 +167,7 @@ class SrMiseStaticOwnerError(SrMiseError): """ def __init__(self, info): - """initialize. + """Initialize. info -- description string """ @@ -181,7 +181,7 @@ class SrMiseTransformationError(SrMiseError): """ def __init__(self, info): - """initialize. + """Initialize. info -- description string """ @@ -195,7 +195,7 @@ class SrMiseUndefinedCovarianceError(SrMiseError): """ def __init__(self, info): - """initialize. + """Initialize. info -- description string """ @@ -209,7 +209,7 @@ class SrMisePDFKeyError(SrMiseError): """ def __init__(self, info): - """initialize. + """Initialize. info -- description string """ diff --git a/src/diffpy/srmise/srmiselog.py b/src/diffpy/srmise/srmiselog.py index 5393475..d5fcd6f 100644 --- a/src/diffpy/srmise/srmiselog.py +++ b/src/diffpy/srmise/srmiselog.py @@ -79,6 +79,7 @@ def addfilelog(filename, level=defaultlevel, format=defaultformat): """Log output from diffpy.srmise in specified file. Parameters + ---------- filename: Name of file to receiving output level: The logging level format: A string defining format of output messages conforming to logging package. @@ -95,6 +96,7 @@ def setfilelevel(level): """Set level of file logger. Parameters + ---------- level: The logging level. """ global fh @@ -112,6 +114,7 @@ def setlevel(level): """Set level of default (stdout) logger. Parameters + ---------- level: The logging level. """ global ch @@ -128,6 +131,7 @@ def liveplotting(lp, w=False): as extraction progresses. Parameters + ---------- lp: Use live plotting (True) or not (False). w: (False) Whether to wait for user after plotting. """ @@ -233,6 +237,7 @@ def read(self, filename): """Read tracer ModelCluster from file. Parameters + ---------- filename - file from which to read Returns dictionary with keys @@ -256,6 +261,7 @@ def readstr(self, datastring): """Read tracer ModelCluster from string. Parameters + ---------- datastring - The string representation of a trace Returns dictionary with keys @@ -264,7 +270,6 @@ def readstr(self, datastring): "mc" - A ModelCluster instance "recursion" - The recursion level of mc """ - # find where the ModelCluster section starts res = re.search(r"^#+ ModelCluster\s*(?:#.*\s+)*", datastring, re.M) if res: diff --git a/tests/test_version.py b/tests/test_version.py index 06a0a7c..04f9972 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -5,6 +5,7 @@ def test_package_version(): """Ensure the package version is defined and not set to the initial - placeholder.""" + placeholder. + """ assert hasattr(diffpy.srmise, "__version__") assert diffpy.srmise.__version__ != "0.0.0"