|
| 1 | +"""Vdict key tuple wrapper class |
| 2 | +""" |
| 3 | +from typing import Tuple, Union |
| 4 | + |
| 5 | +class Vkey: |
| 6 | + |
| 7 | + def __init__(self, subkeys, origin: str, method: str): |
| 8 | + """ |
| 9 | + Parameters |
| 10 | + ---------- |
| 11 | + subkeys: tuple |
| 12 | + tuple of subkeys to associate with this Vkey |
| 13 | + origin: str |
| 14 | + string attribute that identifies the Vset that created this Vkey |
| 15 | + method: str |
| 16 | + String attribute that identifies the Vset method that was called to create |
| 17 | + this Vkey |
| 18 | + """ |
| 19 | + self._subkeys = subkeys |
| 20 | + self.origin = origin |
| 21 | + self.method = method |
| 22 | + |
| 23 | + def subkeys(self): |
| 24 | + """Return a tuple of the Subkeys in this Vkey. |
| 25 | + """ |
| 26 | + return self._subkeys |
| 27 | + |
| 28 | + def get_origins(self): |
| 29 | + """Return a tuple of strings with the origins of the Subkeys in this Vkey. |
| 30 | + """ |
| 31 | + return (sk.origin for sk in self.subkeys()) |
| 32 | + |
| 33 | + def get_values(self): |
| 34 | + """Return a tuple of strings with the values of the Subkeys in this Vkey. |
| 35 | + """ |
| 36 | + return (sk.value for sk in self.subkeys()) |
| 37 | + |
| 38 | + def __contains__(self, *subkeys: Union[str, Tuple[str, str]]): |
| 39 | + """Returns True if subkeys that are strings overlap with self.get_values() |
| 40 | + and if subkeys that are string tuples like (`origin`, `value`) have |
| 41 | + corresponding matches in both self.get_origins() and self.get_values(). |
| 42 | +
|
| 43 | + Examples: |
| 44 | + `preproc_0` in vkey => bool |
| 45 | + (`model`, `RF`) in vkey => bool |
| 46 | + """ |
| 47 | + pass |
| 48 | + |
| 49 | + def __add__(self, other: 'Vkey'): |
| 50 | + """Return a new Vkey by combining this Vkey with other, following Subkey |
| 51 | + matching rules. Returns an empty Vkey if there are any Subkey mismatches. |
| 52 | + """ |
| 53 | + pass |
| 54 | + |
| 55 | + def __copy__(self): |
| 56 | + """Return a copy of this Vkey (but not its Subkeys). |
| 57 | + """ |
| 58 | + pass |
| 59 | + |
| 60 | + def __deepcopy__(self): |
| 61 | + """Return a copy of this Vkey and its Subkeys. |
| 62 | + """ |
| 63 | + pass |
| 64 | + |
| 65 | + def __len__(self): |
| 66 | + """Return the number of Subkeys in this Vkey. |
| 67 | + """ |
| 68 | + return len(self.subkeys()) |
0 commit comments