opendrift.models.openoil.adios.util.many_many
ManyMany
class for managing a many to many relationship in a pair of dicts
The two mappings are “left” and “right”
The left one is originally populated by the initializer.
After that they are equivalent – when you add something to one the other is updated.
Currently there is no way to remove anything
YOu can access copies of the mappings with:
ManyMany.left
and
ManyMany.right
They are copies, so that mutating them won’t break the internal data.
Module Contents
Classes
initialize a ManyMany structure |
- class opendrift.models.openoil.adios.util.many_many.ManyMany(initial_data=None)[source]
initialize a ManyMany structure
- Parameters:
initial_data –
initial data for the left dict. of the form: {key1: iterable_of_values,
key2: iterable_of_values, … }
all values must be hashable
- property left
A copy of the left dict
It’s a copy, so it won’t change the internal ones if mutated
- property right
A copy of the right dict
It’s a copy, so it won’t change the internal ones if mutated
- static _dict_hash(d)[source]
Provide a hash of a dict with a sequence of hashable items as the values
- This was to be used to know if an internal dict was changed,
but it turns out that’s not useful (at least not in a robust way)