array
array
#
Array — a homogeneous sequence that broadcasts natively when loaded.
Array[Image] is a storable type: it knows its element, so it serializes and
reads/writes zero-padded index entries. A loaded array is an Array — it
broadcasts attribute access to its elements (photos.location is the location
of each), projects with string/tuple indexing, maps with per-element isolation,
chains through Missing instead of raising, and converts to NumPy arrays and
column-oriented dicts for analysis. A projection has no schema, so it lands in
a bare Array (broadcast-only, not storable). There is no separate "List":
the array is the sequence.
Array
#
Bases: CGType
A homogeneous sequence.
Array[T] is storable when T is (so Array[Path[V]] is a
non-storable view); a bare Array is the schemaless broadcast view a
projection lands in. The type parameter types the element surface
(indexing, iteration, append); derived views — broadcasts,
projections, map — carry object elements, narrowed by the caller.
Source code in capturegraph-lib/capturegraph/types/containers/array.py
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 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |
dkeys
property
#
The union of field/key names across all present leaves.
dtype
property
#
The type of the first present leaf (descends nested arrays), or None.
__add__(other)
#
__array__(dtype=None, copy=True)
#
NumPy's array-conversion protocol hook — see to_numpy.
Source code in capturegraph-lib/capturegraph/types/containers/array.py
__bool__()
#
__call__(*args, **kwargs)
#
Call each element with the same arguments (the elements are callables).
Raises if the call fails on every element for a non-data reason (every
element non-callable is a typo); a sparse failure chains as Missing.
Source code in capturegraph-lib/capturegraph/types/containers/array.py
__class_getitem__(element)
#
Build Array[element] — a storable subclass, or a typing-only alias.
A CGType element makes Array[T] whose storability follows the
element: Array[Image] is storable, while Array[Path[V]] is a
non-storable fan-out collection (an array of positions, never written to
disk). A non-CGType element is a typing-only alias, so loaded values can
be annotated without a schema.
Source code in capturegraph-lib/capturegraph/types/containers/array.py
__dir__()
#
Standard members plus the broadcastable element field names.
Surfaces photos.location in REPL/notebook autocomplete; the
broadcast itself stays dynamically typed.
Source code in capturegraph-lib/capturegraph/types/containers/array.py
__eq__(other)
#
Equal to another Array or a plain list with the same elements.
Source code in capturegraph-lib/capturegraph/types/containers/array.py
__getattr__(name)
#
Broadcast attribute access over the elements.
A name no element has raises (a typo), a name some lack chains as
Missing. Underscore names use normal lookup.
Source code in capturegraph-lib/capturegraph/types/containers/array.py
__getitem__(key)
#
Index by position (int/slice) or project by str/tuple.
numbers.Integral is accepted alongside plain int so a NumPy
index (np.argmax etc.) works like one — this Array converts to and
from NumPy for analysis. An out-of-range index chains as Missing
(typed as the element).
Source code in capturegraph-lib/capturegraph/types/containers/array.py
__init__(items=())
#
Wrap items (any iterable, copied into a plain list) as an Array.
__iter__()
#
__len__()
#
__or__(default)
#
Fill Missing/None leaves with default.
A parallel sequence fills element-wise; this recurses into nested Arrays.
Source code in capturegraph-lib/capturegraph/types/containers/array.py
__radd__(other)
#
__repr__()
#
__setattr__(name, value)
#
Broadcast attribute assignment over the elements.
An empty array adopts the length of value, creating a plain dict
per entry; a non-empty array assigns element-wise (a same-length
sequence), broadcasts a single-element sequence or a scalar, and skips
Missing elements. Each element is written by attribute when it
supports one, else by key (a dict row).
Source code in capturegraph-lib/capturegraph/types/containers/array.py
append(item)
#
load(base)
classmethod
#
Read the zero-padded index entries under base as this array type.
Typed by the annotation naming this class — Array[Image].load(...)
is an Array[Image]. The schema supplies the runtime _element;
the cast below is the one boundary where the type-erased registry meets
the static element type the schema declares.
Source code in capturegraph-lib/capturegraph/types/containers/array.py
map(function)
#
Apply function to each element, collecting failures as Missing.
Raises if the call fails on every element 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/array.py
map_leaves(function)
#
Apply function to every leaf, descending into nested Arrays.
Raises if the call fails on every leaf 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/array.py
pmap(function, workers=None)
#
Like map, but applies function across a thread pool (I/O-bound).
Source code in capturegraph-lib/capturegraph/types/containers/array.py
schema()
classmethod
#
This array's wire form: its element's schema, tagged "array".
Source code in capturegraph-lib/capturegraph/types/containers/array.py
store(base, value)
classmethod
#
Write value (an iterable) under base as zero-padded index entries.
Source code in capturegraph-lib/capturegraph/types/containers/array.py
to_dict(keys=None)
#
Column-orient as {name: [values]} for a DataFrame.
With no keys, the union of leaf field names is used; Missing is
written as None.
Source code in capturegraph-lib/capturegraph/types/containers/array.py
to_numpy()
#
Convert to a NumPy array, mapping Missing/None to nan.
index_name(index)
#
The on-disk folder name for the array element at index.
Zero-padded to a fixed width so the ascending-lexicographic entry_stems
order (the cross-platform enumeration contract) matches numeric order.
Source code in capturegraph-lib/capturegraph/types/containers/array.py
parse_index_name(name)
#
The array index a folder name encodes, or raise if it is not one.
Canonical means exactly index_name(i): ASCII digits, zero-padded to the
fixed width (wider only for a huge index), no sign and no alias padding — so a
hostile path component cannot masquerade as an index it does not equal.