File tree Expand file tree Collapse file tree 3 files changed +16
-16
lines changed
Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Original file line number Diff line number Diff line change 1+ Fixed AtomCategory usage when sisl.geom hasn't been imported
Original file line number Diff line number Diff line change 9090
9191from ._core import *
9292
93+
9394# Import warning classes
9495# We currently do not import warn and info
9596# as they are too generic names in case one does from sisl import *
133134 SileBin ,
134135)
135136
137+ # We need to pre-import geom, because
138+ # The categories are necessary to be exposed (for sub-class handling).
139+ # Therefore lazy-loading of this module is not possible.
140+ from . import geom
141+
136142# Allow geometry to register siles
137143# Ensure BaseSile works as a str
138144# We have to do it after loading BaseSile and Geometry
167173def __getattr__ (attr ):
168174 """Enables simpler access of sub-modules, without having to import them"""
169175
170- # One can test that this is only ever called once
171- # per sub-module.
172- # Insert a print statement, and you'll see that:
173- # import sisl
174- # sisl.geom
175- # sisl.geom
176- # will only print *once*.
177-
178- if attr == "geom" :
179- import sisl .geom as geom
180-
181- return geom
182176 if attr == "io" :
183177 import sisl .io as io
184178
@@ -211,10 +205,7 @@ def __getattr__(attr):
211205 import sisl .unit as unit
212206
213207 return unit
214- if attr == "C" :
215- import sisl .constant as C
216208
217- return constant
218209 if attr == "constant" :
219210 import sisl .constant as constant
220211
Original file line number Diff line number Diff line change @@ -222,6 +222,14 @@ def func(a, b):
222222 spec , sdir = key .split ("_" )
223223 else :
224224 sdir , op = key .split ("_" )
225+ if not hasattr (operator , op ):
226+ raise ValueError (
227+ f"{ self .__class__ .__name__ } could not determine the "
228+ f"operations for { key } . "
229+ "A single value for this without an operator is ill-defined. "
230+ "Please define an operator."
231+ )
232+
225233 elif value .size == 2 :
226234 sdir = key
227235 else :
@@ -346,7 +354,7 @@ def _apply_key(k, v):
346354 return AtomXYZ (** {key : interval }, ** new_kwargs )
347355 elif len (interval ) != 0 :
348356 raise ValueError (
349- f"{ cls .__name__ } non-keyword argumest must be 1 tuple, or 2 values"
357+ f"{ cls .__name__ } non-keyword argument must be 1 tuple, or 2 values"
350358 )
351359 return AtomXYZ (** new_kwargs )
352360
You can’t perform that action at this time.
0 commit comments