diff --git a/tests/test_aggregators.py b/tests/test_aggregators.py index b85dcd19..0b65c5ea 100644 --- a/tests/test_aggregators.py +++ b/tests/test_aggregators.py @@ -109,7 +109,7 @@ def test_arg_downsample_no_x_empty_series(downsampler, series): def test_wrap_aggregate(downsampler, gap_handler, series, index_type): series = series.copy() series.index = construct_index(series, index_type) - for n in np.random.randint(100, len(series), 6): + for n in np.random.randint(100, len(series) // 2, 6): # make sure n is even (required for MinMax downsampler) n = n - (n % 2) x_agg, y_agg, indices = wrap_aggregate( @@ -234,11 +234,10 @@ def test_wrap_aggregate_range_index_data_point_selection( # ------------------------------- NAN handling ------------------------------- @pytest.mark.parametrize("downsampler", [MinMaxLTTB, MinMaxAggregator]) -@pytest.mark.parametrize("gap_handler", [MedDiffGapHandler, NoGapHandler]) @pytest.mark.parametrize("series", [lf("float_series")]) -def test_nan_behavior(series, downsampler, gap_handler): +def test_nan_behavior(series, downsampler): series = series.copy() - series.iloc[np.random.choice(len(series), 100)] = np.nan + series.iloc[1 + np.random.choice(len(series) - 2, 100, replace=False)] = np.nan # OMIT -> no NaNs in the output for n in np.random.randint(100, len(series), 6): diff --git a/tests/test_figure_resampler.py b/tests/test_figure_resampler.py index bebd9f59..640914ec 100644 --- a/tests/test_figure_resampler.py +++ b/tests/test_figure_resampler.py @@ -435,7 +435,9 @@ def test_nan_retained_input(float_series): # ADD nans to to the float_series float_series = float_series.copy() - float_series.iloc[np.random.choice(len(float_series), 100, replace=False)] = np.nan + float_series.iloc[ + 1 + np.random.choice(len(float_series) - 2, 100, replace=False) + ] = np.nan fig.add_trace( go.Scatter(x=float_series.index, y=float_series, name="float_series"), row=1, @@ -449,7 +451,9 @@ def test_nan_retained_input(float_series): assert pd.isna(fig.hf_data[0]["y"]).sum() == 100 # here we test whether we are able to deal with not-nan output - float_series.iloc[np.random.choice(len(float_series), 100)] = np.nan + float_series.iloc[ + 1 + np.random.choice(len(float_series) - 2, 100, replace=False) + ] = np.nan fig.add_trace( go.Scatter( x=float_series.index, y=float_series @@ -459,7 +463,9 @@ def test_nan_retained_input(float_series): col=1, ) - float_series.iloc[np.random.choice(len(float_series), 100)] = np.nan + float_series.iloc[ + 1 + np.random.choice(len(float_series) - 2, 100, replace=False) + ] = np.nan fig.add_trace( go.Scattergl( x=float_series.index, @@ -599,7 +605,7 @@ def test_hf_text_and_hf_marker_color(): def test_hf_text_and_hf_hovertext_and_hf_marker_size_nans(): y_orig = np.arange(10_000).astype(float) y = y_orig.copy() - y[::101] = np.nan + y[1::101] = np.nan # NEW from plotly-resampler >0.9.2 => we retain the NaNs in the input data and # the NaN handling is delegated to the aggregators diff --git a/tests/test_figurewidget_resampler.py b/tests/test_figurewidget_resampler.py index 90e83d51..03f73bd4 100644 --- a/tests/test_figurewidget_resampler.py +++ b/tests/test_figurewidget_resampler.py @@ -265,7 +265,9 @@ def test_nan_removed_input(float_series): # Add NaN's to the float series float_series = float_series.copy() - float_series.iloc[np.random.choice(len(float_series), 100, replace=False)] = np.nan + float_series.iloc[ + 1 + np.random.choice(len(float_series) - 2, 100, replace=False) + ] = np.nan fig.add_trace( go.Scatter(x=float_series.index, y=float_series, name="float_series"), row=1, @@ -279,7 +281,9 @@ def test_nan_removed_input(float_series): assert pd.isna(fig.hf_data[0]["y"]).sum() == 100 # here we test whether we are able to deal with not-nan output - float_series.iloc[np.random.choice(len(float_series), 100)] = np.nan + float_series.iloc[ + 1 + np.random.choice(len(float_series) - 2, 100, replace=False) + ] = np.nan fig.add_trace( go.Scatter( x=float_series.index, y=float_series @@ -289,7 +293,9 @@ def test_nan_removed_input(float_series): col=1, ) - float_series.iloc[np.random.choice(len(float_series), 100)] = np.nan + float_series.iloc[ + 1 + np.random.choice(len(float_series) - 2, 100, replace=False) + ] = np.nan fig.add_trace( go.Scattergl( x=float_series.index,