numcodecs_replace
numcodecs_replace
Value replacement codecs for the numcodecs buffer compression API.
Classes:
-
Replacement–Special replacement values that are derived from the original data.
-
ReplaceFilterCodec–Filter codec that replaces configured values during encoding and passes through the data during decoding.
Replacement
Bases: Enum
Special replacement values that are derived from the original data.
Methods:
-
compute–Compute the special replacement value for the array
x.
finite_min
class-attribute
instance-attribute
finite_min = auto()
The finite minimum of the data, or the largest-possible finite value if the data contains no finite values.
finite_mean
class-attribute
instance-attribute
finite_mean = auto()
The finite mean of the data, or NaN if the data contains no finite values.
finite_max
class-attribute
instance-attribute
finite_max = auto()
The finite maximum of the data, or the smallest-possible finite value if the data contains no finite values.
nan_min
class-attribute
instance-attribute
nan_min = auto()
The non-NaN minimum of the data, or the largest-possible value if the data contains no non-NaN values.
nan_mean
class-attribute
instance-attribute
nan_mean = auto()
The non-NaN mean of the data, or NaN if the data contains no non-NaN values.
nan_max
class-attribute
instance-attribute
nan_max = auto()
The non-NaN maximum of the data, or the smallest-possible value if the data contains no non-NaN values.
ReplaceFilterCodec
ReplaceFilterCodec(
*,
replacements: dict[
int | float,
int
| float
| Replacement
| Literal[
"finite_min",
"finite_mean",
"finite_max",
"nan_min",
"nan_mean",
"nan_max",
],
],
)
Bases: Codec
Filter codec that replaces configured values during encoding and passes through the data during decoding.
The replacements are processed in order.
The special Replacement values, e.g.
Replacement.nan_mean, are derived from the data
before any replacements are made.
Multiple ReplaceFilterCodecs can be stacked, e.g. using the
numcodecs-combinators
package, to apply some replacements before computing e.g. the finite mean.
When replacing NaN values, all values that are NaN are replaced, irrespective of their bitpatterns.
| Parameters: |
|---|
Methods:
-
encode–Encode the data in
buf. -
decode–Decode the data in
buf. -
get_config–Returns the configuration of this replacement filter codec.
encode
encode(buf: Buffer) -> Buffer
Encode the data in buf.
| Parameters: |
|
|---|
| Returns: |
|
|---|
decode
decode(buf: Buffer, out: None | Buffer = None) -> Buffer
Decode the data in buf.
| Parameters: |
|
|---|
| Returns: |
|
|---|
get_config
get_config() -> dict
Returns the configuration of this replacement filter codec.
numcodecs.registry.get_codec(config)
can be used to reconstruct this codec from the returned config.
| Returns: |
|
|---|