Skip to content

Commit 58a94de

Browse files
authored
Merge pull request #70 from stevenhua0320/c1
pre-commit run with no manual change
2 parents 48b3bbb + be6c14a commit 58a94de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+334
-245
lines changed

.flake8

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[flake8]
2+
exclude =
3+
.git,
4+
__pycache__,
5+
build,
6+
dist,
7+
doc/source/conf.py,
8+
*/doc/source/conf.py,
9+
hooks/post_gen_project.py,
10+
*/__init__.py,
11+
*/debug.py
12+
builtins = cookiecutter
13+
max-line-length = 115
14+
# Ignore some style 'errors' produced while formatting by 'black' (see link below)
15+
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#labels-why-pycodestyle-warnings
16+
extend-ignore = E203

.pre-commit-config.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
default_language_version:
2+
python: python3
3+
ci:
4+
autofix_commit_msg: |
5+
[pre-commit.ci] auto fixes from pre-commit hooks
6+
autofix_prs: true
7+
autoupdate_branch: 'pre-commit-autoupdate'
8+
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
9+
autoupdate_schedule: monthly
10+
skip: [no-commit-to-branch]
11+
submodules: false
12+
repos:
13+
- repo: https://github.com/pre-commit/pre-commit-hooks
14+
rev: v4.6.0
15+
hooks:
16+
- id: check-yaml
17+
exclude: 'environment.yml'
18+
- id: end-of-file-fixer
19+
- id: trailing-whitespace
20+
exclude: '\.(rst|txt)$'
21+
- repo: https://github.com/psf/black
22+
rev: 24.4.2
23+
hooks:
24+
- id: black
25+
exclude: '.*\.py'
26+
- repo: https://github.com/pycqa/flake8
27+
rev: 7.0.0
28+
hooks:
29+
- id: flake8
30+
- repo: https://github.com/pycqa/isort
31+
rev: 5.13.2
32+
hooks:
33+
- id: isort
34+
args: ["--profile", "black"]
35+
- repo: https://github.com/kynan/nbstripout
36+
rev: 0.7.1
37+
hooks:
38+
- id: nbstripout
39+
- repo: https://github.com/pre-commit/pre-commit-hooks
40+
rev: v4.4.0
41+
hooks:
42+
- id: no-commit-to-branch
43+
name: Prevent Commit to Main Branch
44+
args: ["--branch", "main"]
45+
stages: [pre-commit]

conda-recipe/run_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
22

33
import diffpy.srfit.tests
4+
45
assert diffpy.srfit.tests.test().wasSuccessful()

devutils/makesdist

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,57 @@
11
#!/usr/bin/env python
22

3-
'''Create source distribution tar.gz archive, where each file belongs
3+
"""Create source distribution tar.gz archive, where each file belongs
44
to a root user and modification time is set to the git commit time.
5-
'''
5+
"""
66

7-
import sys
7+
import glob
8+
import gzip
89
import os
910
import subprocess
10-
import glob
11+
import sys
1112
import tarfile
12-
import gzip
1313

1414
BASEDIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
1515
sys.path.insert(0, BASEDIR)
1616

17-
from setup import versiondata, FALLBACK_VERSION
18-
timestamp = versiondata.getint('DEFAULT', 'timestamp')
17+
from setup import FALLBACK_VERSION, versiondata
1918

20-
vfb = versiondata.get('DEFAULT', 'version').split('.post')[0] + '.post0'
19+
timestamp = versiondata.getint("DEFAULT", "timestamp")
20+
21+
vfb = versiondata.get("DEFAULT", "version").split(".post")[0] + ".post0"
2122
emsg = "Invalid FALLBACK_VERSION. Expected %r got %r."
2223
assert vfb == FALLBACK_VERSION, emsg % (vfb, FALLBACK_VERSION)
2324

25+
2426
def inform(s):
2527
sys.stdout.write(s)
2628
sys.stdout.flush()
2729
return
2830

31+
2932
inform('Run "setup.py sdist --formats=tar" ')
30-
cmd_sdist = [sys.executable] + 'setup.py sdist --formats=tar'.split()
31-
ec = subprocess.call(cmd_sdist, cwd=BASEDIR, stdout=open(os.devnull, 'w'))
32-
if ec: sys.exit(ec)
33+
cmd_sdist = [sys.executable] + "setup.py sdist --formats=tar".split()
34+
ec = subprocess.call(cmd_sdist, cwd=BASEDIR, stdout=open(os.devnull, "w"))
35+
if ec:
36+
sys.exit(ec)
3337
inform("[done]\n")
3438

35-
tarname = max(glob.glob(BASEDIR + '/dist/*.tar'), key=os.path.getmtime)
39+
tarname = max(glob.glob(BASEDIR + "/dist/*.tar"), key=os.path.getmtime)
3640

3741
tfin = tarfile.open(tarname)
38-
fpout = gzip.GzipFile(tarname + '.gz', 'w', mtime=0)
39-
tfout = tarfile.open(fileobj=fpout, mode='w')
42+
fpout = gzip.GzipFile(tarname + ".gz", "w", mtime=0)
43+
tfout = tarfile.open(fileobj=fpout, mode="w")
44+
4045

4146
def fixtarinfo(tinfo):
4247
tinfo.uid = tinfo.gid = 0
43-
tinfo.uname = tinfo.gname = 'root'
48+
tinfo.uname = tinfo.gname = "root"
4449
tinfo.mtime = timestamp
4550
tinfo.mode &= ~0o022
4651
return tinfo
4752

48-
inform('Filter %s --> %s.gz ' % (2 * (os.path.basename(tarname),)))
53+
54+
inform("Filter %s --> %s.gz " % (2 * (os.path.basename(tarname),)))
4955
for ti in tfin:
5056
tfout.addfile(fixtarinfo(ti), tfin.extractfile(ti))
5157

doc/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,3 @@ clean:
3131
rm -rf diffpy.srfitapi
3232
rm -f srfit_examples.zip
3333
$(MAKE) -C devmanual $@
34-

doc/examples/coreshellnp.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,11 @@
2222
"""
2323

2424
import numpy
25-
from scipy.optimize import leastsq
26-
2725
from pyobjcryst import loadCrystal
26+
from scipy.optimize import leastsq
2827

28+
from diffpy.srfit.fitbase import FitContribution, FitRecipe, FitResults, Profile
2929
from diffpy.srfit.pdf import PDFGenerator, PDFParser
30-
from diffpy.srfit.fitbase import Profile
31-
from diffpy.srfit.fitbase import FitContribution, FitRecipe
32-
from diffpy.srfit.fitbase import FitResults
3330

3431
# Example Code
3532

@@ -73,7 +70,7 @@ def makeRecipe(stru1, stru2, datname):
7370
# and a spherical shell CF for the shell. Since this is set up as two
7471
# phases, we implicitly assume that the core-shell correlations contribute
7572
# very little to the PDF.
76-
from diffpy.srfit.pdf.characteristicfunctions import sphericalCF, shellCF
73+
from diffpy.srfit.pdf.characteristicfunctions import shellCF, sphericalCF
7774
contribution.registerFunction(sphericalCF, name="f_CdS")
7875
contribution.registerFunction(shellCF, name="f_ZnS")
7976

doc/examples/crystalpdf.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,11 @@
2626
"""
2727

2828
import numpy
29+
from gaussianrecipe import scipyOptimize
2930

30-
from diffpy.structure import Structure
31+
from diffpy.srfit.fitbase import FitContribution, FitRecipe, FitResults, Profile
3132
from diffpy.srfit.pdf import PDFGenerator, PDFParser
32-
from diffpy.srfit.fitbase import Profile
33-
from diffpy.srfit.fitbase import FitContribution, FitRecipe
34-
from diffpy.srfit.fitbase import FitResults
35-
36-
from gaussianrecipe import scipyOptimize
33+
from diffpy.structure import Structure
3734

3835
####### Example Code
3936

doc/examples/crystalpdfall.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,11 @@
2020
"""
2121

2222
import numpy
23-
23+
from gaussianrecipe import scipyOptimize
2424
from pyobjcryst import loadCrystal
2525

26+
from diffpy.srfit.fitbase import FitContribution, FitRecipe, FitResults, Profile
2627
from diffpy.srfit.pdf import PDFGenerator, PDFParser
27-
from diffpy.srfit.fitbase import Profile
28-
from diffpy.srfit.fitbase import FitContribution, FitRecipe
29-
from diffpy.srfit.fitbase import FitResults
30-
31-
from gaussianrecipe import scipyOptimize
3228

3329
####### Example Code
3430

doc/examples/crystalpdfobjcryst.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,12 @@
2020
by the ObjCrystCrystalParSet structure adapter.
2121
"""
2222

23+
from crystalpdf import plotResults
24+
from gaussianrecipe import scipyOptimize
2325
from pyobjcryst import loadCrystal
2426

27+
from diffpy.srfit.fitbase import FitContribution, FitRecipe, FitResults, Profile
2528
from diffpy.srfit.pdf import PDFGenerator, PDFParser
26-
from diffpy.srfit.fitbase import Profile
27-
from diffpy.srfit.fitbase import FitContribution, FitRecipe
28-
from diffpy.srfit.fitbase import FitResults
29-
30-
from gaussianrecipe import scipyOptimize
31-
from crystalpdf import plotResults
3229

3330
####### Example Code
3431

doc/examples/crystalpdftwodata.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,11 @@
2222
"""
2323

2424
import numpy
25-
25+
from gaussianrecipe import scipyOptimize
2626
from pyobjcryst import loadCrystal
2727

28+
from diffpy.srfit.fitbase import FitContribution, FitRecipe, FitResults, Profile
2829
from diffpy.srfit.pdf import PDFGenerator, PDFParser
29-
from diffpy.srfit.fitbase import Profile
30-
from diffpy.srfit.fitbase import FitContribution, FitRecipe
31-
from diffpy.srfit.fitbase import FitResults
32-
33-
from gaussianrecipe import scipyOptimize
3430

3531
####### Example Code
3632

doc/examples/crystalpdftwophase.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,11 @@
2222
"""
2323

2424
import numpy
25-
25+
from gaussianrecipe import scipyOptimize
2626
from pyobjcryst import loadCrystal
2727

28+
from diffpy.srfit.fitbase import FitContribution, FitRecipe, FitResults, Profile
2829
from diffpy.srfit.pdf import PDFGenerator, PDFParser
29-
from diffpy.srfit.fitbase import Profile
30-
from diffpy.srfit.fitbase import FitContribution, FitRecipe
31-
from diffpy.srfit.fitbase import FitResults
32-
33-
from gaussianrecipe import scipyOptimize
3430

3531
####### Example Code
3632

doc/examples/data/ni.iq

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2462,4 +2462,3 @@
24622462
26.123511 0
24632463
26.133371 0
24642464
26.143228 0
2465-

doc/examples/debyemodel.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@
3434
"""
3535

3636
import numpy
37-
38-
from diffpy.srfit.fitbase import FitContribution, FitRecipe, Profile, FitResults
39-
4037
from gaussianrecipe import scipyOptimize
4138

39+
from diffpy.srfit.fitbase import FitContribution, FitRecipe, FitResults, Profile
40+
4241
# The data
4342
data = """\
4443
015.0 0.00334 0.00013

doc/examples/debyemodelII.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
done.
3535
"""
3636

37-
from diffpy.srfit.fitbase import FitRecipe, FitResults
38-
3937
from debyemodel import makeRecipe, scipyOptimize
4038

39+
from diffpy.srfit.fitbase import FitRecipe, FitResults
40+
4141
####### Example Code
4242

4343
def makeRecipeII():

doc/examples/ellipsoidsas.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616
"""Example of a refinement of SAS I(Q) data to an ellipsoidal model.
1717
"""
1818

19-
from diffpy.srfit.sas import SASGenerator, SASParser
20-
from diffpy.srfit.fitbase import FitContribution, FitRecipe
21-
from diffpy.srfit.fitbase import FitResults, Profile
22-
2319
from gaussianrecipe import scipyOptimize
2420

21+
from diffpy.srfit.fitbase import FitContribution, FitRecipe, FitResults, Profile
22+
from diffpy.srfit.sas import SASGenerator, SASParser
23+
2524
####### Example Code
2625

2726
def makeRecipe(datname):

doc/examples/gaussiangenerator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@
4141

4242
from numpy import exp
4343

44-
from diffpy.srfit.fitbase import ProfileGenerator, Profile
45-
from diffpy.srfit.fitbase import FitContribution, FitRecipe
44+
from diffpy.srfit.fitbase import FitContribution, FitRecipe, Profile, ProfileGenerator
4645

4746
####### Example Code
4847

doc/examples/gaussianrecipe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
from __future__ import print_function
4848

49-
from diffpy.srfit.fitbase import FitContribution, FitRecipe, Profile, FitResults
49+
from diffpy.srfit.fitbase import FitContribution, FitRecipe, FitResults, Profile
5050

5151
####### Example Code
5252

doc/examples/interface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
the diffpy.srfit.interface.interface.py module.
2020
"""
2121

22-
from diffpy.srfit.fitbase import FitContribution, FitRecipe, Profile, FitResults
22+
from diffpy.srfit.fitbase import FitContribution, FitRecipe, FitResults, Profile
2323

2424
####### Example Code
2525

doc/examples/npintensity.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,17 @@
4545
from __future__ import print_function
4646

4747
import numpy
48+
from gaussianrecipe import scipyOptimize
4849

49-
from diffpy.srfit.fitbase import ProfileGenerator, Profile
50-
from diffpy.srfit.fitbase import FitContribution, FitRecipe
51-
from diffpy.srfit.fitbase import FitResults
50+
from diffpy.srfit.fitbase import (
51+
FitContribution,
52+
FitRecipe,
53+
FitResults,
54+
Profile,
55+
ProfileGenerator,
56+
)
5257
from diffpy.srfit.structure.diffpyparset import DiffpyStructureParSet
5358

54-
from gaussianrecipe import scipyOptimize
55-
5659
####### Example Code
5760

5861
class IntensityGenerator(ProfileGenerator):

doc/examples/npintensityII.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@
3535
"""
3636

3737
import numpy
38-
39-
from diffpy.srfit.fitbase import FitContribution, FitRecipe, Profile, FitResults
40-
from npintensity import IntensityGenerator
41-
from npintensity import makeData
42-
4338
from gaussianrecipe import scipyOptimize
39+
from npintensity import IntensityGenerator, makeData
40+
41+
from diffpy.srfit.fitbase import FitContribution, FitRecipe, FitResults, Profile
4442

4543
####### Example Code
4644

doc/examples/nppdfcrystal.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,12 @@
2626
"""
2727

2828
import numpy
29-
29+
from gaussianrecipe import scipyOptimize
3030
from pyobjcryst import loadCrystal
3131

32+
from diffpy.srfit.fitbase import FitContribution, FitRecipe, FitResults, Profile
3233
from diffpy.srfit.pdf import PDFGenerator, PDFParser
33-
from diffpy.srfit.fitbase import Profile
34-
from diffpy.srfit.fitbase import FitContribution, FitRecipe
35-
from diffpy.srfit.fitbase import FitResults
3634

37-
from gaussianrecipe import scipyOptimize
3835

3936
def makeRecipe(ciffile, grdata):
4037
"""Make a recipe to model a crystal-like nanoparticle PDF."""

0 commit comments

Comments
 (0)