Files
NODEDC_MISSION_CORE/simulation/semantic-learning/label_extension.py
T
DCCONSTRUCTIONS 25dc0a1b44 feat(semantics): add portable annotation, learning and review contracts
Add portable corpus, annotation provenance, admission, review and bounded agent-cycle contracts. Preserve dataset ownership and explicit research acceptance limits.
2026-10-29 09:10:00 +03:00

17 lines
809 B
Python

"""Extend reviewed labels without silently overriding known or locked unknown."""
import numpy as np
def extend_reviewed_target(base, proposal, protected):
if (not isinstance(base, np.ndarray) or base.ndim != 2 or base.dtype != np.uint8
or not isinstance(proposal, np.ndarray) or proposal.shape != base.shape
or proposal.dtype != np.uint8 or not isinstance(protected, np.ndarray)
or protected.shape != base.shape or protected.dtype != np.bool_
or not np.isin(base, [0, 1, 255]).all()
or not np.isin(proposal, [0, 1, 255]).all()):
raise ValueError("Aligned uint8 labels and explicit bool protection required")
preserve = protected | (base != 255)
result = proposal.copy()
result[preserve] = base[preserve]
return result