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(+)
| 245 | boolean) dtype cannot leak downstream and break a mixed-vintage | 245 | boolean) dtype cannot leak downstream and break a mixed-vintage |
| 246 | concatenation. The returned mapping always holds every key in | 246 | 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. |
| 248 | 248 | ||
| 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, or | 254 | ValueError: A required key is missing, an array has the wrong shape, or |
| 251 | a member with a declared storage dtype is stored with a | 255 | 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. |
| 291 | raises instead of zero-filling. Members whose spec declares a storage dtype | 295 | 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 rest | 296 | (``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. |
| 294 | 298 | ||
| 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 member | 304 | 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 | """ |
| 323 | *mask* along axis 0, so ``points`` keeps its ``(n, 3)`` rows while the | 331 | *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 change | 332 | ancillary members stay 1-D. Adding a field to the contract needs no change |
| 325 | here. | 333 | here. |
| 326 | 334 | ||
| 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; any | 341 | mask: Boolean mask of shape ``(N,)`` or an integer index array; any |
| 330 | NumPy row indexer works. | 342 | NumPy row indexer works. |
| 362 | Schema-agnostic: every key of the first record is concatenated across all | 374 | 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. |
| 365 | 377 | ||
| 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 the | 383 | records: Records to join, in the intended order. All must carry the |
| 368 | same key set. | 384 | same key set. |
| 369 | 385 |