Skip to content

Commit e400add

Browse files
authored
Merge pull request #502 from sezelt/black-gh-action
Add a GitHub action that checks for `black` styling Former-commit-id: d9daf5d
2 parents 02eeab1 + 7aa64a4 commit e400add

File tree

83 files changed

+482
-750
lines changed

Some content is hidden

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

83 files changed

+482
-750
lines changed

.github/scripts/update_version.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88
with open(version_file_path, "r") as f:
99
lines = f.readlines()
1010

11-
line_split = lines[0].split('.')
12-
patch_number = line_split[2].split('\'')[0]
11+
line_split = lines[0].split(".")
12+
patch_number = line_split[2].split("'")[0]
1313

1414
# Increment patch number
15-
patch_number = str(int(patch_number) + 1)+'\''
15+
patch_number = str(int(patch_number) + 1) + "'"
1616

1717

18-
new_line = line_split[0]+'.'+line_split[1]+'.'+patch_number
18+
new_line = line_split[0] + "." + line_split[1] + "." + patch_number
1919

20-
with open(version_file_path,"w") as f:
20+
with open(version_file_path, "w") as f:
2121
f.write(new_line)
22-

.github/workflows/black.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Check code style
2+
3+
on:
4+
push:
5+
branches: [ "dev" ]
6+
pull_request:
7+
branches: [ "dev" ]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- uses: psf/black@stable

.github/workflows/build-flake.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will install Python dependencies, run tests and lint with a single version of Python
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33

4-
name: Python application
4+
name: Check module can be imported
55

66
on:
77
push:

.github/workflows/linter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: flake8 Lint
1+
name: Check for errors with flake8
22

33
on:
44
push:

docs/source/conf.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515

1616
import os
1717
import sys
18-
sys.path.insert(0,os.path.dirname(os.getcwd()))
18+
19+
sys.path.insert(0, os.path.dirname(os.getcwd()))
1920
from py4DSTEM import __version__
2021
from datetime import datetime
2122

2223
# -- Project information -----------------------------------------------------
2324

24-
project = 'py4dstem'
25-
copyright = f'{datetime.today().year}, py4DSTEM Development Team'
26-
author = 'Ben Savitsky & Alex Rakowski'
25+
project = "py4dstem"
26+
copyright = f"{datetime.today().year}, py4DSTEM Development Team"
27+
author = "Ben Savitsky & Alex Rakowski"
2728

2829
# The full version, including alpha/beta/rc tags
2930
# release = '0.14.0'
@@ -35,9 +36,7 @@
3536
# Add any Sphinx extension module names here, as strings. They can be
3637
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3738
# ones.
38-
extensions = ['sphinx.ext.autodoc',
39-
'sphinx.ext.napoleon',
40-
'sphinx.ext.intersphinx']
39+
extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon", "sphinx.ext.intersphinx"]
4140

4241
# Other useful extensions
4342
# sphinx_copybutton
@@ -49,7 +48,7 @@
4948

5049

5150
# Add any paths that contain templates here, relative to this directory.
52-
templates_path = ['_templates']
51+
templates_path = ["_templates"]
5352

5453
# List of patterns, relative to source directory, that match files and
5554
# directories to ignore when looking for source files.
@@ -58,18 +57,18 @@
5857

5958
# Set autodoc defaults
6059
autodoc_default_options = {
61-
'members': True,
62-
'member-order': 'bysource',
63-
'special-members': '__init__'
60+
"members": True,
61+
"member-order": "bysource",
62+
"special-members": "__init__",
6463
}
6564

6665
# Include todo items/lists
6766
todo_include_todos = True
6867

69-
#autodoc_member_order = 'bysource'
68+
# autodoc_member_order = 'bysource'
7069

7170

72-
# intersphinx options
71+
# intersphinx options
7372

7473
# intersphinx_mapping = {
7574
# 'emdfile': ('https://pypi.org/project/emdfile/0.0.4/', None)
@@ -80,21 +79,19 @@
8079
# The theme to use for HTML and HTML Help pages. See the documentation for
8180
# a list of builtin themes.
8281
#
83-
html_theme = 'sphinx_rtd_theme'
82+
html_theme = "sphinx_rtd_theme"
8483

8584
# Add any paths that contain custom static files (such as style sheets) here,
8685
# relative to this directory. They are copied after the builtin static files,
8786
# so a file named "default.css" will overwrite the builtin "default.css".
88-
html_static_path = ['../_static']
87+
html_static_path = ["../_static"]
8988

9089

9190
# The name of an image file (relative to this directory) to place at the top
9291
# of the sidebar.
93-
html_logo = '../_static/py4DSTEM_logo.png'
92+
html_logo = "../_static/py4DSTEM_logo.png"
9493

9594
# The name of an image file (within the static path) to use as favicon of the
9695
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
9796
# pixels large.
98-
html_favicon = '../_static/py4DSTEM_logo_vsmall.ico'
99-
100-
97+
html_favicon = "../_static/py4DSTEM_logo_vsmall.ico"

py4DSTEM/braggvectors/braggvector_methods.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,6 @@ def measure_origin_beamstop(
458458
found_center = np.zeros((R_Nx, R_Ny), dtype=bool)
459459
for rx in range(R_Nx):
460460
for ry in range(R_Ny):
461-
462461
# Get data
463462
pl = braggpeaks_masked[rx, ry]
464463
is_paired = np.zeros(len(pl.data), dtype=bool)

py4DSTEM/braggvectors/braggvectors.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ def _populate_instance(self, group):
321321
# standard output display
322322

323323
def __repr__(self):
324-
325324
space = " " * len(self.__class__.__name__) + " "
326325
string = f"{self.__class__.__name__}( "
327326
string += f"A {self.shape}-shaped array of lists of bragg vectors )"

py4DSTEM/braggvectors/diskdetection.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ def _find_Bragg_disks_single(
323323
_return_cc=False,
324324
_template_space="real",
325325
):
326-
327326
# apply filter function
328327
er = "filter_function must be callable"
329328
if filter_function:
@@ -334,7 +333,6 @@ def _find_Bragg_disks_single(
334333
if template is None:
335334
cc = DP
336335
else:
337-
338336
# fourier transform the template
339337
assert _template_space in ("real", "fourier")
340338
if _template_space == "real":
@@ -417,11 +415,9 @@ def _find_Bragg_disks_stack(
417415
maxNumPeaks=100,
418416
_template_space="real",
419417
):
420-
421418
ans = []
422419

423420
for idx in range(dp_stack.shape[0]):
424-
425421
dp = dp_stack[idx, :, :]
426422
peaks = _find_Bragg_disks_single(
427423
dp,
@@ -466,7 +462,6 @@ def _find_Bragg_disks_CPU(
466462
maxNumPeaks=70,
467463
radial_bksb=False,
468464
):
469-
470465
# Make the BraggVectors instance
471466
braggvectors = BraggVectors(datacube.Rshape, datacube.Qshape)
472467

@@ -475,14 +470,13 @@ def _find_Bragg_disks_CPU(
475470

476471
# Loop over all diffraction patterns
477472
# Compute and populate BraggVectors data
478-
for (rx, ry) in tqdmnd(
473+
for rx, ry in tqdmnd(
479474
datacube.R_Nx,
480475
datacube.R_Ny,
481476
desc="Finding Bragg Disks",
482477
unit="DP",
483478
unit_scale=True,
484479
):
485-
486480
# Get a diffraction pattern
487481

488482
# without background subtraction
@@ -538,7 +532,6 @@ def _find_Bragg_disks_CUDA_unbatched(
538532
edgeBoundary=20,
539533
maxNumPeaks=70,
540534
):
541-
542535
# compute
543536
from py4DSTEM.braggvectors.diskdetection_cuda import find_Bragg_disks_CUDA
544537

@@ -584,7 +577,6 @@ def _find_Bragg_disks_CUDA_batched(
584577
edgeBoundary=20,
585578
maxNumPeaks=70,
586579
):
587-
588580
# compute
589581
from py4DSTEM.braggvectors.diskdetection_cuda import find_Bragg_disks_CUDA
590582

@@ -633,7 +625,6 @@ def _find_Bragg_disks_ipp(
633625
edgeBoundary=20,
634626
maxNumPeaks=70,
635627
):
636-
637628
# compute
638629
from py4DSTEM.braggvectors.diskdetection_parallel import find_Bragg_disks_ipp
639630

@@ -684,7 +675,6 @@ def _find_Bragg_disks_dask(
684675
edgeBoundary=20,
685676
maxNumPeaks=70,
686677
):
687-
688678
# compute
689679
from py4DSTEM.braggvectors.diskdetection_parallel import find_Bragg_disks_dask
690680

py4DSTEM/braggvectors/diskdetection_aiml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ def find_Bragg_disks_aiml_serial(
494494
)
495495

496496
# Loop over all diffraction patterns
497-
for (Rx, Ry) in tqdmnd(
497+
for Rx, Ry in tqdmnd(
498498
datacube.R_Nx,
499499
datacube.R_Ny,
500500
desc="Finding Bragg Disks using AI/ML",

py4DSTEM/braggvectors/diskdetection_aiml_cuda.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def find_Bragg_disks_aiml_CUDA(
198198
)
199199

200200
# Loop over all diffraction patterns
201-
for (Rx, Ry) in tqdmnd(
201+
for Rx, Ry in tqdmnd(
202202
datacube.R_Nx,
203203
datacube.R_Ny,
204204
desc="Finding Bragg Disks using AI/ML CUDA",

0 commit comments

Comments
 (0)