Skip to content

Commit c3f0fc3

Browse files
authored
nan min/max to handle possible nan ghosts (#923)
* nan min/max to handle possible nan ghosts * flatten
1 parent e61b34c commit c3f0fc3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pyphare/pyphare/pharesee/hierarchy/hierarchy.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,11 @@ def global_min(self, qty, **kwargs):
275275
for patch in lvl.patches:
276276
pd = patch.patch_datas[qty]
277277
if first:
278-
m = pd.dataset[:].min()
278+
m = np.nanmin(pd.dataset[:])
279279
first = False
280280
else:
281-
m = min(m, pd.dataset[:].min())
281+
data_and_min = np.concatenate(([m], pd.dataset[:].flatten()))
282+
m = np.nanmin(data_and_min)
282283

283284
return m
284285

@@ -289,10 +290,11 @@ def global_max(self, qty, **kwargs):
289290
for patch in lvl.patches:
290291
pd = patch.patch_datas[qty]
291292
if first:
292-
m = pd.dataset[:].max()
293+
m = np.nanmax(pd.dataset[:])
293294
first = False
294295
else:
295-
m = max(m, pd.dataset[:].max())
296+
data_and_max = np.concatenate(([m], pd.dataset[:].flatten()))
297+
m = np.nanmax(data_and_max)
296298

297299
return m
298300

0 commit comments

Comments
 (0)