Skip to content

Commit a019f61

Browse files
committed
Allow training of Series with tuples
closes has2k1/plotnine#933
1 parent c34ba7f commit a019f61

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

doc/changelog.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
Changelog
22
=========
33

4+
v0.13.3
5+
-------
6+
7+
*2025-04-11*
8+
9+
Enhancements
10+
************
11+
12+
- Make it possible to train discrete data that is a sequence of tuples.
13+
(plotnine issue [#933](https://github.com/has2k1/plotnine/issues/933))
14+
415
v0.13.2
516
-------
617
*2025-04-03*

mizani/scale.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def train(
272272
limits = old + [i for i in new if (i not in old_set)]
273273

274274
# Add nan if required
275-
has_na_limits = any(pd.isna(limits))
275+
has_na_limits = pd.isna(limits).any()
276276
if not has_na_limits and not na_rm and has_na:
277277
limits.append(np.nan)
278278
return limits

tests/test_scale.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,10 @@ def SCategorical(*args, **kwargs):
111111
limits = scale_discrete.train(x2, old=limits)
112112
# assert limits == list('abcedf')
113113
assert limits == list("adefbc")
114+
115+
# Sequence of tuples
116+
x1 = pd.Series([(1, 2), (3, 4), (5, 6)])
117+
x2 = pd.Series([(1, 2), (7, 8)])
118+
limits = scale_discrete.train(x1)
119+
limits = scale_discrete.train(x2, old=limits)
120+
assert limits == [(1, 2), (3, 4), (5, 6), (7, 8)]

0 commit comments

Comments
 (0)