diff --git a/src/sisl/_category.py b/src/sisl/_category.py index 59c5fde79..ee6893e39 100644 --- a/src/sisl/_category.py +++ b/src/sisl/_category.py @@ -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): @@ -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): diff --git a/src/sisl/_dispatch_class.py b/src/sisl/_dispatch_class.py index 343ee682c..ec68b5cff 100644 --- a/src/sisl/_dispatch_class.py +++ b/src/sisl/_dispatch_class.py @@ -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 diff --git a/src/sisl/geom/_composite.py b/src/sisl/geom/_composite.py index 746d166b8..b830c7e06 100644 --- a/src/sisl/geom/_composite.py +++ b/src/sisl/geom/_composite.py @@ -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. diff --git a/src/sisl/geom/category/_coord.py b/src/sisl/geom/category/_coord.py index 2ee11dcc8..0b32e67f7 100644 --- a/src/sisl/geom/category/_coord.py +++ b/src/sisl/geom/category/_coord.py @@ -54,6 +54,7 @@ class AtomFracSite(AtomCategory): ... else: ... assert c == B_site """ + __slots__ = ( f"_{a}" for a in ("cell", "icell", "length", "atol", "offset", "foffset") ) @@ -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): diff --git a/src/sisl/geom/category/_kind.py b/src/sisl/geom/category/_kind.py index b04d198a2..b6f1f1054 100644 --- a/src/sisl/geom/category/_kind.py +++ b/src/sisl/geom/category/_kind.py @@ -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): @@ -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): @@ -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): @@ -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): @@ -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): diff --git a/src/sisl/geom/category/_neighbours.py b/src/sisl/geom/category/_neighbours.py index ea531b0af..7a801563b 100644 --- a/src/sisl/geom/category/_neighbours.py +++ b/src/sisl/geom/category/_neighbours.py @@ -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): diff --git a/src/sisl/io/siesta/binaries.py b/src/sisl/io/siesta/binaries.py index c60fb4808..98c7919f5 100644 --- a/src/sisl/io/siesta/binaries.py +++ b/src/sisl/io/siesta/binaries.py @@ -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", @@ -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 @@ -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( diff --git a/src/sisl/io/tbtrans/se.py b/src/sisl/io/tbtrans/se.py index 14eb63bf8..b9b5af939 100644 --- a/src/sisl/io/tbtrans/se.py +++ b/src/sisl/io/tbtrans/se.py @@ -62,6 +62,7 @@ class tbtsencSileTBtrans(_devncSileTBtrans): >>> np.allclose(Hdev_pvt, Hdev[pvt_dev, pvt_dev.T]) True """ + _trans_type = "TBT" _E2eV = Ry2eV diff --git a/src/sisl/io/tbtrans/tbt.py b/src/sisl/io/tbtrans/tbt.py index ba4336d19..910c85960 100644 --- a/src/sisl/io/tbtrans/tbt.py +++ b/src/sisl/io/tbtrans/tbt.py @@ -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 diff --git a/src/sisl/mixing/base.py b/src/sisl/mixing/base.py index 3630d2d03..d8287e34a 100644 --- a/src/sisl/mixing/base.py +++ b/src/sisl/mixing/base.py @@ -36,6 +36,7 @@ @set_module("sisl.mixing") class BaseMixer: r"""Base class mixer""" + __slots__ = () @abstractmethod @@ -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): @@ -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): diff --git a/src/sisl/mixing/diis.py b/src/sisl/mixing/diis.py index 7a4505e55..cd5f3811a 100644 --- a/src/sisl/mixing/diis.py +++ b/src/sisl/mixing/diis.py @@ -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__( @@ -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__( diff --git a/src/sisl/mixing/linear.py b/src/sisl/mixing/linear.py index d4b0be508..11a08a1db 100644 --- a/src/sisl/mixing/linear.py +++ b/src/sisl/mixing/linear.py @@ -29,6 +29,7 @@ class LinearMixer(BaseHistoryWeightMixer): weight : float, optional mixing weight """ + __slots__ = () def __call__(self, f: T, df: T, append: bool = True) -> T: diff --git a/src/sisl/nodes/syntax_nodes.py b/src/sisl/nodes/syntax_nodes.py index b94df1f25..7dc2e341a 100644 --- a/src/sisl/nodes/syntax_nodes.py +++ b/src/sisl/nodes/syntax_nodes.py @@ -4,8 +4,7 @@ from .node import Node -class SyntaxNode(Node): - ... +class SyntaxNode(Node): ... class ListSyntaxNode(SyntaxNode): diff --git a/src/sisl/nodes/tests/test_context.py b/src/sisl/nodes/tests/test_context.py index a9ee16f09..836fb6b6c 100644 --- a/src/sisl/nodes/tests/test_context.py +++ b/src/sisl/nodes/tests/test_context.py @@ -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) diff --git a/src/sisl/nodes/workflow.py b/src/sisl/nodes/workflow.py index 7fc3a763b..37dedc6d8 100644 --- a/src/sisl/nodes/workflow.py +++ b/src/sisl/nodes/workflow.py @@ -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 @@ -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 diff --git a/src/sisl/orbital.py b/src/sisl/orbital.py index bde0f604c..ec9b5a7e2 100644 --- a/src/sisl/orbital.py +++ b/src/sisl/orbital.py @@ -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=""): @@ -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") diff --git a/src/sisl/physics/brillouinzone.py b/src/sisl/physics/brillouinzone.py index 47f44de63..61b559bfe 100644 --- a/src/sisl/physics/brillouinzone.py +++ b/src/sisl/physics/brillouinzone.py @@ -187,6 +187,7 @@ class BrillouinZoneDispatcher(ClassDispatcher): Please see :ref:`physics.brillouinzone` for further examples. """ + pass diff --git a/src/sisl/physics/electron.py b/src/sisl/physics/electron.py index 34a11d079..01f492722 100644 --- a/src/sisl/physics/electron.py +++ b/src/sisl/physics/electron.py @@ -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): @@ -1724,6 +1727,7 @@ class EigenvalueElectron(CoefficientElectron): This holds routines that enable the calculation of density of states. """ + __slots__ = [] @property @@ -1765,6 +1769,7 @@ class EigenvectorElectron(StateElectron): This holds routines that enable the calculation of spin moments. """ + __slots__ = [] @@ -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 diff --git a/src/sisl/shape/_cylinder.py b/src/sisl/shape/_cylinder.py index eb749d587..82d71c91c 100644 --- a/src/sisl/shape/_cylinder.py +++ b/src/sisl/shape/_cylinder.py @@ -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): diff --git a/src/sisl/viz/_plotables.py b/src/sisl/viz/_plotables.py index 9c9913f13..193e7b657 100644 --- a/src/sisl/viz/_plotables.py +++ b/src/sisl/viz/_plotables.py @@ -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( @@ -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) diff --git a/src/sisl/viz/_splot.py b/src/sisl/viz/_splot.py index 6cf5f0485..4c9244714 100644 --- a/src/sisl/viz/_splot.py +++ b/src/sisl/viz/_splot.py @@ -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) diff --git a/src/sisl/viz/data/bands.py b/src/sisl/viz/data/bands.py index b7c9fdd04..db56a93b4 100644 --- a/src/sisl/viz/data/bands.py +++ b/src/sisl/viz/data/bands.py @@ -388,9 +388,11 @@ def from_hamiltonian( if isinstance(bz, sisl.BandStructure) and len(bz._jump_idx) > 0: old_coords = bands_data.coords coords = { - name: bz.insert_jump(old_coords[name]) - if name == "k" - else old_coords[name].values + name: ( + bz.insert_jump(old_coords[name]) + if name == "k" + else old_coords[name].values + ) for name in old_coords } diff --git a/src/sisl/viz/figure/figure.py b/src/sisl/viz/figure/figure.py index e1f183c7a..e5e7f2cc1 100644 --- a/src/sisl/viz/figure/figure.py +++ b/src/sisl/viz/figure/figure.py @@ -759,7 +759,9 @@ def draw_multisize_balls_3D( Usually supported by the normal draw_balls_3D """ - return self.draw_balls_3D(x, y, z, name=name, marker=marker, row=row, col=col, **kwargs) + return self.draw_balls_3D( + x, y, z, name=name, marker=marker, row=row, col=col, **kwargs + ) def draw_arrows_3D( self, diff --git a/src/sisl/viz/figure/plotly.py b/src/sisl/viz/figure/plotly.py index ce5589528..f0f293d45 100644 --- a/src/sisl/viz/figure/plotly.py +++ b/src/sisl/viz/figure/plotly.py @@ -59,7 +59,7 @@ ), ) }, - } + }, # "editrevision": True # "title": {"xref": "paper", "x": 0.5, "text": "Whhhhhhhat up", "pad": {"b": 0}} }, @@ -116,7 +116,7 @@ ), ) }, - } + }, # "editrevision": True # "title": {"xref": "paper", "x": 0.5, "text": "Whhhhhhhat up", "pad": {"b": 0}} }, diff --git a/src/sisl/viz/processors/bands.py b/src/sisl/viz/processors/bands.py index cf67bbc3d..a51be7f40 100644 --- a/src/sisl/viz/processors/bands.py +++ b/src/sisl/viz/processors/bands.py @@ -150,9 +150,11 @@ def calculate_gap(bands_data: xr.Dataset) -> dict: "gap": gap, "k": (VB["k"].values, CB["k"].values), "bands": (VB["band"].values, CB["band"].values), - "spin": (VB["spin"].values, CB["spin"].values) - if bands_data.attrs["spin"].is_polarized - else (0, 0), + "spin": ( + (VB["spin"].values, CB["spin"].values) + if bands_data.attrs["spin"].is_polarized + else (0, 0) + ), "Es": (float(VBtop), float(CBbot)), } diff --git a/src/sisl/viz/processors/grid.py b/src/sisl/viz/processors/grid.py index 11e46f0ae..f39770934 100644 --- a/src/sisl/viz/processors/grid.py +++ b/src/sisl/viz/processors/grid.py @@ -351,9 +351,9 @@ def sub_grid( lims = np.zeros((2, 3)) # If the cell was transformed, then we need to modify # the range to get what the user wants. - lims[ - :, ax - ] = ax_range # + self.offsets["cell_transform"][ax] - self.offsets["origin"][ax] + lims[:, ax] = ( + ax_range # + self.offsets["cell_transform"][ax] - self.offsets["origin"][ax] + ) origin[ax] += ax_range[0] diff --git a/src/sisl/viz/processors/wavefunction.py b/src/sisl/viz/processors/wavefunction.py index 18d073a92..f430320c4 100644 --- a/src/sisl/viz/processors/wavefunction.py +++ b/src/sisl/viz/processors/wavefunction.py @@ -54,8 +54,7 @@ def get_ith_eigenstate(eigenstate: EigenstateElectron, i: int): return eigenstate[wf_i] -class WavefunctionDataNode(GridDataNode): - ... +class WavefunctionDataNode(GridDataNode): ... @WavefunctionDataNode.register diff --git a/src/sisl/viz/types.py b/src/sisl/viz/types.py index 5484dc2e5..a73c37451 100644 --- a/src/sisl/viz/types.py +++ b/src/sisl/viz/types.py @@ -81,8 +81,7 @@ class OrbitalQuery(Query): @dataclass -class OrbitalStyleQuery(StyleSpec, OrbitalQuery): - ... +class OrbitalStyleQuery(StyleSpec, OrbitalQuery): ... OrbitalQueries = Sequence[OrbitalQuery] diff --git a/src/sisl_toolbox/models/_graphene/_hamiltonian.py b/src/sisl_toolbox/models/_graphene/_hamiltonian.py index 58f28de00..ad6313d75 100644 --- a/src/sisl_toolbox/models/_graphene/_hamiltonian.py +++ b/src/sisl_toolbox/models/_graphene/_hamiltonian.py @@ -99,6 +99,7 @@ class Ishii2010Dispatch(ReferenceDispatch): Instead of using the :math:`\lambda_0` as parameter name, we use ``t`` for the coupling strength. """ + doi = "10.1103/PhysRevLett.104.116801" def dispatch(self, t=-2.7, a=1.42, orthogonal=False):