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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
2 changes: 1 addition & 1 deletion CODE-OF-CONDUCT.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE-PDFgui.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://pypi.python.org>`_.
Expand All @@ -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__)"
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/multimodel-unknown-dG2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion docs/source/license.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
23 changes: 23 additions & 0 deletions news/email.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* No News Added: change email to the right one and add instruction to install in existing env

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/diffpy/srmise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/srmise/applications/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down Expand Up @@ -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
"""
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/srmise/applications/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 5 additions & 3 deletions src/diffpy/srmise/basefunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
#
##############################################################################
"""Defines BaseFunction, the base class for mathematical functions in
srmise."""
srmise.
"""

import logging
import re
Expand All @@ -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
Expand Down Expand Up @@ -102,7 +103,6 @@ def __init__(
The class (not instance) which implements caching of BaseFunction
evaluations.
"""

self.parameterdict = parameterdict
self.npars = len(self.parameterdict)

Expand Down Expand Up @@ -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
"""
Expand Down Expand Up @@ -505,6 +506,7 @@ def safefunctionlist(fs):
is guaranteed to be safe for saving/reinstantiating peak functions.

Parameters
----------
fs: List of BaseFunction instances.
"""
fsafe = []
Expand Down
12 changes: 6 additions & 6 deletions src/diffpy/srmise/baselines/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/diffpy/srmise/baselines/polynomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/diffpy/srmise/dataclusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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]
Expand Down
21 changes: 11 additions & 10 deletions src/diffpy/srmise/modelcluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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):
Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 0 additions & 4 deletions src/diffpy/srmise/modelevaluators/aic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
Loading
Loading