@@ -771,9 +771,6 @@ def _make_ds_canvas_and_df(n=500, seed=42):
771771 return cvs , df
772772
773773
774- # -- Fix: default_reduction parameter forwarding --
775-
776-
777774def test_ds_aggregate_default_reduction_is_forwarded ():
778775 """default_reduction must affect the actual aggregation, not just the log message."""
779776 cvs , df = _make_ds_canvas_and_df ()
@@ -807,9 +804,6 @@ def test_ds_aggregate_explicit_overrides_default():
807804 )
808805
809806
810- # -- Fix: warn when ds_reduction is ignored for categorical data --
811-
812-
813807def test_ds_reduction_ignored_for_categorical (caplog ):
814808 """Categorical aggregation always uses ds.count(); a warning is emitted when ds_reduction is set."""
815809 cvs , df = _make_ds_canvas_and_df ()
@@ -829,16 +823,13 @@ def test_ds_reduction_no_warning_when_none(caplog):
829823 assert not any ("ignored" in r .message .lower () for r in caplog .records )
830824
831825
832- def test_ds_reduction_categorical_always_uses_count ():
833- """All ds_reduction values produce the same aggregate for categorical data (by design)."""
826+ @pytest .mark .parametrize ("reduction" , ["mean" , "max" , "min" , "count" , "std" , "var" ])
827+ def test_ds_reduction_categorical_always_uses_count (reduction ):
828+ """Categorical aggregation always uses ds.count(), regardless of ds_reduction (by design)."""
834829 cvs , df = _make_ds_canvas_and_df ()
835830 base , _ , _ = _ds_aggregate (cvs , df .copy (), "cat" , True , "sum" , "sum" , "points" )
836- for red in ["mean" , "max" , "min" , "count" , "std" , "var" ]:
837- agg , _ , _ = _ds_aggregate (cvs , df .copy (), "cat" , True , red , red , "points" )
838- np .testing .assert_array_equal (agg .values , base .values )
839-
840-
841- # -- Fix: warn when groups is used with continuous data --
831+ agg , _ , _ = _ds_aggregate (cvs , df .copy (), "cat" , True , reduction , reduction , "points" )
832+ np .testing .assert_array_equal (agg .values , base .values )
842833
843834
844835def test_groups_warns_when_continuous_points (sdata_blobs : SpatialData , caplog ):
@@ -866,9 +857,6 @@ def test_warn_groups_ignored_continuous_silent_for_categorical(caplog):
866857 assert not any ("ignored" in r .message for r in caplog .records )
867858
868859
869- # -- Fix: warn on color_vector length mismatch in _build_datashader_color_key --
870-
871-
872860def test_color_key_warns_on_short_color_vector (caplog ):
873861 """Warning when color_vector is shorter than categorical series."""
874862 cat = pd .Categorical (["A" , "B" , "C" , "A" , "B" , "C" , "A" ])
@@ -904,9 +892,6 @@ def test_color_key_unseen_category_gets_na_color(caplog):
904892 assert result ["D" ] == "#cccccc"
905893
906894
907- # -- Fix: _ds_shade_categorical only sets cmap when no color_key --
908-
909-
910895def test_shade_categorical_color_key_overrides_cmap ():
911896 """When color_key is provided, different color_vector[0] values must produce identical output."""
912897 cvs , df = _make_ds_canvas_and_df (n = 100 )
@@ -919,8 +904,10 @@ def test_shade_categorical_color_key_overrides_cmap():
919904
920905
921906def test_shade_categorical_cmap_used_when_no_color_key ():
922- """When color_key is None (no color column), cmap is set from color_vector[0]."""
907+ """When color_key is None (no color column), cmap from color_vector[0] affects output ."""
923908 cvs , df = _make_ds_canvas_and_df (n = 100 )
924909 agg = cvs .points (df , "x" , "y" , agg = ds .count ())
925- shaded = _ds_shade_categorical (agg , None , np .array (["#ff0000" ] * 100 ), alpha = 1.0 )
926- assert shaded is not None
910+ shaded_red = _ds_shade_categorical (agg , None , np .array (["#ff0000" ] * 100 ), alpha = 1.0 )
911+ shaded_blue = _ds_shade_categorical (agg , None , np .array (["#0000ff" ] * 100 ), alpha = 1.0 )
912+ # Different color_vector[0] values should produce different shaded output
913+ assert not np .array_equal (np .asarray (shaded_red ), np .asarray (shaded_blue ))
0 commit comments