← Back to Pull requests

Add a value parameter so that the codec can decode to any constant #1

Open
SF-N opened this pull request with 64 lines diff across 3 files
View on GitHub
SF-N SF-N commented on Sep 30, 2026 22:00 UTC
Author

Summary

ZeroCodec gains a keyword value: int | float = 0 and decodes to np.full(shape, value, dtype). The default behaviour (all zeros) and the stream format are unchanged; get_config and __repr__ are added so that the value round-trips through the configuration.

  • tests for float, integer and NaN values, and for the default configuration
  • Motivation

    Some safety requirements in the compression recommendations are so loose that a constant reconstruction (e.g. the field's median) satisfies them; combined with MaskMetaCodec for missing values this gives the smallest possible representation without a dedicated "constant" codec.

    Diff: 64 lines (+54 / -10) across 3 files Reviewer: juntyr Review duration: 17832m
    All Vouch review confidence checks passed
    Residual risk 0.03 = Change Risk (0.31) × (1 − Review Confidence (0.89)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.31 · 64 lines diff across 3 files
    0.31
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.89 · 1 substantive comment(s)
    0.89
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    89%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Diff Size diff_size
    0.250
    Real PR Conversation Timeline
    2 items
    juntyr juntyr commented on code on Oct 05, 2026 18:19 UTC
    Code Review
    src/numcodecs_zero/__init__.py:1
    @@ -16,17 +16,26 @@
     
     class ZeroCodec(Codec):
         """
    -    Codec that decodes to an all-zero array of the same data type and shape as
    -    the original data.
    +    Codec that decodes to an array filled with a constant `value` (zero by
    +    default) of the same data type and shape as the original data.
     
         Encoding produces a bytestring containing information on the data type and
    -    shape.
    +    shape; the `value` is part of the codec configuration.
    +
    +    Parameters
    +    ----------
    +    value : int | float, optional
    +        The constant value that the data decodes to.

    Mention again that this is zero by default

    Reviewers
    Assignees
    SF-N SF-N
    Labels
    risk: low confidence: 89.1% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 30.9% (LOW) · Higher = larger blast radius
    30.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 89.1% · Lower = rushed or shallow review
    89.1%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 3.4% · Safe to merge
    3.4%