-
Notifications
You must be signed in to change notification settings - Fork 104
Open
Description
The Delta filter does not always preserve the input if it contains nans. Is it possible to use np.nandiff
and np.nancumsum
in place of np.diff
/np.cumsum
in the implementation of Delta?
Example:
#!/usr/bin/env -S uv run --script
#
#
# /// script
# requires-python = ">=3.12"
# dependencies = ["numcodecs==0.16.1"]
# ///
#
import numpy as np
from numcodecs import Delta
codec = Delta(dtype=np.float64)
arr_in = np.array([1.0, 2.0, np.nan, 4.0, 5.0], dtype=np.float64)
arr_enc = codec.encode(arr_in)
arr_dec = codec.decode(arr_enc)
cmp = np.array_equal(arr_in, arr_dec, equal_nan=True)
print('input', arr_in)
print('output', arr_dec)
$ uv run example.py
input [ 1. 2. nan 4. 5.]
output [ 1. 2. nan nan nan]
Metadata
Metadata
Assignees
Labels
No labels