Skip to content

Commit

Permalink
linting, new black introduces new linting
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Papior <[email protected]>
  • Loading branch information
zerothi committed Feb 13, 2024
1 parent eafa456 commit ab45ef4
Show file tree
Hide file tree
Showing 29 changed files with 90 additions and 56 deletions.
2 changes: 2 additions & 0 deletions src/sisl/_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def __call__(cls, *args, **kwargs):
@set_module("sisl.category")
class Category(metaclass=CategoryMeta):
r"""A category"""

__slots__ = ("_name", "_wrapper")

def __init__(self, name=None):
Expand Down Expand Up @@ -297,6 +298,7 @@ def is_class(cls, name):
@set_module("sisl.category")
class NullCategory(GenericCategory):
r"""Special Null class which always represents a classification not being *anything*"""

__slots__ = tuple()

def __init__(self):
Expand Down
1 change: 1 addition & 0 deletions src/sisl/_dispatch_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class A(_Dispatchs,
A.new.register ..
A.hello.register ..
"""

import logging
from collections import namedtuple
from typing import Any, Optional, Sequence, Union
Expand Down
8 changes: 4 additions & 4 deletions src/sisl/geom/_composite.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
@dataclass
class CompositeGeometrySection:
@abstractmethod
def build_section(self, previous: Geometry) -> Geometry:
...
def build_section(self, previous: Geometry) -> Geometry: ...

@abstractmethod
def add_section(self, geometry: Geometry, geometry_addition: Geometry) -> Geometry:
...
def add_section(
self, geometry: Geometry, geometry_addition: Geometry
) -> Geometry: ...

def _junction_error(self, prev, msg, what):
"""Helper function to raise an error if the junction is not valid.
Expand Down
2 changes: 2 additions & 0 deletions src/sisl/geom/category/_coord.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class AtomFracSite(AtomCategory):
... else:
... assert c == B_site
"""

__slots__ = (
f"_{a}" for a in ("cell", "icell", "length", "atol", "offset", "foffset")
)
Expand Down Expand Up @@ -159,6 +160,7 @@ class AtomXYZ(AtomCategory):
AtomXYZ.fx < 3 == AtomXYZ.fx(None, 3) == AtomXYZ(f_x=(None, 3)) == AtomXYZ(f_x_lt=3)
"""

__slots__ = ("_coord_check",)

def __init__(self, *args, **kwargs):
Expand Down
5 changes: 5 additions & 0 deletions src/sisl/geom/category/_kind.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class AtomZ(AtomCategory):
Z : int or array_like
atomic number match for several values this is equivalent to AND
"""

__slots__ = ("_Z",)

def __init__(self, Z):
Expand Down Expand Up @@ -62,6 +63,7 @@ class AtomTag(AtomCategory):
tag : str
The tag you want atoms to match. It can be a regex expression.
"""

__slots__ = ("_compiled_re", "_re")

def __init__(self, tag):
Expand Down Expand Up @@ -113,6 +115,7 @@ class AtomIndex(AtomCategory):
>>> aidx = AtomIndex(mod=3) # [1, 2, 4, 5, ...]: range(na) - range(0, na, 3)
>>> geom.sub(aidx) == geom.sub(range(0, len(geom), 3))
"""

__slots__ = ("_op_val",)

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -272,6 +275,7 @@ def __eq__(self, other):

class AtomEven(AtomCategory):
r"""Classify atoms based on indices (even in this case)"""

__slots__ = []

def __init__(self):
Expand All @@ -291,6 +295,7 @@ def __eq__(self, other):
@set_module("sisl.geom")
class AtomOdd(AtomCategory):
r"""Classify atoms based on indices (odd in this case)"""

__slots__ = []

def __init__(self):
Expand Down
1 change: 1 addition & 0 deletions src/sisl/geom/category/_neighbours.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class AtomNeighbours(AtomCategory):
>>> AtomNeighbours(4, R=(1, 1.44)) # 4 neighbours within (1, Geometry.maxR())
>>> AtomNeighbours(4, R=lambda atom: (0.01, PeriodicTable().radius(atom.Z))) # 4 neighbours within (0.01, <>)
"""

__slots__ = ("_min", "_max", "_in", "_R")

def __init__(self, *args, **kwargs):
Expand Down
12 changes: 3 additions & 9 deletions src/sisl/io/siesta/binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -2561,9 +2561,7 @@ def _type(name, obj, dic=None):
)
add_sile(
"RHOINIT",
_type(
"rhoinitSileSiesta", _gridSileSiesta, {"grid_unit": 1.0 / _Bohr2Ang**3}
),
_type("rhoinitSileSiesta", _gridSileSiesta, {"grid_unit": 1.0 / _Bohr2Ang**3}),
)
add_sile(
"RHOXC",
Expand All @@ -2583,9 +2581,7 @@ def _type(name, obj, dic=None):
)
add_sile(
"TOCH",
_type(
"totalrhoSileSiesta", _gridSileSiesta, {"grid_unit": 1.0 / _Bohr2Ang**3}
),
_type("totalrhoSileSiesta", _gridSileSiesta, {"grid_unit": 1.0 / _Bohr2Ang**3}),
)
# The following two files *require* that
# STM.DensityUnits Ele/bohr**3
Expand All @@ -2597,9 +2593,7 @@ def _type(name, obj, dic=None):
)
add_sile(
"STM.LDOS",
_type(
"stmldosSileSiesta", _gridSileSiesta, {"grid_unit": 1.0 / _Bohr2Ang**3}
),
_type("stmldosSileSiesta", _gridSileSiesta, {"grid_unit": 1.0 / _Bohr2Ang**3}),
)
add_sile("VH", _type("hartreeSileSiesta", _gridSileSiesta, {"grid_unit": _Ry2eV}))
add_sile(
Expand Down
1 change: 1 addition & 0 deletions src/sisl/io/tbtrans/se.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class tbtsencSileTBtrans(_devncSileTBtrans):
>>> np.allclose(Hdev_pvt, Hdev[pvt_dev, pvt_dev.T])
True
"""

_trans_type = "TBT"
_E2eV = Ry2eV

Expand Down
1 change: 1 addition & 0 deletions src/sisl/io/tbtrans/tbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class tbtncSileTBtrans(_devncSileTBtrans):
The API for this class are largely equivalent to the arguments of the `sdata` command-line
tool, with the execption that the command-line tool uses Fortran indexing numbers (1-based).
"""

_trans_type = "TBT"
_E2eV = Ry2eV

Expand Down
3 changes: 3 additions & 0 deletions src/sisl/mixing/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
@set_module("sisl.mixing")
class BaseMixer:
r"""Base class mixer"""

__slots__ = ()

@abstractmethod
Expand Down Expand Up @@ -117,6 +118,7 @@ def __str__(self) -> str:
@set_module("sisl.mixing")
class BaseWeightMixer(BaseMixer):
r"""Base class mixer"""

__slots__ = ("_weight",)

def __init__(self, weight: TypeWeight = 0.2):
Expand All @@ -142,6 +144,7 @@ def set_weight(self, weight: TypeWeight):
@set_module("sisl.mixing")
class BaseHistoryWeightMixer(BaseWeightMixer):
r"""Base class mixer with history"""

__slots__ = ("_history",)

def __init__(self, weight: TypeWeight = 0.2, history: TypeArgHistory = 0):
Expand Down
2 changes: 2 additions & 0 deletions src/sisl/mixing/diis.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class DIISMixer(BaseHistoryWeightMixer):
metric : callable, optional
the metric used for the two values, defaults to ``lambda a, b: a.ravel().conj().dot(b.ravel).real``
"""

__slots__ = ("_metric",)

def __init__(
Expand Down Expand Up @@ -179,6 +180,7 @@ class AdaptiveDIISMixer(DIISMixer):
be relatively far from the true saddle point, and for small values we
will be close to the saddle point.
"""

__slots__ = ("_weight_min", "_weight_delta")

def __init__(
Expand Down
1 change: 1 addition & 0 deletions src/sisl/mixing/linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class LinearMixer(BaseHistoryWeightMixer):
weight : float, optional
mixing weight
"""

__slots__ = ()

def __call__(self, f: T, df: T, append: bool = True) -> T:
Expand Down
3 changes: 1 addition & 2 deletions src/sisl/nodes/syntax_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from .node import Node


class SyntaxNode(Node):
...
class SyntaxNode(Node): ...


class ListSyntaxNode(SyntaxNode):
Expand Down
3 changes: 1 addition & 2 deletions src/sisl/nodes/tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ def calc(val: int):
return val

@Node.from_func(context={"lazy": False, "lazy_init": lazy_init})
def alert_change(val: int):
...
def alert_change(val: int): ...

val = calc(1)

Expand Down
14 changes: 8 additions & 6 deletions src/sisl/nodes/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def _edge_props(node_out, node_in, key) -> dict:
if edge_labels:
props["label"] = key

props[
"title"
] = f"{node_out.__class__.__name__}() -> {node_in.__class__.__name__}.{key}"
props["title"] = (
f"{node_out.__class__.__name__}() -> {node_in.__class__.__name__}.{key}"
)
return props

# Get the workflow's nodes
Expand Down Expand Up @@ -942,9 +942,11 @@ def assign_workflow_var(value: Any, var_name: str):
inps = {
k: WorkflowInput(
input_key=k,
value=param.default
if param.default != inspect.Parameter.empty
else Node._blank,
value=(
param.default
if param.default != inspect.Parameter.empty
else Node._blank
),
)
for k, param in sig.parameters.items()
if param.kind
Expand Down
2 changes: 2 additions & 0 deletions src/sisl/orbital.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class Orbital:
The optimization problem depends heavily on the ``func`` since the tails are
important for real-space quantities.
"""

__slots__ = ("_R", "_tag", "_q0")

def __init__(self, R, q0=0.0, tag=""):
Expand Down Expand Up @@ -669,6 +670,7 @@ class SphericalOrbital(Orbital):
... fill_value=(0., 0.), kind="cubic", bounds_error=False)))
True
"""

# Additional slots (inherited classes retain the same slots)
__slots__ = ("_l", "_radial")

Expand Down
1 change: 1 addition & 0 deletions src/sisl/physics/brillouinzone.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class BrillouinZoneDispatcher(ClassDispatcher):
Please see :ref:`physics.brillouinzone` for further examples.
"""

pass


Expand Down
6 changes: 6 additions & 0 deletions src/sisl/physics/electron.py
Original file line number Diff line number Diff line change
Expand Up @@ -1622,18 +1622,21 @@ def wavefunction(self, grid, spinor=0, eta=None):
@set_module("sisl.physics.electron")
class CoefficientElectron(Coefficient):
r"""Coefficients describing some physical quantity related to electrons"""

__slots__ = []


@set_module("sisl.physics.electron")
class StateElectron(_electron_State, State):
r"""A state describing a physical quantity related to electrons"""

__slots__ = []


@set_module("sisl.physics.electron")
class StateCElectron(_electron_State, StateC):
r"""A state describing a physical quantity related to electrons, with associated coefficients of the state"""

__slots__ = []

def velocity(self, *args, **kwargs):
Expand Down Expand Up @@ -1724,6 +1727,7 @@ class EigenvalueElectron(CoefficientElectron):
This holds routines that enable the calculation of density of states.
"""

__slots__ = []

@property
Expand Down Expand Up @@ -1765,6 +1769,7 @@ class EigenvectorElectron(StateElectron):
This holds routines that enable the calculation of spin moments.
"""

__slots__ = []


Expand All @@ -1775,6 +1780,7 @@ class EigenstateElectron(StateCElectron):
This holds routines that enable the calculation of (projected) density of states,
spin moments (spin texture).
"""

__slots__ = []

@property
Expand Down
1 change: 1 addition & 0 deletions src/sisl/shape/_cylinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class EllipticalCylinder(PureShape):
>>> shape.within([1.4, 0, 1.1])
False
"""

__slots__ = ("_v", "_nh", "_iv", "_h")

def __init__(self, v, h: float, axes=(0, 1), center=None):
Expand Down
18 changes: 11 additions & 7 deletions src/sisl/viz/_plotables.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,11 @@ def register_data_source(
"data_args": data_args,
"replaced_data_args": replaced_data_args,
"data_var_kwarg": data_var_kwarg,
"plot_var_kwarg": new_parameters[-1].name
if new_parameters[-1].kind == inspect.Parameter.VAR_KEYWORD
else None,
"plot_var_kwarg": (
new_parameters[-1].name
if new_parameters[-1].kind == inspect.Parameter.VAR_KEYWORD
else None
),
}

def _plot(
Expand Down Expand Up @@ -393,10 +395,12 @@ def register_sile_method(
"data_args": data_args,
"replaced_data_args": replaced_data_args,
"data_var_kwarg": data_var_kwarg,
"plot_var_kwarg": new_parameters[-1].name
if len(new_parameters) > 0
and new_parameters[-1].kind == inspect.Parameter.VAR_KEYWORD
else None,
"plot_var_kwarg": (
new_parameters[-1].name
if len(new_parameters) > 0
and new_parameters[-1].kind == inspect.Parameter.VAR_KEYWORD
else None
),
}

signature = signature.replace(parameters=new_parameters)
Expand Down
22 changes: 12 additions & 10 deletions src/sisl/viz/_splot.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,17 @@ def splot():
# Extra configuration that the user requested for the display
config = {
"editable": args.editable,
"modeBarButtonsToAdd": [
"drawline",
"drawopenpath",
"drawclosedpath",
"drawcircle",
"drawrect",
"eraseshape",
]
if args.drawable
else [],
"modeBarButtonsToAdd": (
[
"drawline",
"drawopenpath",
"drawclosedpath",
"drawcircle",
"drawrect",
"eraseshape",
]
if args.drawable
else []
),
}
plot.show(config=config)
Loading

0 comments on commit ab45ef4

Please sign in to comment.