map
map
#
Map — a key-scalar-keyed collection that broadcasts over its entries when loaded.
Map[Date, Entry] is storable: it knows its key scalar and element, so it
reads/writes entries under folder names from the key scalar's key_encode. A
loaded map is a Map — index it by a decoded key to select an entry
(Missing if absent), iterate or call values() for the entries as an
Array, and attribute access broadcasts over the entry values
(sessions.rating is every entry's rating). It is mutable: assign, delete, and
test membership by key, so a runtime keyed bag (an interceptor's persistence
dict) is also a Map.
The key is a keyable scalar (Time/Date, String, UserID,
Bool) — a real CGType, so .keys() has an element type.
Map
#
Bases: CGType
A keyed collection.
Map[K, V] is storable when V is (so a keyed fan-out
Map[K, Path[V]] is non-storable); a bare Map is a schemaless keyed
view. The key is always a keyable — hence storable — scalar. The type
parameters type the entry surface (keys()/values(), values by
key); broadcasts carry object elements, narrowed by the caller. Key
parameters accept object: a schema map's runtime keys are the
decoded values (datetime for a Date key), not the scalar class
the subscription names.
Source code in capturegraph-lib/capturegraph/types/containers/map.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
__bool__()
#
__class_getitem__(params)
#
Build Map[key, element], a storable subclass keyed by key.
Source code in capturegraph-lib/capturegraph/types/containers/map.py
__contains__(key)
#
__delitem__(key)
#
__dir__()
#
Standard members plus the broadcastable entry-value field names.
Surfaces sessions.rating in REPL/notebook autocomplete; the
broadcast itself stays dynamically typed.
Source code in capturegraph-lib/capturegraph/types/containers/map.py
__eq__(other)
#
Equal to another Map or a plain dict with the same entries.
Source code in capturegraph-lib/capturegraph/types/containers/map.py
__getattr__(name)
#
Broadcast attribute access over the entry values.
A name no value has raises (a typo), a name some lack chains as
Missing.
Source code in capturegraph-lib/capturegraph/types/containers/map.py
__getitem__(key)
#
The value at key; an absent key chains as a reasoned Missing.
__init__(entries=())
#
Wrap entries (any (key, value) iterable) as a Map.
__iter__()
#
__len__()
#
__repr__()
#
__setitem__(key, value)
#
get_or_insert(key, value)
#
The value at key, inserting value first if it is absent.
Source code in capturegraph-lib/capturegraph/types/containers/map.py
items()
#
keys()
#
load(base)
classmethod
#
Read the key-encoded entries under base as this map type.
Typed by the annotation naming this class — Map[Date, Session]
loads as itself. The schema supplies the runtime _key/_element;
the cast below is the one boundary where the type-erased registry meets
the static entry types the schema declares.
Source code in capturegraph-lib/capturegraph/types/containers/map.py
map(function)
#
Apply function to each value, keeping keys; failures become Missing.
Raises if the call fails on every entry for a non-data reason (a broken
lambda fails loudly); a sparse data-absence failure chains as Missing.
Source code in capturegraph-lib/capturegraph/types/containers/map.py
schema()
classmethod
#
This map's wire form: its key and element schemas, tagged "map".
Source code in capturegraph-lib/capturegraph/types/containers/map.py
store(base, value)
classmethod
#
Write value (a dict) under base as key-encoded entries.