1515import numpy as np
1616from adios2 import FileReader
1717
18- # from xarray.core.dataset import Dataset
1918from xarray import Dataset , Variable
20- from xarray import coding , conventions
2119from xarray .backends .common import (
22- BACKEND_ENTRYPOINTS ,
23- AbstractWritableDataStore ,
2420 BackendArray ,
2521 BackendEntrypoint ,
26- _encode_variable_name ,
2722 _normalize_path ,
2823)
2924
30- # from xarray.backends.store import StoreBackendEntrypoint
3125from xarray .core import indexing
3226
33- # from xarray.core.indexing import LazilyIndexedArray
34-
35- # from xarray.core.parallelcompat import guess_chunkmanager
36- # from xarray.core.pycompat import integer_types
37- # from xarray.core.utils import (
38- # FrozenDict,
39- # HiddenKeyDict,
40- # close_on_error,
41- # )
42-
4327if TYPE_CHECKING :
4428 from io import BufferedIOBase
4529 from xarray .backends .common import AbstractDataStore
6953class BoutADIOSBackendArray (BackendArray ):
7054 """ADIOS2 backend for lazily indexed arrays"""
7155
72- def __init__ (self , shape : list , dtype : np .dtype , lock , adiosfile : FileReader , varname : str ):
56+ def __init__ (
57+ self , shape : list , dtype : np .dtype , lock , adiosfile : FileReader , varname : str
58+ ):
7359 self .shape = shape
7460 self .dtype = dtype
7561 self .lock = lock
@@ -94,7 +80,7 @@ def _raw_indexing_method(self, key: tuple) -> np.typing.ArrayLike:
9480 # f"key = {key} steps = {self.steps}")
9581 # print(f" data shape {data.shape}")
9682
97- # thread safe method that access to data on disk needed because
83+ # thread safe method that access to data on disk needed because
9884 # adios is not thread safe even for reading
9985 # with self.lock:
10086 start = []
@@ -103,17 +89,17 @@ def _raw_indexing_method(self, key: tuple) -> np.typing.ArrayLike:
10389 first_sl = True
10490 for sl in key :
10591 if isinstance (sl , slice ):
106- if sl .start == None :
92+ if sl .start is None :
10793 st = 0
10894 else :
10995 st = sl .start
11096
111- if sl .stop == None :
97+ if sl .stop is None :
11298 ct = self .shape [dimid ] - st
11399 else :
114100 ct = sl .stop - st
115101
116- if sl .step != 1 and sl .step != None :
102+ if sl .step != 1 and sl .step is not None :
117103 msg = (
118104 "The indexing operation with step != 1 you are attempting to perform "
119105 "is not valid on ADIOS2.Variable object. "
@@ -284,7 +270,9 @@ def open_dataset( # type: ignore[override] # allow LSP violation, not supporti
284270 avar .set_step_selection ([0 , avar .steps ()])
285271 data = self ._fh .read (avar )
286272 # print(f"\tCreate timed scalar variable {varname}")
287- xvar = Variable ("t" , data , attrs = xattrs , encoding = {"dtype" : data .dtype })
273+ xvar = Variable (
274+ "t" , data , attrs = xattrs , encoding = {"dtype" : data .dtype }
275+ )
288276 else :
289277 data = self ._fh .read (varname )
290278 if varinfo ["Type" ] == "string" :
0 commit comments