Back to report index

iolabs-common (shared config layer) b9e3427: AI3D-382 Document the extra-key policy of the point-record helpers

Miroslav Simko <ms@iolabs.ch> 2026-09-01T23:39:27+02:00

Commit #90 ยท 4 snippets

 src/iolabs/common/segment_points_io.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
Importance #1: src/iolabs/common/segment_points_io.py @@ -245,8 +245,12 @@
245 boolean) dtype cannot leak downstream and break a mixed-vintage245 boolean) dtype cannot leak downstream and break a mixed-vintage
246 concatenation. The returned mapping always holds every key in246 concatenation. The returned mapping always holds every key in
247 :data:`POINT_RECORD_KEYS`, in registry order.247 :data:`POINT_RECORD_KEYS`, in registry order.
248248
249 Extra-key policy: NPZ members outside the schema are ignored, so the
250 returned record carries exactly :data:`POINT_RECORD_KEYS` and nothing a
251 hand-rolled producer may have added alongside them.
252
249 Raises:253 Raises:
250 ValueError: A required key is missing, an array has the wrong shape, or254 ValueError: A required key is missing, an array has the wrong shape, or
251 a member with a declared storage dtype is stored with a255 a member with a declared storage dtype is stored with a
252 non-integer/bool dtype or values outside that dtype's range.256 non-integer/bool dtype or values outside that dtype's range.
Importance #2: src/iolabs/common/segment_points_io.py @@ -291,8 +295,12 @@
291 raises instead of zero-filling. Members whose spec declares a storage dtype295 raises instead of zero-filling. Members whose spec declares a storage dtype
292 (``number_of_returns``: uint8) are coerced to it before the write; the rest296 (``number_of_returns``: uint8) are coerced to it before the write; the rest
293 are stored with the dtype the producer supplied.297 are stored with the dtype the producer supplied.
294298
299 Extra-key policy: only the schema keys are written, so any extra key the
300 record carries -- including one :func:`mask_record` or
301 :func:`concat_records` passed through -- is silently dropped by the write.
302
295 Raises:303 Raises:
296 ValueError: A key is missing, an array has the wrong shape, or a member304 ValueError: A key is missing, an array has the wrong shape, or a member
297 with a declared storage dtype cannot be cast to it losslessly.305 with a declared storage dtype cannot be cast to it losslessly.
298 """306 """
Importance #3: src/iolabs/common/segment_points_io.py @@ -323,8 +331,12 @@
323 *mask* along axis 0, so ``points`` keeps its ``(n, 3)`` rows while the331 *mask* along axis 0, so ``points`` keeps its ``(n, 3)`` rows while the
324 ancillary members stay 1-D. Adding a field to the contract needs no change332 ancillary members stay 1-D. Adding a field to the contract needs no change
325 here.333 here.
326334
335 Extra-key policy: keys outside the schema are masked and returned like any
336 other, but :func:`save_points_npz` writes only schema keys, so an extra key
337 survives in memory and is lost by a later save.
338
327 Args:339 Args:
328 record: Point record whose members all share a leading dimension.340 record: Point record whose members all share a leading dimension.
329 mask: Boolean mask of shape ``(N,)`` or an integer index array; any341 mask: Boolean mask of shape ``(N,)`` or an integer index array; any
330 NumPy row indexer works.342 NumPy row indexer works.
Importance #4: src/iolabs/common/segment_points_io.py @@ -362,8 +374,12 @@
362 Schema-agnostic: every key of the first record is concatenated across all374 Schema-agnostic: every key of the first record is concatenated across all
363 records, so ``points`` grows by rows and the ancillary members by elements.375 records, so ``points`` grows by rows and the ancillary members by elements.
364 Dtypes are not checked here -- :func:`concat_points_npz` owns that policy.376 Dtypes are not checked here -- :func:`concat_points_npz` owns that policy.
365377
378 Extra-key policy: keys outside the schema are concatenated and returned
379 like any other, but :func:`save_points_npz` writes only schema keys, so an
380 extra key survives in memory and is lost by a later save.
381
366 Args:382 Args:
367 records: Records to join, in the intended order. All must carry the383 records: Records to join, in the intended order. All must carry the
368 same key set.384 same key set.
369385