Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/iris/fileformats/_nc_load_rules/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

3) Iris-specific info is (still) stored in additional properties created on
the engine object :
engine.cf_var, .cube, .cube_parts, .requires, .rule_triggered, .filename
engine.cf_var, .cube, .cube_parts, .requires, .rules_triggered, .filename

Our "rules" are just action routines.
The top-level 'run_actions' routine decides which actions to call, based on the
Expand Down Expand Up @@ -78,7 +78,7 @@ def inner(engine, *args, **kwargs):
# but also may vary depending on whether it successfully
# triggered, and if so what it matched.
rule_name = _default_rulenamesfunc(func.__name__)
engine.rule_triggered.add(rule_name)
engine.rules_triggered.add(rule_name)

func._rulenames_func = _default_rulenamesfunc
return inner
Expand Down
26 changes: 17 additions & 9 deletions lib/iris/fileformats/netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def _actions_activation_stats(engine, cf_name):

print("Rules Triggered:")

for rule in sorted(list(engine.rule_triggered)):
for rule in sorted(list(engine.rules_triggered)):
print("\t%s" % rule)

print("Case Specific Facts:")
Expand Down Expand Up @@ -570,13 +570,21 @@ def _get_cf_var_data(cf_var, filename):
return as_lazy_data(proxy, chunks=chunks)


class OrderedAddableList(list):
# Used purely in actions debugging, to accumulate a record of which actions
# were activated.
# It replaces a set, so as to record the ordering of operations, with
# possible repeats, and it also numbers the entries.
# Actions routines invoke the 'add' method, which thus effectively converts
# a set.add into a list.append.
class _OrderedAddableList(list):
"""
A custom container object for actions recording.

Used purely in actions debugging, to accumulate a record of which actions
were activated.

It replaces a set, so as to preserve the ordering of operations, with
possible repeats, and it also numbers the entries.

The actions routines invoke an 'add' method, so this effectively replaces
a set.add with a list.append.

"""

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._n_add = 0
Expand All @@ -602,7 +610,7 @@ def _load_cube(engine, cf, cf_var, filename):
engine.cube = cube
engine.cube_parts = {}
engine.requires = {}
engine.rule_triggered = OrderedAddableList()
engine.rules_triggered = _OrderedAddableList()
engine.filename = filename

# Assert all the case-specific facts.
Expand Down