Skip to content

Commit 16e8b7d

Browse files
authored
Merge pull request #6 from 8bitsam/black
Black, flake8, and pre-commit fixes
2 parents 2eb10eb + 3915c8d commit 16e8b7d

File tree

19 files changed

+160
-2016
lines changed

19 files changed

+160
-2016
lines changed

.codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# show coverage in CI status, not as a comment.
1+
# show coverage in CI status, not as a comment.
22
comment: off
33
coverage:
44
status:

.flake8

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ exclude =
44
__pycache__,
55
build,
66
dist,
7-
versioneer.py,
8-
fourigui/_version.py,
9-
docs/source/conf.py
7+
doc/source/conf.py
108
max-line-length = 115
9+
# Ignore some style 'errors' produced while formatting by 'black'
10+
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#labels-why-pycodestyle-warnings
11+
extend-ignore = E203

.pre-commit-config.yaml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,44 @@
11
default_language_version:
22
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
312
repos:
13+
- repo: https://github.com/pre-commit/pre-commit-hooks
14+
rev: v4.6.0
15+
hooks:
16+
- id: check-yaml
17+
exclude: 'conda-recipe/meta\.yaml$'
18+
- id: end-of-file-fixer
19+
- id: trailing-whitespace
20+
exclude: '\.(rst|txt)$'
421
- repo: https://github.com/psf/black
5-
rev: 24.8.0
22+
rev: 24.4.2
623
hooks:
724
- id: black
8-
- repo: https://github.com/pre-commit/pre-commit-hooks
9-
rev: v2.0.0
25+
- repo: https://github.com/pycqa/flake8
26+
rev: 7.0.0
1027
hooks:
1128
- id: flake8
29+
- repo: https://github.com/pycqa/isort
30+
rev: 5.13.2
31+
hooks:
32+
- id: isort
33+
args: ["--profile", "black"]
1234
- repo: https://github.com/kynan/nbstripout
1335
rev: 0.7.1
1436
hooks:
1537
- id: nbstripout
38+
- repo: https://github.com/pre-commit/pre-commit-hooks
39+
rev: v4.4.0
40+
hooks:
41+
- id: no-commit-to-branch
42+
name: Prevent Commit to Main Branch
43+
args: ["--branch", "main"]
44+
stages: [pre-commit]

AUTHORS.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,3 @@ Contributors
3131
------------
3232

3333
None yet. Why not be the first? See: CONTRIBUTING.rst
34-
35-

CONTRIBUTING.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,3 @@ Before you submit a pull request, check that it meets these guidelines:
101101
3. The pull request should work for Python 2.7, 3.3, 3.4, 3.5 and for PyPy. Check
102102
https://travis-ci.org/sbillinge/fourigui/pull_requests
103103
and make sure that the tests pass for all supported Python versions.
104-

README.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,3 @@ For more information on diffpy.structure please visit the project web-page
9898
http://www.diffpy.org/
9999

100100
or email Prof. Simon Billinge at [email protected].
101-

conda-recipe/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ test:
5858
about:
5959
home: https://github.com/diffpy/diffpy.fourigui
6060
#TODO add short description
61-
summary:
61+
summary:
6262
license: Modified BSD License
6363
license_file: LICENSE.txt
6464

devutils/makesdist

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
to a root user and modification time is set to the git commit time.
55
"""
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
13+
14+
from setup import FALLBACK_VERSION, versiondata
1315

1416
BASEDIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
1517
sys.path.insert(0, BASEDIR)
1618

17-
from setup import versiondata, FALLBACK_VERSION
18-
1919
timestamp = versiondata.getint("DEFAULT", "timestamp")
2020

2121
vfb = versiondata.get("DEFAULT", "version").split(".post")[0] + ".post0"

further_processing_code/FFT.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import numpy as np
21
import h5py
2+
import numpy as np
33

44

55
def fourier_transformation(fftholder):

further_processing_code/symm_op.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
# for different cubic structures one can easily change the symmetry operation parameters in line 106
1212
# more complex textures or crystal strucutes require more effort to derive appropriate symmetry operations
1313

14-
import numpy as np
14+
from time import time
15+
1516
import h5py
17+
import numpy as np
1618
from scipy.ndimage import rotate
17-
from time import time
1819

1920

2021
def load_data(fname):
@@ -37,10 +38,11 @@ def save_data(fname, arr):
3738

3839
def symm_op(arr, angle, inversion):
3940
"""
40-
Perform symmetry operations on data set "arr". arr will be inverted about the center voxel and rotated with "angle"
41-
about the z axis by iterating the 2D planes in the 3D data set arr along the z axis. rotation of the planes in the
42-
data set is perfomed by scipy.ndimage.rotate. arr might contain nan values which scipy.ndimage.rotate cannot
43-
operate. therefore the nan values in arr will be converted to float values 0.0 and denoted by 3D array "isnanarr_so".
41+
Perform symmetry operations on data set "arr". arr will be inverted about the center voxel and rotated with
42+
"angle" about the z axis by iterating the 2D planes in the 3D data set arr along the z axis. rotation of the
43+
planes in the data set is perfomed by scipy.ndimage.rotate. arr might contain nan values which
44+
scipy.ndimage.rotate cannot operate. therefore the nan values in arr will be converted to float values 0.0 and
45+
denoted by 3D array "isnanarr_so".
4446
:param arr: data set in h5 type
4547
:param angle: rotate arr angle degrees about the z axis. put False if no rotation is intended.
4648
:param inversion: Boolian variable if arr is supposed to be inverted about center voxel.
@@ -107,8 +109,8 @@ def main(arr, symm_op_params):
107109
"""
108110
Perform symmertry operations specified in symm_op_params and bin together the symmetry operated data sets.
109111
:param arr: data set in h5 type
110-
:param symm_op_params: list of tuples with the supposed angle for the rotation in degree and False if no rotation
111-
is intended and True or False if data set should be inverted or not.
112+
:param symm_op_params: list of tuples with the supposed angle for the rotation in degree and False if no
113+
rotation is intended and True or False if data set should be inverted or not.
112114
:return arr: average of all symmetry operated data sets
113115
"""
114116
holder = np.zeros_like(arr)

requirements/run.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
matplotlib
22
h5py
33
scipy
4-

setup.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
in reciprocal space
88
99
Packages: diffpy.fourigui
10-
Scripts: fourgui -
10+
Scripts: fourgui -
1111
"""
1212

13-
import sys
1413
import os
1514
import re
16-
from setuptools import setup, find_packages
15+
import sys
1716

17+
from setuptools import find_packages, setup
1818

1919
# Use this version when git data are not available, like in git zip archive.
2020
# Update when tagging a new release.
@@ -31,7 +31,7 @@
3131

3232

3333
def gitinfo():
34-
from subprocess import Popen, PIPE
34+
from subprocess import PIPE, Popen
3535

3636
kw = dict(stdout=PIPE, cwd=MYDIR, universal_newlines=True)
3737
proc = Popen(["git", "describe", "--match=v[[:digit:]]*"], **kw)
@@ -90,8 +90,11 @@ def getversioncfg():
9090
long_description = fp.read()
9191

9292

93+
def dest(p):
94+
return os.path.normpath(p.replace("_build", ""))
95+
96+
9397
def datafiles_html():
94-
dest = lambda p: os.path.normpath(p.replace("_build", ""))
9598
rv = [
9699
(dest(t), [os.path.join(t, f) for f in fl])
97100
for t, d, fl in os.walk("doc/manual/_build/html")

src/diffpy/fourigui/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,3 @@
1616
"""\
1717
'{{cookiecutter.short_description}}'
1818
"""
19-
# package version
20-
from diffpy.fourigui.version import __version__
21-
22-
from diffpy.fourigui.fourigui import main

0 commit comments

Comments
 (0)