Skip to content

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

Open
SF-N wants to merge 1 commit into
juntyr:mainfrom
SF-N:constant-value
Open

SF-N wants to merge 1 commit into
juntyr:mainfrom
SF-N:constant-value

Conversation

@SF-N

@SF-N SF-N commented Sep 30, 2026

Copy link
Copy Markdown

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.

Parameters
----------
value : int | float, optional
The constant value that the data decodes to.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mention again that this is zero by default

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants