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

Fix DummyCube initialisation #122

Merged
merged 2 commits into from
Oct 3, 2024
Merged
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
14 changes: 9 additions & 5 deletions test/test_um2netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,25 @@ class DummyCube:

def __init__(self, item_code, var_name=None, attributes=None,
units=None, coords=None):
self.item_code = item_code
self.item_code = item_code # NB: um2nc adds this at runtime
self.var_name = var_name or "unknown_var"
self.attributes = attributes
self.units = units
self.standard_name = None
self.long_name = ""
self.long_name = None # cube names appear to default to None

self.attributes = attributes or {} # needs dict for update()
self.cell_methods = []
truth-quark marked this conversation as resolved.
Show resolved Hide resolved
self.units = units
self.data = None

# Mimic a coordinate dictionary with iris coordinate names as keys to
# ensure the coord() access key matches the coordinate's name
self._coordinates = {c.name(): c for c in coords} if coords else {}

# update() retains attributes set in __init__()
# NB: this is unlike cubes which convert section & item to the stash code
# these tests reverse this for expediency
section, item = um2nc.to_stash_code(item_code)
self.attributes = {um2nc.STASH: DummyStash(section, item)}
self.attributes.update({um2nc.STASH: DummyStash(section, item)})

def name(self):
return self.var_name
Expand Down
Loading