Skip to content

Commit 60a2ceb

Browse files
committed
Provided error message for malformed cell_method attribute
1 parent 83905e9 commit 60a2ceb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/iris/fileformats/_nc_load_rules/helpers.py

+6
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,12 @@ def _split_cell_methods(nc_cell_methods: str) -> List[re.Match]:
296296
for m in _CM_PARSE_NAME.finditer(nc_cell_methods):
297297
name_start_inds.append(m.start())
298298

299+
# No matches? Must be malformed cell_method string; warn and return
300+
if not name_start_inds:
301+
msg = f"Failed to parse cell method string: {nc_cell_methods}"
302+
warnings.warn(msg, category=iris.warnings.IrisCfLoadWarning, stacklevel=2)
303+
return []
304+
299305
# Remove those that fall inside brackets
300306
bracket_depth = 0
301307
for ind, cha in enumerate(nc_cell_methods):

0 commit comments

Comments
 (0)