Skip to content

Commit 43afb02

Browse files
committed
fixed 3.8 support
1 parent 9035988 commit 43afb02

File tree

1 file changed

+42
-41
lines changed

1 file changed

+42
-41
lines changed

nt2/containers/utils.py

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from typing import List, Union, Tuple, Dict
12
import h5py
23
import numpy as np
34
import xarray as xr
@@ -23,7 +24,7 @@ def _dataIs2DPolar(ds):
2324

2425

2526
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]]
2728
):
2829
outsteps = []
2930
steps = []
@@ -62,7 +63,7 @@ def _read_category_metadata(
6263

6364

6465
# fields
65-
def _read_coordinates(coords: list[str], file: h5py.File):
66+
def _read_coordinates(coords: List[str], file: h5py.File):
6667
for st in file:
6768
group = file[st]
6869
if isinstance(group, h5py.Group):
@@ -108,12 +109,12 @@ def _read_coordinates(coords: list[str], file: h5py.File):
108109
def _preload_dask_arrays(
109110
single_file: bool,
110111
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]],
114115
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]]:
117118
dask_arrays = []
118119
if single_file:
119120
for s in outsteps:
@@ -149,11 +150,11 @@ def _preload_dask_arrays(
149150
def _preload_domain_shapes(
150151
single_file: bool,
151152
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]:
157158
dask_corners = []
158159
dask_sizes = []
159160
ndomains = None
@@ -203,15 +204,15 @@ def _preload_domain_shapes(
203204
def _preload_field_with_ghosts(
204205
single_file: bool,
205206
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]],
212213
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]:
215216
k_, dask_arrays = _preload_dask_arrays(
216217
single_file=single_file,
217218
k=k,
@@ -255,18 +256,18 @@ def _preload_field_with_ghosts(
255256
def _preload_field(
256257
single_file: bool,
257258
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]],
267268
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]:
270271
k_, dask_arrays = _preload_dask_arrays(
271272
single_file=single_file,
272273
k=k,
@@ -313,13 +314,13 @@ def _read_particle_species(first_step: str, file: h5py.File):
313314
def _preload_particle_species(
314315
single_file: bool,
315316
s: int,
316-
quantities: list[str],
317+
quantities: List[str],
317318
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]],
323324
):
324325
prtl_data = {}
325326
for q in [
@@ -415,10 +416,10 @@ def _preload_spectra(
415416
single_file: bool,
416417
sp: int,
417418
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]],
422423
):
423424
dask_arrays = []
424425
if single_file:

0 commit comments

Comments
 (0)