Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid exception from Continuous scale for normed property with non-float data #3190

Merged
merged 1 commit into from
Dec 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/whatsnew/v0.12.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ v0.12.2 (Unreleased)

- |Fix| Fixed a regression in v0.12.0 where manually-added labels could have duplicate legend entries (:pr:`3116`).

- |Fix| Normed properties using a :class:`objects.Continuous` scale no longer raise on boolean data (:pr:`3189`).

- |Fix| Fixed a bug in :func:`histplot` with `kde=True` and `log_scale=True` where the curve was not scaled properly (:pr:`3173`).

- |Fix| Fixed a bug in :func:`relplot` where inner axis labels would be shown when axis sharing was disabled (:pr:`3180`).
2 changes: 1 addition & 1 deletion seaborn/_core/scales.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def _setup(
vmin, vmax = data.min(), data.max()
else:
vmin, vmax = new.norm
vmin, vmax = axis.convert_units((vmin, vmax))
vmin, vmax = map(float, axis.convert_units((vmin, vmax)))
a = forward(vmin)
b = forward(vmax) - forward(vmin)

Expand Down
6 changes: 6 additions & 0 deletions tests/_core/test_scales.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ def test_interval_with_range_norm_and_transform(self, x):
s = Continuous((2, 3), (10, 100), "log")._setup(x, IntervalProperty())
assert_array_equal(s(x), [1, 2, 3])

def test_interval_with_bools(self):

x = pd.Series([True, False, False])
s = Continuous()._setup(x, IntervalProperty())
assert_array_equal(s(x), [1, 0, 0])

def test_color_defaults(self, x):

cmap = color_palette("ch:", as_cmap=True)
Expand Down