Skip to content
Snippets Groups Projects
Commit 0c9e4a9b authored by Sebastian Müller's avatar Sebastian Müller 🐈
Browse files

info: better fail info for mask missmatch

parent 928f1991
No related branches found
No related tags found
1 merge request!258Grid mask support
Pipeline #181255 failed with stages
in 2 minutes and 43 seconds
......@@ -24,8 +24,14 @@ def check_mask_equal(grid1, grid2):
if mask1 is None and mask2 is None:
return True
# only one None is not fine
if mask1 is None or mask2 is None:
return False
# if mask1 is None or mask2 is None:
# return False
# None mask and no masked values are equally fine
if mask1 is None:
return not np.any(mask2)
if mask2 is None:
return not np.any(mask1)
# compare
return np.all(grid1.to_canonical(mask1) == grid2.to_canonical(mask2))
......
......@@ -11,6 +11,7 @@ from ..errors import FinamDataError, FinamMetaDataError
# pylint: disable-next=unused-import
from . import cf_units, grid_spec
from .grid_base import Grid, GridBase
from .grid_tools import check_mask_equal
# set default format to cf-convention for pint.dequantify
# some problems with degree_Celsius and similar here
......@@ -657,6 +658,19 @@ class Info:
if self.grid is not None and not self.grid.compatible_with(incoming.grid):
if not (ignore_none and incoming.grid is None):
fail_info["grid"] = (incoming.grid, self.grid)
if not check_mask_equal(self.grid, incoming.grid):
in_mask = (
np.sum(incoming.grid.mask)
if incoming.grid.mask is not None
else 0
)
out_mask = (
np.sum(self.grid.mask) if self.grid.mask is not None else 0
)
fail_info["mask"] = (
f"{in_mask} point(s) masked",
f"{out_mask} point(s) masked",
)
success = False
for k, v in self.meta.items():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment