Skip to content

Commit a714b98

Browse files
Implement automatic spell check via Codespell and fix typos (#149)
* Apply spelling fix and configure codespell * Add news * [pre-commit.ci] auto fixes from pre-commit hooks --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 35ef9e8 commit a714b98

32 files changed

+90
-43
lines changed

.codespell/ignore_lines.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
;; Please include filenames and explanations for each ignored line.
2+
;; See https://docs.openverse.org/meta/codespell.html for docs.

.codespell/ignore_words.txt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
;; Please include explanations for each ignored word (lowercase).
2+
;; See https://docs.openverse.org/meta/codespell.html for docs.
3+
4+
;; abbreviation for "materials" often used in a journal title
5+
mater
6+
7+
;; alternative use of socioeconomic
8+
socio-economic
9+
10+
;; Frobenius norm used in np.linalg.norm
11+
fro

.pre-commit-config.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,9 @@ repos:
4444
name: Prevent Commit to Main Branch
4545
args: ["--branch", "main"]
4646
stages: [pre-commit]
47+
- repo: https://github.com/codespell-project/codespell
48+
rev: v2.3.0
49+
hooks:
50+
- id: codespell
51+
additional_dependencies:
52+
- tomli

AUTHORS.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Authors
22
=======
33

44
Luke Granlund
5-
Billinge Group and community contibutors.
5+
Billinge Group and community contributors.
66

77
Contributors
88
------------

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ trying to commit again.
152152

153153
Improvements and fixes are always appreciated.
154154

155-
Before contribuing, please read our `Code of Conduct <https://github.com/diffpy/diffpy.srmise/blob/main/CODE_OF_CONDUCT.rst>`_.
155+
Before contributing, please read our `Code of Conduct <https://github.com/diffpy/diffpy.srmise/blob/main/CODE_OF_CONDUCT.rst>`_.
156156

157157
Contact
158158
-------

doc/examples/README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ the copiously commented scripts helpful.
111111
* Peak extraction with initial peaks:
112112
extract_initial.py
113113

114-
* Peak fitting with intial peaks:
114+
* Peak fitting with initial peaks:
115115
fit_initial.py
116116

117117
* Querying SrMise results:
@@ -678,7 +678,7 @@ the baseline. The methods of greatest interest are as follows. ::
678678
# Get the correlation between two parameters
679679
cov.getcorrelation((i1,j1), (i2,j2))
680680

681-
Suppose, for example, one wants to emperically estimate the number of silver
681+
Suppose, for example, one wants to empirically estimate the number of silver
682682
atoms contributing to each occupied coordination shell of the FCC structure,
683683
knowing that the coordination number (i.e. nearest neighbors) of an ideal FCC
684684
structure is exactly 12. For a monoelemental material the intensity of a peak

doc/examples/multimodel_known_dG2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def run(plot=True):
114114
# with respect to the actual experiment when using a Nyquist-sampled PDF
115115
# with experimentally determined uncertainties.
116116
#
117-
# The present PDF satisifes these conditions, so the rankings below reflect
117+
# The present PDF satisfies these conditions, so the rankings below reflect
118118
# an AIC-based estimate of which of the tested models the data best support.
119119
print("\n--------- Model Rankings for dG = %f ---------" % dG)
120120
print("Rank Model Class Free AIC Prob File")

doc/examples/output/extract_single_peak.pwa

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ ModelEvaluator=AIC
4444
## Extracted Peaks
4545
# Parameters are given in the natural units of the data,
4646
# where width is measured as full-width at half maximum.
47-
# Each line is followd by a comment which gives the index
47+
# Each line is followed by a comment which gives the index
4848
# of the corresponding Peak Function.
4949
#L position fwhm area
5050
2.90074809344 0.267213055365 9.84389058517 # 1

doc/examples/output/fit_initial.pwa

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ ModelEvaluator=AIC
4343
## Extracted Peaks
4444
# Parameters are given in the natural units of the data,
4545
# where width is measured as full-width at half maximum.
46-
# Each line is followd by a comment which gives the index
46+
# Each line is followed by a comment which gives the index
4747
# of the corresponding Peak Function.
4848
#L position fwhm area
4949
1.44052045545 0.126922793092 35515.0466525 # 1

doc/examples/output/known_dG_m0.pwa

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ ModelEvaluator=AIC
5151
## Extracted Peaks
5252
# Parameters are given in the natural units of the data,
5353
# where width is measured as full-width at half maximum.
54-
# Each line is followd by a comment which gives the index
54+
# Each line is followed by a comment which gives the index
5555
# of the corresponding Peak Function.
5656
#L position fwhm area
5757
11.2310491383 0.29009226516 19.2512559254 # 2

doc/examples/output/known_dG_m1.pwa

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ ModelEvaluator=AIC
5151
## Extracted Peaks
5252
# Parameters are given in the natural units of the data,
5353
# where width is measured as full-width at half maximum.
54-
# Each line is followd by a comment which gives the index
54+
# Each line is followed by a comment which gives the index
5555
# of the corresponding Peak Function.
5656
#L position fwhm area
5757
11.2529285169 0.364905691879 35.069510576 # 2

doc/examples/output/known_dG_m12.pwa

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ ModelEvaluator=AIC
5151
## Extracted Peaks
5252
# Parameters are given in the natural units of the data,
5353
# where width is measured as full-width at half maximum.
54-
# Each line is followd by a comment which gives the index
54+
# Each line is followed by a comment which gives the index
5555
# of the corresponding Peak Function.
5656
#L position fwhm area
5757
11.2573520325 0.373991203999 34.6040498151 # 2

doc/examples/output/known_dG_m8.pwa

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ ModelEvaluator=AIC
5151
## Extracted Peaks
5252
# Parameters are given in the natural units of the data,
5353
# where width is measured as full-width at half maximum.
54-
# Each line is followd by a comment which gives the index
54+
# Each line is followed by a comment which gives the index
5555
# of the corresponding Peak Function.
5656
#L position fwhm area
5757
11.2506286561 0.370187490596 34.3566941925 # 2

doc/examples/output/parameter_summary.pwa

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ ModelEvaluator=AIC
4444
## Extracted Peaks
4545
# Parameters are given in the natural units of the data,
4646
# where width is measured as full-width at half maximum.
47-
# Each line is followd by a comment which gives the index
47+
# Each line is followed by a comment which gives the index
4848
# of the corresponding Peak Function.
4949
#L position fwhm area
5050
1.9557575566 0.248658302944 2.57966649229 # 1

doc/examples/output/query_results.pwa

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ ModelEvaluator=AIC
4444
## Extracted Peaks
4545
# Parameters are given in the natural units of the data,
4646
# where width is measured as full-width at half maximum.
47-
# Each line is followd by a comment which gives the index
47+
# Each line is followed by a comment which gives the index
4848
# of the corresponding Peak Function.
4949
#L position fwhm area
5050
2.90080420526 0.268377339284 9.93053286298 # 1

doc/examples/output/unknown_dG_m11.pwa

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ ModelEvaluator=AIC
5050
## Extracted Peaks
5151
# Parameters are given in the natural units of the data,
5252
# where width is measured as full-width at half maximum.
53-
# Each line is followd by a comment which gives the index
53+
# Each line is followed by a comment which gives the index
5454
# of the corresponding Peak Function.
5555
#L position fwhm area
5656
1.44110805058 0.137450008306 36477.2666515 # 2

doc/examples/output/unknown_dG_m17.pwa

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ ModelEvaluator=AIC
5050
## Extracted Peaks
5151
# Parameters are given in the natural units of the data,
5252
# where width is measured as full-width at half maximum.
53-
# Each line is followd by a comment which gives the index
53+
# Each line is followed by a comment which gives the index
5454
# of the corresponding Peak Function.
5555
#L position fwhm area
5656
1.44210250295 0.130428325915 35832.2439651 # 2

doc/examples/output/unknown_dG_m18.pwa

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ ModelEvaluator=AIC
5050
## Extracted Peaks
5151
# Parameters are given in the natural units of the data,
5252
# where width is measured as full-width at half maximum.
53-
# Each line is followd by a comment which gives the index
53+
# Each line is followed by a comment which gives the index
5454
# of the corresponding Peak Function.
5555
#L position fwhm area
5656
1.44255991965 0.130976461359 35872.4728645 # 2

doc/examples/output/unknown_dG_m5.pwa

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ ModelEvaluator=AIC
5050
## Extracted Peaks
5151
# Parameters are given in the natural units of the data,
5252
# where width is measured as full-width at half maximum.
53-
# Each line is followd by a comment which gives the index
53+
# Each line is followed by a comment which gives the index
5454
# of the corresponding Peak Function.
5555
#L position fwhm area
5656
1.44110346987 0.135456358948 36202.906939 # 2

doc/examples/output/unknown_dG_m7.pwa

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ ModelEvaluator=AIC
5050
## Extracted Peaks
5151
# Parameters are given in the natural units of the data,
5252
# where width is measured as full-width at half maximum.
53-
# Each line is followd by a comment which gives the index
53+
# Each line is followed by a comment which gives the index
5454
# of the corresponding Peak Function.
5555
#L position fwhm area
5656
1.4417380998 0.13653359706 36320.7534683 # 2

doc/examples/query_results.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# See LICENSE.txt for license information.
1111
#
1212
##############################################################################
13-
"""Example of extracting multiple peaks and accessing results programatically.
13+
"""Example of extracting multiple peaks and accessing results programmatically.
1414
1515
This example shows how to extract a range of peaks from a simple crystalline
1616
PDF using a crystalline baseline obtained from an existing trial. It shows

doc/source/extending.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ functionality common to all SrMise baseline and peak functions, which are
2222
separately implemented in the ``diffpy.srmise.baselines`` and
2323
``diffpy.srmise.peaks`` subpackages. Specific baseline and peak functions
2424
inherit from the ``BaselineFunction`` and ``PeakFunction`` classes in those
25-
subpackges, as shown below.
25+
subpackages, as shown below.
2626

2727
* .. py:class:: BaseFunction
2828

news/codespell.rst

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* Codespell for automatic spelling check, configured in pre-commit
4+
5+
**Changed:**
6+
7+
* <news item>
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* Typos in the source code and documentation
20+
21+
**Security:**
22+
23+
* <news item>

pyproject.toml

+5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ namespaces = false # to disable scanning PEP 420 namespaces (true by default)
5757
[tool.setuptools.dynamic]
5858
dependencies = {file = ["requirements/pip.txt"]}
5959

60+
[tool.codespell]
61+
exclude-file = ".codespell/ignore_lines.txt"
62+
ignore-words = ".codespell/ignore_words.txt"
63+
skip = "*.cif,*.dat"
64+
6065
[tool.black]
6166
line-length = 115
6267
include = '\.pyi?$'

src/diffpy/srmise/modelcluster.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class ModelCovariance(object):
5353
"""
5454

5555
def __init__(self, *args, **kwds):
56-
"""Intialize object."""
56+
"""Initialize object."""
5757
self.cov = None # The raw covariance matrix
5858
self.model = None # ModelParts instance, so both peaks and baseline (if present)
5959

@@ -430,7 +430,7 @@ class ModelCluster(object):
430430
"""
431431

432432
def __init__(self, model, *args, **kwds):
433-
"""Intialize explicitly, or from existing ModelCluster.
433+
"""Initialize explicitly, or from existing ModelCluster.
434434
435435
Parameters
436436
----------
@@ -978,7 +978,7 @@ def estimatepeak(self):
978978
# be estimating and fitting each possible peak type to the data
979979
# and seeing which works best, but for small clusters evaluating
980980
# model quality is generally unreliable, and most peak shapes will
981-
# be approxiately equally good anyway.
981+
# be approximately equally good anyway.
982982
if len(self.model) > 0:
983983
# throw some exception
984984
pass
@@ -1105,7 +1105,7 @@ def fit(
11051105
# after a second peak could potentially explain its residual.
11061106
#
11071107
# This is a tricky point. It is often the case while fitting that an
1108-
# intially good peak becomes less accurate due to greater overlap at
1108+
# initially good peak becomes less accurate due to greater overlap at
11091109
# the edges of the cluster, even as its (calculated) quality improves.
11101110
# This may make combining clusters later more difficult, and so test
11111111
# if the degree by which the new fit is off could perhaps be adequately
@@ -1220,7 +1220,7 @@ def reduce_to(self, x, y):
12201220
-------
12211221
ModelEvaluator or None
12221222
Return ModelEvaluator instance if fit changed, otherwise None."""
1223-
# No reduction neccessary
1223+
# No reduction necessary
12241224
if self.model.value(x) < y:
12251225
logger.debug("reduce_to: No reduction necessary.")
12261226
return None

src/diffpy/srmise/modelevaluators/aicc.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def akaikeweights(aics):
176176
Parameters
177177
----------
178178
aics : array-like
179-
The squence of AIC instances
179+
The sequence of AIC instances
180180
181181
Returns
182182
-------
@@ -195,7 +195,7 @@ def akaikeprobs(aics):
195195
Parameters
196196
----------
197197
aics : array-like
198-
The squence of AIC instances
198+
The sequence of AIC instances
199199
200200
Returns
201201
-------

src/diffpy/srmise/pdfdataset.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def readStr(self, datastring):
295295
if res:
296296
self.metadata["doping"] = float(res.groups()[0])
297297

298-
# parsing gerneral metadata
298+
# parsing general metadata
299299
if metadata:
300300
regexp = r"\b(\w+)\ *=\ *(%(f)s)\b" % rx
301301
while True:
@@ -458,7 +458,7 @@ def copy(self, other=None):
458458

459459

460460
class PDFDataFormatError(Exception):
461-
"""Exception class marking failure to proccess PDF data string."""
461+
"""Exception class marking failure to process PDF data string."""
462462

463463
pass
464464

src/diffpy/srmise/pdfpeakextraction.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def resampledata(self, dr, **kwds):
258258
The effective error may be scaled if class member scale is True.
259259
260260
The method for 'resampling' the uncertainties is interpolation, since insufficient
261-
information exists in a PDFPeakExtraction object to propogate them correctly on the
261+
information exists in a PDFPeakExtraction object to propagate them correctly on the
262262
new grid.
263263
264264
Parameters
@@ -897,7 +897,7 @@ def writepwastr(self, comments):
897897
lines.append("## Extracted Peaks")
898898
lines.append("# Parameters are given in the natural units of the data,")
899899
lines.append("# where width is measured as full-width at half maximum.")
900-
lines.append("# Each line is followd by a comment which gives the index")
900+
lines.append("# Each line is followed by a comment which gives the index")
901901
lines.append("# of the corresponding Peak Function.")
902902
lines.append("#L position fwhm area")
903903
for p in self.extracted.model:

src/diffpy/srmise/peakextraction.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ def readstr(self, datastring):
442442
for s in res[1:]:
443443
self.initial_peaks.append(Peak.factory(s, safepf))
444444

445-
# Instantiating srmise metatdata
445+
# Instantiating srmise metadata
446446

447447
# pf
448448
res = re.search(r"^pf=(.*)$", srmisemetadata, re.M)
@@ -1382,16 +1382,16 @@ def fit_single(self):
13821382
err = np.ones(len(r))
13831383
evaluator = AICc()
13841384

1385-
te = PeakExtraction()
1386-
te.setdata(r, y, None, err)
1387-
te.setvars(rng=[1.51, 10.0], pf=[pf], cres=0.1, effective_dy=1.5 * err)
1388-
te.extract_single()
1385+
peak_extraction = PeakExtraction()
1386+
peak_extraction.setdata(r, y, None, err)
1387+
peak_extraction.setvars(rng=[1.51, 10.0], pf=[pf], cres=0.1, effective_dy=1.5 * err)
1388+
peak_extraction.extract_single()
13891389

13901390
print("--- Actual Peak parameters ---")
13911391
print(ideal_peaks)
13921392

13931393
print("\n--- After extraction ---")
1394-
print(te)
1394+
print(peak_extraction)
13951395

1396-
te.plot()
1396+
peak_extraction.plot()
13971397
input()

src/diffpy/srmise/peaks/gaussian.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def estimate_parameters(self, r, y):
135135
)
136136
guesspars[1] = 0.5 * (sigma_right + sigma_left) * self.sigma2fwhm
137137
else:
138-
# Procede cautiously if min_y == max_y. Without other information
138+
# Proceed cautiously if min_y == max_y. Without other information
139139
# we choose the center of the cluster as the peak center, and make
140140
# sure the peak has died down by the time it reaches the edge of
141141
# the data.
@@ -261,7 +261,7 @@ def _jacobianraw(self, pars, r, free):
261261
if free[2]:
262262
# derivative with respect to peak area
263263
# abs'(x)=sign(x) for real x except at 0 where it is undetermined. Since any real peak necessarily has
264-
# non-zero area and the function is paramaterized such that values of either sign represent equivalent
264+
# non-zero area and the function is parameterized such that values of either sign represent equivalent
265265
# curves I arbitrarily choose positive sign for pars[2]==0 in order to
266266
# push the system back into a realistic parameter space should this improbable scenario occur.
267267
# jacobian[2] = sign(pars[2])*exp_p

0 commit comments

Comments
 (0)