Skip to content

Commit 7644740

Browse files
committed
TST: Add test for after_scale mapping
1 parent ec704cd commit 7644740

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

.coveragerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ exclude_lines =
1212
pragma: no cover
1313
^def test_
1414
if __name__ == .__main__.:
15+
raise NotImplementedError('Not Implemented')
1516
precision = 1
5.22 KB
Loading

plotnine/tests/test_ggplot_internals.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from plotnine import xlab, ylab, labs, ggtitle, xlim, lims, guides
1010
from plotnine import scale_x_continuous, coord_trans, annotate
1111
from plotnine import stat_identity, facet_null, theme, theme_gray
12-
from plotnine import stage, after_stat
12+
from plotnine import stage, after_stat, after_scale
1313
from plotnine.mapping.aes import is_valid_aesthetic
1414
from plotnine.exceptions import PlotnineError, PlotnineWarning
1515

@@ -197,6 +197,20 @@ def _test():
197197
p.draw_test()
198198

199199

200+
def test_after_scale_mapping():
201+
df = pd.DataFrame({'x': [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]})
202+
df2 = pd.DataFrame({
203+
# Same as above, but add 2 of each unique element
204+
'x': [1, 2, 2, 3, 3, 3, 4, 4, 4, 4] + [1, 2, 3, 4] * 2
205+
})
206+
207+
p = ggplot(df) + geom_bar(aes(x='x', ymax=after_scale('ymax + 2')))
208+
p2 = ggplot(df2) + geom_bar(aes(x='x'))
209+
210+
assert p + lims(y=(0, 7)) == 'after_scale_mapping'
211+
assert p2 + lims(y=(0, 7)) == 'after_scale_mapping'
212+
213+
200214
def test_add_aes():
201215
df = pd.DataFrame({'var1': [1, 2, 3, 4],
202216
'var2': 2})

0 commit comments

Comments
 (0)