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

Update pre-commit config and change the code accordingly #60

Merged
merged 4 commits into from
May 31, 2023
Merged
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
84 changes: 65 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,66 @@
# # Install pre-commit hooks via
# pre-commit install
---
ci:
autoupdat_schedule: quarterly

- repo: local
hooks:
# yapf = yet another python formatter
- id: yapf
name: yapf
entry: yapf
language: system
types: [python]
args: ["-i"]

# prospector: collection of linters
- id: prospector
language: system
types: [file, python]
name: prospector
description: "This hook runs Prospector: https://github.com/landscapeio/prospector"
entry: prospector
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: [--profile, black, --filter-files]
- repo: https://github.com/PyCQA/autoflake
rev: v2.1.1
hooks:
- id: autoflake
- repo: https://github.com/asottile/pyupgrade
rev: v3.4.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
language_version: python3 # Should be a command that runs python3.6+
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
args: [--count, --show-source, --statistics]
additional_dependencies:
- flake8-bugbear
- flake8-builtins
- flake8-comprehensions
- flake8-debugger
- flake8-logging-format
- pep8-naming
- pyflakes
- tryceratops
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
hooks:
- id: mypy
additional_dependencies:
- types-click-spinner
- types-requests
- types-tabulate
- types-toml
- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.3
hooks:
- id: yamlfmt
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.2.0
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
hooks:
- id: nbstripout
19 changes: 0 additions & 19 deletions .prospector.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To get an idea of how it works, please [check out the videos](https://www.youtub

## Uploading a new structure
File formats compatible with [ASE](https://wiki.fysik.dtu.dk/ase/) can be used.
In the example a .mol file for a structure is generated with ChemDraw.
In the example a .mol file for a structure is generated with ChemDraw.

The structure is uploaded, a warning message is provided if similar structures were already computed.

Expand Down
Empty file removed __init__.py
Empty file.
4 changes: 1 addition & 3 deletions compare.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"def make_plots(pk_list):\n",
Expand Down
53 changes: 6 additions & 47 deletions export_structure.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,9 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7834195bf63045f38d46585f64d12e3f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"_ColormakerRegistry()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"%aiida\n",
"from aiidalab_widgets_base import viewer\n",
Expand All @@ -28,45 +13,19 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b13b606b7c574f279828ee27314fffdf",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"StructureDataVisualizer(children=(NGLWidget(), HBox(children=(Dropdown(description='File format:', options=('x…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"uuid = urlparse.parse_qs(urlparse.urlsplit(jupyter_notebook_url).query)['uuid'][0]\n",
"display(viewer(load_node(uuid=uuid)))"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'676167bc-1bae-4b70-a5cc-d813731f1db2'"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"uuid"
]
Expand Down
9 changes: 3 additions & 6 deletions nanoribbon/editors/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
"""Nanoribbon AiiDA lab viewers."""
# pylint: disable=unused-import,wrong-import-position
"""Nanoribbon AiiDAlab viewers."""

from __future__ import absolute_import
from aiida import load_profile
load_profile()
from .replicate import NanoribbonReplicateEditor

from .replicate import NanoribbonReplicateEditor
__all__ = ["NanoribbonReplicateEditor"]
56 changes: 21 additions & 35 deletions nanoribbon/editors/replicate.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,34 @@
import numpy as np
from numpy.linalg import norm
from ase import Atoms
from ase.data import covalent_radii
from ase.neighborlist import NeighborList
import ase.neighborlist
import scipy.stats
from scipy.constants import physical_constants
import itertools
from IPython.display import display, clear_output, HTML
import nglview
import ipywidgets as ipw

from traitlets import HasTraits, Instance, Dict, Unicode, dlink, link, observe
from aiidalab_widgets_base import StructureManagerWidget
from ase import Atoms
from traitlets import Instance


class NanoribbonReplicateEditor(ipw.VBox):
structure = Instance(Atoms, allow_none=True)
def __init__(self, title=''):

def __init__(self, title=""):
self.title = title
self._molecule = None
self.nx_slider = ipw.IntSlider(description="nx", min=1, max=6, continuous_update=False)

self.nx_slider = ipw.IntSlider(
description="nx", min=1, max=6, continuous_update=False
)

self.create_bttn = ipw.Button(description="Replicate")
self.create_bttn.on_click(self.replicate)
self.info = ipw.HTML('')
super().__init__(children=[
ipw.HBox([self.nx_slider, self.create_bttn]),
self.info,
])

self.info = ipw.HTML("")
super().__init__(
children=[
ipw.HBox([self.nx_slider, self.create_bttn]),
self.info,
]
)

def replicate(self, _=None):
"""Create slab and remember the last molecule used."""
#sa = StructureAnalyzer()
#sa.structure = self.molecule
self.info.value = ''
# sa = StructureAnalyzer()
# sa.structure = self.molecule
self.info.value = ""
atoms = self.structure.copy()
nx = self.nx_slider.value
self.nx_slider.value

self.structure = atoms.repeat((self.nx_slider.value, 1, 1))

# @observe('molecule')
# def on_struct_change(self, change=None):
# """Selected molecule from structure."""
#
# if self.molecule:
# self.nx_slider.value = 1
19 changes: 10 additions & 9 deletions nanoribbon/viewers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""Nanoribbon AiiDA lab viewers."""
# pylint: disable=unused-import,wrong-import-position

from __future__ import absolute_import
from aiida import load_profile
load_profile()
"""Nanoribbon AiiDAlab viewers."""

from .cdxml2gnr import CdxmlUpload2GnrWidget
from .pdos_computed import NanoribbonPDOSWidget
from .search import NanoribbonSearchWidget
from .show_computed import NanoribbonShowWidget
from .pdos_computed import NanoribbonPDOSWidget
#from .smiles2gnr import Smiles2GnrWidget
from .cdxml2gnr import CdxmlUpload2GnrWidget

__all__ = [
"CdxmlUpload2GnrWidget",
"NanoribbonPDOSWidget",
"NanoribbonSearchWidget",
"NanoribbonShowWidget",
]
Loading