Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F811, F523/F524, F841, F741 - Corrections in crystal.py #571

Closed
Closed
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
23 changes: 23 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[flake8]
extend-ignore =
E114,
E115,
E116,
E201,
E202,
E203,
E204,
E231,
E265,
E266,
E303,
E402,
E501,
exclude =
; __init__.py # totally ignore __init__.py files
setup.py # ignore setup.py file
docs/
#F401 ignore unused imports in __init__.py files
#F403 ignore unable to detect undefined names from import *
per-file-ignores =
__init__.py:F401,F403
2 changes: 0 additions & 2 deletions .github/linters/.flake8

This file was deleted.

40 changes: 0 additions & 40 deletions .github/workflows/build-flake.yml

This file was deleted.

17 changes: 11 additions & 6 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check for errors with flake8
name: Lint with super-linter@v5-slim

on:
push:
Expand All @@ -17,9 +17,14 @@ jobs:
fetch-depth: 0

- name: Lint Code Base
uses: github/super-linter@v4
uses: super-linter/super-linter/slim@v5 # updated to latest slim as quicker to download
env:
VALIDATE_ALL_CODEBASE: false
VALIDATE_PYTHON_FLAKE8: true
DEFAULT_BRANCH: "dev"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_ALL_CODEBASE: false # only check changes
VALIDATE_PYTHON_FLAKE8: true # lint with flake8
DEFAULT_BRANCH: "dev" # set default branch to dev
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # for github things
# FILTER_REGEX_EXCLUDE: .*test/.* # exclude test dirs
FILTER_REGEX_EXCLUDE: .*__init__.py/.* # exclude test dirs
FILTER_REGEX_INCLUDE: .*py4DSTEM/.* # only look for py4DSTEM
LINTER_RULES_PATH: / # set toplevel dir as the path to look for rules
PYTHON_FLAKE8_CONFIG_FILE: .flake8 # set specific config file
34 changes: 9 additions & 25 deletions py4DSTEM/process/diffraction/crystal.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class Crystal:
save_ang_file,
symmetry_reduce_directions,
orientation_map_to_orix_CrystalMap,
save_ang_file,
)

from py4DSTEM.process.diffraction.crystal_viz import (
Expand Down Expand Up @@ -433,41 +432,31 @@ def from_unitcell_parameters(
elif lattice_type == "hexagonal":
assert (
len(latt_params) == 2
), "2 lattice parametere are expected for hexagonal: a, c, but given {len(latt_params)}".format(
len(latt_params)
)
), f"2 lattice parametere are expected for hexagonal: a, c, but given {len(latt_params)}"
lattice = mg.core.Lattice.hexagonal(latt_params[0], latt_params[1])
elif lattice_type == "tetragonal":
assert (
len(latt_params) == 2
), "2 lattice parametere are expected for tetragonal: a, c, but given {len(latt_params)}".format(
len(latt_params)
)
), f"2 lattice parametere are expected for tetragonal: a, c, but given {len(latt_params)}"
lattice = mg.core.Lattice.tetragonal(latt_params[0], latt_params[1])
elif lattice_type == "orthorhombic":
assert (
len(latt_params) == 3
), "3 lattice parametere are expected for orthorhombic: a, b, c, but given {len(latt_params)}".format(
len(latt_params)
)
), f"3 lattice parametere are expected for orthorhombic: a, b, c, but given {len(latt_params)}"
lattice = mg.core.Lattice.orthorhombic(
latt_params[0], latt_params[1], latt_params[2]
)
elif lattice_type == "monoclinic":
assert (
len(latt_params) == 4
), "4 lattice parametere are expected for monoclinic: a, b, c, beta, but given {len(latt_params)}".format(
len(latt_params)
)
), f"4 lattice parametere are expected for monoclinic: a, b, c, beta, but given {len(latt_params)}"
lattice = mg.core.Lattice.monoclinic(
latt_params[0], latt_params[1], latt_params[2], latt_params[3]
)
else:
assert (
len(latt_params) == 6
), "all 6 lattice parametere are expected: a, b, c, alpha, beta, gamma, but given {len(latt_params)}".format(
len(latt_params)
)
), f"all 6 lattice parametere are expected: a, b, c, alpha, beta, gamma, but given {len(latt_params)}"
lattice = mg.core.Lattice.from_parameters(
latt_params[0],
latt_params[1],
Expand Down Expand Up @@ -659,9 +648,6 @@ def generate_diffraction_pattern(
print("Accelerating voltage not set. Assuming 300 keV!")
self.setup_diffraction(300e3)

# Tolerance for angular tests
tol = 1e-6

# Parse orientation inputs
if orientation is not None:
if ind_orientation is None:
Expand Down Expand Up @@ -720,9 +706,9 @@ def generate_diffraction_pattern(
gy_proj = g_diff[1, keep_int]

# Diffracted peak labels
h = hkl[0, keep_int]
k = hkl[1, keep_int]
l = hkl[2, keep_int]
h = hkl[0, keep_int] # noqa: E741
k = hkl[1, keep_int] # noqa: E741
l = hkl[2, keep_int] # noqa: E741

# Output as PointList
if keep_qz:
Expand Down Expand Up @@ -815,9 +801,7 @@ def generate_ring_pattern(
)

# check accelerating voltage
if hasattr(self, "accel_voltage"):
accelerating_voltage = self.accel_voltage
else:
if not hasattr(self, "accel_voltage"):
sezelt marked this conversation as resolved.
Show resolved Hide resolved
self.accel_voltage = 300e3
print("Accelerating voltage not set. Assuming 300 keV!")

Expand Down