map
map
#
Map — a collection keyed by a keyable scalar; attribute access broadcasts over entries.
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), and map/pmap carry the function's return type; a broadcast
names a field no type system can resolve, so it carries Any values.
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
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 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
__bool__()
#
__call__(*args, **kwargs)
#
Call each entry value with the same arguments, keys kept; a failure is Missing.
Source code in capturegraph-lib/capturegraph/types/containers/map.py
__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)
#
Each entry's name, keys kept; a name no value has raises, sparse is Missing.
This map's own machinery is not an entry field (broadcastable).
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.
Source code in capturegraph-lib/capturegraph/types/containers/map.py
__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()
#
key_of(component)
classmethod
#
The key the on-disk entry name component spells, decoded by the key type.
Raises:
| Type | Description |
|---|---|
SchemaPathError
|
If this map is schemaless, or |
Source code in capturegraph-lib/capturegraph/types/containers/map.py
keys()
#
load(base)
classmethod
#
The map stored at base, keys decoded from folder names; an unwritten tree is empty.
Raises:
| Type | Description |
|---|---|
TypeError
|
If this map is schemaless. |
Source code in capturegraph-lib/capturegraph/types/containers/map.py
map(function, label=None)
#
Apply function to each value, keeping keys; failures become Missing.
The walk is a progress step counting the entries, shown as label or
function's name. 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
pmap(function, label=None)
#
Like map, across the process's one thread pool, sized to the CPU count.
Keys are kept. Parallel only where function releases the GIL:
decoding an image, NumPy, a subprocess. cg.parallelism(workers) caps
how many elements are in flight at once. Each worker runs in a copy of
the caller's context, so the active scratch, workspace and progress
step carry over; a pmap inside a worker runs sequentially, the outer
pool being the parallelism.
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 under base, one key-encoded folder per entry.
Raises:
| Type | Description |
|---|---|
TypeError
|
If this map is schemaless, |
SchemaPathError
|
If a key encodes to something that cannot name a folder. |