Skip to content

Commit

Permalink
[Fix issue][#3511]lineplot of empty dataframe with hue in seaborn 0.1…
Browse files Browse the repository at this point in the history
…3.0 (#3569)

* Update _base.py

Corresponds to the case where grouping_var has None object.

* Add a test case

Add a test case to test_relational.py and a fixture empty dataframe.

* Fix error

To avoid the error 'The truth value of an array with more than one element is ambiguous.', we don't use walrus operator.

* Incorporate feedbacks.

- Remove unnecessary fixture.
- Refactoring.
  • Loading branch information
nokoshu authored Nov 28, 2023
1 parent d4b8de8 commit 9a2196d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion seaborn/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,8 @@ def iter_data(

grouping_keys = []
for var in grouping_vars:
grouping_keys.append(levels.get(var, []))
key = levels.get(var)
grouping_keys.append([] if key is None else key)

iter_keys = itertools.product(*grouping_keys)
if reverse:
Expand Down
3 changes: 3 additions & 0 deletions tests/test_relational.py
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,9 @@ def test_lineplot_smoke(
lineplot(x="x", y="y", hue="f", size="s", data=object_df)
ax.clear()

lineplot(x="x", y="y", hue="a", data=long_df.iloc[:0])
ax.clear()

def test_ci_deprecation(self, long_df):

axs = plt.figure().subplots(2)
Expand Down

0 comments on commit 9a2196d

Please sign in to comment.