Skip to content

Commit

Permalink
Use ruff for code format
Browse files Browse the repository at this point in the history
00
  • Loading branch information
unkcpz committed Jan 17, 2024
1 parent 5f40802 commit e582f92
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 52 deletions.
42 changes: 16 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,31 @@ repos:
- id: yamlfmt
exclude: tests

- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
language_version: python3 # Should be a command that runs python3.6+

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
args: [--count, --show-source, --statistics]
additional_dependencies:
- flake8-bugbear==22.7.1

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: [--profile, black, --filter-files]

- repo: https://github.com/sirosen/check-jsonschema
rev: 0.27.3
hooks:
- id: check-github-workflows

- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
hooks:
- id: nbstripout

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.1
hooks:
- id: nbqa-pyupgrade
args: [--py38-plus]
- id: nbqa-isort
args: [--profile=black]
- id: nbqa-black
- id: nbqa-ruff

- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
hooks:
- id: nbstripout

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.13
hooks:
# Run the linter.
- id: ruff
args: [--fix]
# Run the formatter.
- id: ruff-format
31 changes: 19 additions & 12 deletions qe.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,27 @@
"\n",
" sys.modules[\"pybel\"] = __import__(\"openbabel\", globals(), locals(), [\"pybel\"]).pybel\n",
"except Exception:\n",
" pass"
" pass\n",
"\n",
"import ipywidgets as ipw\n",
"from aiidalab_widgets_base.bug_report import (\n",
" install_create_github_issue_exception_handler,\n",
")\n",
"from importlib_resources import files\n",
"from IPython.display import display\n",
"from jinja2 import Environment\n",
"\n",
"from aiidalab_qe.app import App, static\n",
"from aiidalab_qe.version import __version__"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -45,17 +63,6 @@
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as ipw\n",
"from aiidalab_widgets_base.bug_report import (\n",
" install_create_github_issue_exception_handler,\n",
")\n",
"from importlib_resources import files\n",
"from IPython.display import display\n",
"from jinja2 import Environment\n",
"\n",
"from aiidalab_qe.app import App, static\n",
"from aiidalab_qe.version import __version__\n",
"\n",
"env = Environment()\n",
"\n",
"template = files(static).joinpath(\"welcome.jinja\").read_text()\n",
Expand Down
6 changes: 0 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ description = Perform Quantum ESPRESSO calculations
categories =
quantum

[flake8]
ignore =
E501
W503
E203

[bumpver]
current_version = "v23.10.0"
version_pattern = "v0Y.0M.PATCH[PYTAGNUM]"
Expand Down
2 changes: 1 addition & 1 deletion src/aiidalab_qe/app/structure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(self, description=None, **kwargs):
self.message_area,
self.confirm_button,
],
**kwargs
**kwargs,
)

@traitlets.default("state")
Expand Down
4 changes: 1 addition & 3 deletions src/aiidalab_qe/common/node_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ def _update_displayed_structure(self, change):
def _update_structure_viewer(self, change):
"""Update the view if displayed_structure trait was modified."""
with self.hold_trait_notifications():
for (
comp_id
) in self._viewer._ngl_component_ids: # pylint: disable=protected-access
for comp_id in self._viewer._ngl_component_ids: # pylint: disable=protected-access
self._viewer.remove_component(comp_id)
self.selection = list()
if change["new"] is not None:
Expand Down
5 changes: 3 additions & 2 deletions src/aiidalab_qe/common/setup_pseudos.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,9 @@ def install(

except Timeout:
# Assume that the installation was triggered by a different process.
yield "Installation was already started elsewhere, waiting for it to finish...", ProgressBar.AnimationRate(
1.0
yield (
"Installation was already started elsewhere, waiting for it to finish...",
ProgressBar.AnimationRate(1.0),
)
with FileLock(FN_LOCKFILE, timeout=120):
if len(pseudos_to_install()) > 0:
Expand Down
4 changes: 2 additions & 2 deletions src/aiidalab_qe/plugins/bands/workchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def generate_kpath_2d(structure, kpoints_distance, kpath_2d):
a2 = reciprocal_cell[1]
norm_a1 = np.linalg.norm(a1)
norm_a2 = np.linalg.norm(a2)
cos_gamma = a1.dot(a2) / (
norm_a1 * norm_a2
cos_gamma = (
a1.dot(a2) / (norm_a1 * norm_a2)
) # Angle between a1 and a2 # like in https://pubs.acs.org/doi/10.1021/acs.jpclett.2c02972
gamma = np.arccos(cos_gamma)
eta = (1 - (norm_a1 / norm_a2) * cos_gamma) / (2 * np.power(np.sin(gamma), 2))
Expand Down

0 comments on commit e582f92

Please sign in to comment.