Add a MaskAwareCodecMixin so that inner codecs can skip masked values #4
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.37) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 231 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.326
Real PR Conversation Timeline
1 comments
"Review active on #4"
general
weight: 0.35
juntyr
Summary
This PR adds a small protocol that lets the inner codec of a
MaskMetaCodecknow which values are masked, so that it can skip them instead of encoding a fill value for them.numcodecs_mask.abc.MaskAwareCodecMixinwith two abstract methods,encode_masked(buf, mask)anddecode_masked(buf, mask, out=None). The mask is a boolean array of the data's shape marking values that do not need to be preserved; the values at masked positions are unspecified on input and output.MaskMetaCodeccallsencode_masked/decode_maskedon inner codecs that implement the mixin (the bitmap is now decoded first, then the data), and falls back toencode/decodeotherwise. The stream format is unchanged and mask-unaware codecs behave exactly as before.MaskMetaCodecimplements the mixin itself, so nested mask meta-codecs forward the union of their masks to the innermost codec.Motivation
Entropy coders that condition on neighbouring values (e.g. the context-mixing coders in numcodecs-context-mixing) can avoid spending any bits on masked values and treat them as missing in their contexts. In the missing-values challenge of the compression lab (69 % NaN), coding a fill value for the masked positions costs 13 % of the compression ratio compared to skipping them; a mask-aware inner codec recovers this while keeping the masking modular.
Follow-ups (not in this PR)
CodecStack/FramedCodecStack(numcodecs-combinators) and throughpw_ratioto their inner codecs,numcodecs-eb-quantizeandnumcodecs-context-mixing.