1
+ from typing import List , Union , Tuple , Dict
1
2
import h5py
2
3
import numpy as np
3
4
import xarray as xr
@@ -23,7 +24,7 @@ def _dataIs2DPolar(ds):
23
24
24
25
25
26
def _read_category_metadata (
26
- single_file : bool , prefix : str , file : h5py .File | list [h5py .File ]
27
+ single_file : bool , prefix : str , file : Union [ h5py .File , List [h5py .File ] ]
27
28
):
28
29
outsteps = []
29
30
steps = []
@@ -62,7 +63,7 @@ def _read_category_metadata(
62
63
63
64
64
65
# fields
65
- def _read_coordinates (coords : list [str ], file : h5py .File ):
66
+ def _read_coordinates (coords : List [str ], file : h5py .File ):
66
67
for st in file :
67
68
group = file [st ]
68
69
if isinstance (group , h5py .Group ):
@@ -108,12 +109,12 @@ def _read_coordinates(coords: list[str], file: h5py.File):
108
109
def _preload_dask_arrays (
109
110
single_file : bool ,
110
111
k : str ,
111
- outsteps : list [int ],
112
- coord_replacements : list [ tuple [str , str ]],
113
- field_replacements : list [ tuple [str , str ]],
112
+ outsteps : List [int ],
113
+ coord_replacements : List [ Tuple [str , str ]],
114
+ field_replacements : List [ Tuple [str , str ]],
114
115
layout : str ,
115
- file : h5py .File | list [h5py .File ],
116
- ) -> tuple [str , list [dArray ]]:
116
+ file : Union [ h5py .File , List [h5py .File ] ],
117
+ ) -> Tuple [str , List [dArray ]]:
117
118
dask_arrays = []
118
119
if single_file :
119
120
for s in outsteps :
@@ -149,11 +150,11 @@ def _preload_dask_arrays(
149
150
def _preload_domain_shapes (
150
151
single_file : bool ,
151
152
k : str ,
152
- outsteps : list [int ],
153
- times : list [float ],
154
- steps : list [int ],
155
- file : h5py .File | list [h5py .File ],
156
- ) -> tuple [xr .DataArray , xr .DataArray ]:
153
+ outsteps : List [int ],
154
+ times : List [float ],
155
+ steps : List [int ],
156
+ file : Union [ h5py .File , List [h5py .File ] ],
157
+ ) -> Tuple [xr .DataArray , xr .DataArray ]:
157
158
dask_corners = []
158
159
dask_sizes = []
159
160
ndomains = None
@@ -203,15 +204,15 @@ def _preload_domain_shapes(
203
204
def _preload_field_with_ghosts (
204
205
single_file : bool ,
205
206
k : str ,
206
- outsteps : list [int ],
207
- times : list [float ],
208
- steps : list [int ],
209
- coords : list [str ],
210
- coord_replacements : list [ tuple [str , str ]],
211
- field_replacements : list [ tuple [str , str ]],
207
+ outsteps : List [int ],
208
+ times : List [float ],
209
+ steps : List [int ],
210
+ coords : List [str ],
211
+ coord_replacements : List [ Tuple [str , str ]],
212
+ field_replacements : List [ Tuple [str , str ]],
212
213
layout : str ,
213
- file : h5py .File | list [h5py .File ],
214
- ) -> tuple [str , xr .DataArray , dict , dict , dict ]:
214
+ file : Union [ h5py .File , List [h5py .File ] ],
215
+ ) -> Tuple [str , xr .DataArray , Dict , Dict , Dict ]:
215
216
k_ , dask_arrays = _preload_dask_arrays (
216
217
single_file = single_file ,
217
218
k = k ,
@@ -255,18 +256,18 @@ def _preload_field_with_ghosts(
255
256
def _preload_field (
256
257
single_file : bool ,
257
258
k : str ,
258
- outsteps : list [int ],
259
- times : list [float ],
260
- steps : list [int ],
261
- coords : list [str ],
262
- xc_coords : dict [str , str ],
263
- xe_min_coords : dict [str , str ],
264
- xe_max_coords : dict [str , str ],
265
- coord_replacements : list [ tuple [str , str ]],
266
- field_replacements : list [ tuple [str , str ]],
259
+ outsteps : List [int ],
260
+ times : List [float ],
261
+ steps : List [int ],
262
+ coords : List [str ],
263
+ xc_coords : Dict [str , str ],
264
+ xe_min_coords : Dict [str , str ],
265
+ xe_max_coords : Dict [str , str ],
266
+ coord_replacements : List [ Tuple [str , str ]],
267
+ field_replacements : List [ Tuple [str , str ]],
267
268
layout : str ,
268
- file : h5py .File | list [h5py .File ],
269
- ) -> tuple [str , xr .DataArray ]:
269
+ file : Union [ h5py .File , List [h5py .File ] ],
270
+ ) -> Tuple [str , xr .DataArray ]:
270
271
k_ , dask_arrays = _preload_dask_arrays (
271
272
single_file = single_file ,
272
273
k = k ,
@@ -313,13 +314,13 @@ def _read_particle_species(first_step: str, file: h5py.File):
313
314
def _preload_particle_species (
314
315
single_file : bool ,
315
316
s : int ,
316
- quantities : list [str ],
317
+ quantities : List [str ],
317
318
coord_type : str ,
318
- outsteps : list [int ],
319
- times : list [float ],
320
- steps : list [int ],
321
- coord_replacements : dict [str , str ],
322
- file : h5py .File | list [h5py .File ],
319
+ outsteps : List [int ],
320
+ times : List [float ],
321
+ steps : List [int ],
322
+ coord_replacements : Dict [str , str ],
323
+ file : Union [ h5py .File , List [h5py .File ] ],
323
324
):
324
325
prtl_data = {}
325
326
for q in [
@@ -415,10 +416,10 @@ def _preload_spectra(
415
416
single_file : bool ,
416
417
sp : int ,
417
418
e_bins : np .ndarray ,
418
- outsteps : list [int ],
419
- times : list [float ],
420
- steps : list [int ],
421
- file : h5py .File | list [h5py .File ],
419
+ outsteps : List [int ],
420
+ times : List [float ],
421
+ steps : List [int ],
422
+ file : Union [ h5py .File , List [h5py .File ] ],
422
423
):
423
424
dask_arrays = []
424
425
if single_file :
0 commit comments