Skip to content

Commit

Permalink
🙈 fix typo in NaNMinMaxDownsampler
Browse files Browse the repository at this point in the history
  • Loading branch information
jvdd committed Jan 24, 2024
1 parent 6916dbb commit 910c788
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Extremely fast **time series downsampling 📈** for visualization, written in R
- **Flexible**: works on any type of data
- supported datatypes are
- for `x`: `f32`, `f64`, `i16`, `i32`, `i64`, `u16`, `u32`, `u64`, `datetime64`, `timedelta64`
- for `y`: `f16`, `f32`, `f64`, `i8`, `i16`, `i32`, `i64`, `u8`, `u16`, `u32`, `u64`, `datetime64`, `timedelta64`, `bool`<sup>\*</sup>
- for `y`: `f16`, `f32`, `f64`, `i8`, `i16`, `i32`, `i64`, `u8`, `u16`, `u32`, `u64`, `datetime64`, `timedelta64`, `bool`
<details>
<summary><i>!! 🚀 <code>f16</code> <a href="https://github.com/jvdd/argminmax">argminmax</a> is 200-300x faster than numpy</i></summary>
In contrast with all other data types above, <code>f16</code> is *not* hardware supported (i.e., no instructions for f16) by most modern CPUs!! <br>
Expand All @@ -42,8 +42,6 @@ Extremely fast **time series downsampling 📈** for visualization, written in R
</details>
- **Easy to use**: simple & flexible API

<sup>\*</sup><i>When `NaN`s need to be retained in the downsampling, the only supported datatypes for `y` are `f16`, `f32` and `f64`</i>

## Install

```bash
Expand Down Expand Up @@ -126,11 +124,14 @@ This library supports two `NaN`-policies:
| `MinMaxLTTBDownsampler` | `NaNMinMaxLTTBDownsampler` |
| `LTTBDownsampler` | |

> Note that NaNs are not supported for `x`-data.
## Limitations & assumptions 🚨

Assumes;

1. `x`-data is (non-strictly) monotonic increasing (i.e., sorted)
2. no `NaN`s in `x`-data

---

Expand Down
6 changes: 3 additions & 3 deletions tests/test_algos_python_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
M4Downsampler,
MinMaxDownsampler,
NaNM4Downsampler,
NanMinMaxDownsampler,
NaNMinMaxDownsampler,
)
from tsdownsample._python.downsamplers import (
LTTB_py,
Expand All @@ -24,7 +24,7 @@
(M4Downsampler(), M4_py()),
(LTTBDownsampler(), LTTB_py()),
# Include NaN downsamplers
(NanMinMaxDownsampler(), NaNMinMax_py()),
(NaNMinMaxDownsampler(), NaNMinMax_py()),
(NaNM4Downsampler(), NaNM4_py()),
],
)
Expand All @@ -48,7 +48,7 @@ def test_resampler_accordance(rust_python_pair, n, n_out):

@pytest.mark.parametrize(
"rust_python_pair",
[(NanMinMaxDownsampler(), NaNMinMax_py()), (NaNM4Downsampler(), NaNM4_py())],
[(NaNMinMaxDownsampler(), NaNMinMax_py()), (NaNM4Downsampler(), NaNM4_py())],
)
@pytest.mark.parametrize("n", [10_000, 10_032, 20_321, 23_489])
@pytest.mark.parametrize("n_random_nans", [100, 200, 500, 2000, 5000])
Expand Down
6 changes: 3 additions & 3 deletions tests/test_tsdownsample.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
MinMaxDownsampler,
MinMaxLTTBDownsampler,
NaNM4Downsampler,
NanMinMaxDownsampler,
NaNMinMaxDownsampler,
NaNMinMaxLTTBDownsampler,
)
from tsdownsample.downsampling_interface import (
Expand All @@ -31,7 +31,7 @@
]

RUST_NAN_DOWNSAMPLERS = [
NanMinMaxDownsampler(),
NaNMinMaxDownsampler(),
NaNM4Downsampler(),
NaNMinMaxLTTBDownsampler(),
]
Expand Down Expand Up @@ -367,7 +367,7 @@ def test_nan_minmax_downsampler():
"""Test NaN downsamplers."""
arr = np.random.randn(50_000)
arr[::5] = np.nan
s_downsampled = NanMinMaxDownsampler().downsample(arr, n_out=100)
s_downsampled = NaNMinMaxDownsampler().downsample(arr, n_out=100)
arr_downsampled = arr[s_downsampled]
assert np.all(np.isnan(arr_downsampled))

Expand Down
4 changes: 2 additions & 2 deletions tsdownsample/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
MinMaxDownsampler,
MinMaxLTTBDownsampler,
NaNM4Downsampler,
NanMinMaxDownsampler,
NaNMinMaxDownsampler,
NaNMinMaxLTTBDownsampler,
)

Expand All @@ -20,7 +20,7 @@
"M4Downsampler",
"LTTBDownsampler",
"MinMaxLTTBDownsampler",
"NanMinMaxDownsampler",
"NaNMinMaxDownsampler",
"NaNM4Downsampler",
"NaNMinMaxLTTBDownsampler",
]
2 changes: 1 addition & 1 deletion tsdownsample/downsamplers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _check_valid_n_out(n_out: int):
raise ValueError("n_out must be even")


class NanMinMaxDownsampler(AbstractRustNaNDownsampler):
class NaNMinMaxDownsampler(AbstractRustNaNDownsampler):
"""Downsampler that uses the MinMax algorithm. If the y data contains NaNs, the
indices of these NaNs are returned.
Expand Down

0 comments on commit 910c788

Please sign in to comment.