Skip to content

Commit 88ab6e1

Browse files
authored
Merge pull request #398 from RemiLehe/fix_warning
Close #396 warning when reading particle data
2 parents 3b38a54 + 964bd16 commit 88ab6e1

File tree

1 file changed

+7
-2
lines changed
  • openpmd_viewer/openpmd_timeseries/data_reader/io_reader

1 file changed

+7
-2
lines changed

openpmd_viewer/openpmd_timeseries/data_reader/io_reader/utilities.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,16 @@ def get_data(series, record_component, i_slice=None, pos_slice=None,
5959
# ADIOS2: Actual chunks, all other: one chunk
6060
chunks = record_component.available_chunks()
6161

62+
# mask invalid regions with NaN: fill value
63+
# note: NaN is only defined for floating point types
64+
NaN_value = np.nan if np.issubdtype(record_component.dtype, np.floating) or np.issubdtype(record_component.dtype, np.complexfloating) else 0
65+
6266
# read whole data set
6367
if pos_slice is None:
6468
# mask invalid regions with NaN
6569
# note: full_like triggers a full read, thus we avoid it #340
66-
data = np.full(record_component.shape, np.nan, record_component.dtype)
70+
data = np.full(record_component.shape, NaN_value, record_component.dtype)
71+
6772
for chunk in chunks:
6873
chunk_slice = chunk_to_slice(chunk)
6974

@@ -90,7 +95,7 @@ def get_data(series, record_component, i_slice=None, pos_slice=None,
9095
del slice_shape[dir_index]
9196

9297
# mask invalid regions with NaN
93-
data = np.full(slice_shape, np.nan, dtype=record_component.dtype)
98+
data = np.full(slice_shape, NaN_value, dtype=record_component.dtype)
9499

95100
# build requested ND slice with respect to full data
96101
s = []

0 commit comments

Comments
 (0)