Skip to content

Commit

Permalink
nan min/max to handle possible nan ghosts (#923)
Browse files Browse the repository at this point in the history
* nan min/max to handle possible nan ghosts

* flatten
  • Loading branch information
nicolasaunai authored Nov 12, 2024
1 parent e61b34c commit c3f0fc3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pyphare/pyphare/pharesee/hierarchy/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,11 @@ def global_min(self, qty, **kwargs):
for patch in lvl.patches:
pd = patch.patch_datas[qty]
if first:
m = pd.dataset[:].min()
m = np.nanmin(pd.dataset[:])
first = False
else:
m = min(m, pd.dataset[:].min())
data_and_min = np.concatenate(([m], pd.dataset[:].flatten()))
m = np.nanmin(data_and_min)

return m

Expand All @@ -289,10 +290,11 @@ def global_max(self, qty, **kwargs):
for patch in lvl.patches:
pd = patch.patch_datas[qty]
if first:
m = pd.dataset[:].max()
m = np.nanmax(pd.dataset[:])
first = False
else:
m = max(m, pd.dataset[:].max())
data_and_max = np.concatenate(([m], pd.dataset[:].flatten()))
m = np.nanmax(data_and_max)

return m

Expand Down

0 comments on commit c3f0fc3

Please sign in to comment.