Skip to content

Commit eff4027

Browse files
authored
Merge pull request #70 from phobson/test-seaborn
test that markers are handled correctly for seaborn
2 parents 958b33a + 48beb49 commit eff4027

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ matrix:
1515
- python: 3.7
1616
env:
1717
- COVERAGE=true
18-
- EXTRATESTERS=""
18+
- EXTRATESTERS="seaborn"
1919
- ARGS="--pep8 --mpl"
2020

2121
before_install:

probscale/tests/test_viz.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@
22
from functools import wraps
33

44
import numpy
5+
import matplotlib.lines
56
import matplotlib.pyplot as plt
67

78
try:
89
from scipy import stats
910
except: # pragma: no cover
1011
stats = None
1112

13+
try:
14+
import seaborn
15+
except: # pragma: no cover
16+
seaborn = None
17+
1218
from probscale import viz
1319
from probscale.probscale import _minimal_norm
1420
from .helpers import seed
@@ -704,3 +710,31 @@ def test_probplot_color_and_label(plot_data):
704710
label='A Top-Level Label')
705711
ax.legend(loc='lower right')
706712
return fig
713+
714+
715+
@pytest.mark.skipif(seaborn is None, reason="no seaborn")
716+
@pytest.mark.parametrize('usemarkers', [True, False])
717+
def test_probplot_with_FacetGrid_with_markers(usemarkers):
718+
iris = seaborn.load_dataset("iris")
719+
720+
hue_kws = None
721+
species = sorted(iris['species'].unique())
722+
markers = ['o', 'o', 'o']
723+
if usemarkers:
724+
markers = ['o', 's', '^']
725+
hue_kws = {'marker': markers}
726+
727+
fg = (
728+
seaborn.FacetGrid(data=iris, hue='species', hue_kws=hue_kws)
729+
.map(viz.probplot, 'sepal_length')
730+
.set_axis_labels(x_var='Probability', y_var='Sepal Length')
731+
.add_legend()
732+
)
733+
734+
_lines = filter(lambda x: isinstance(x, matplotlib.lines.Line2D), fg.ax.get_children())
735+
result_markers = {
736+
l.get_label(): l.get_marker()
737+
for l in _lines
738+
}
739+
expected_markers = dict(zip(species, markers))
740+
assert expected_markers == result_markers

0 commit comments

Comments
 (0)