Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cellmethod tolerance #5126

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Snapshot some additional existing behaviours.
  • Loading branch information
pp-mo committed Jan 4, 2023
commit 040dc91ccbffa235c383fe936e74f0eaf2bb3488
27 changes: 27 additions & 0 deletions lib/iris/tests/unit/fileformats/netcdf/test_parse_cell_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
Unit tests for :func:`iris.fileformats.netcdf.parse_cell_methods`.

"""
import warnings

import pytest

from iris.coords import CellMethod
Expand Down Expand Up @@ -241,3 +243,28 @@ def test_random_junk__warns(self):
with pytest.warns(UserWarning, match=msg):
result = parse_cell_methods(cm_str)
assert result == ()

def test_junk_after__silentlyignores(self):
cm_str = "time: mean -?-"
with warnings.catch_warnings():
warnings.simplefilter("error")
result = parse_cell_methods(cm_str)
expected = (CellMethod("mean", ("time",)),)
assert result == expected

def test_junk_before__silentlyignores(self):
cm_str = "-?- time: mean"
with warnings.catch_warnings():
warnings.simplefilter("error")
result = parse_cell_methods(cm_str)
expected = (CellMethod("mean", ("time",)),)
assert result == expected

def test_embeddedcolon__silentlyignores(self):
cm_str = "time:any: mean"
with warnings.catch_warnings():
warnings.simplefilter("error")
result = parse_cell_methods(cm_str)
# N.B. treats the initial "time:" as plain junk + discards it
expected = (CellMethod("mean", ("any",)),)
assert result == expected