Skip to content

Commit 6c3f313

Browse files
Removed unneccessary theoretical upperbound checks, removed early return of true, added more precise method of getting the upper bound, fixed lower and upper boundary checks.
1 parent 7ce4421 commit 6c3f313

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

src/emsarray/conventions/ugrid.py

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -748,30 +748,19 @@ def has_valid_face_edge_connectivity(self) -> bool:
748748
)
749749
return False
750750

751-
try:
751+
if '_FillValue' in data_array.encoding:
752752
fill_value = data_array.encoding['_FillValue']
753-
except KeyError:
754-
return True
755-
756-
lower_bound = _get_start_index(data_array)
757-
theoretical_upper_bound = self.face_count * self.max_node_count
758-
actual_upper_bound = numpy.nanmax(data_array)
759753

760-
if lower_bound < fill_value < actual_upper_bound:
761-
warnings.warn(
762-
f"Got a face_edge_connectivity variable {data_array.name!r} with "
763-
f"a _FillValue inside the actual index range",
764-
ConventionViolationWarning,
765-
)
766-
return False
754+
lower_bound = _get_start_index(data_array)
755+
upper_bound = self.edge_count + lower_bound
767756

768-
if lower_bound < fill_value < theoretical_upper_bound:
769-
warnings.warn(
770-
f"Got a face_edge_connectivity variable {data_array.name!r} with "
771-
f"a _FillValue inside the theoretical index range",
772-
ConventionViolationWarning,
773-
)
774-
return False
757+
if lower_bound <= fill_value <= upper_bound:
758+
warnings.warn(
759+
f"Got a face_edge_connectivity variable {data_array.name!r} with "
760+
f"a _FillValue inside the actual index range",
761+
ConventionViolationWarning,
762+
)
763+
return False
775764

776765
return True
777766

0 commit comments

Comments
 (0)