Skip to content

Commit 97c000d

Browse files
committed
Added test_sequence_layers method
1 parent f240a25 commit 97c000d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/tests/test_rplot.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ class TestUtilityFunctions(unittest.TestCase):
2929
"""
3030
Tests for RPlot utility functions.
3131
"""
32+
def setUp(self):
33+
path = os.path.join(curpath(), 'data/iris.csv')
34+
self.data = read_csv(path, sep=',')
35+
3236
def test_make_aes1(self):
3337
aes = rplot.make_aes()
3438
self.assertTrue(aes['x'] is None)
@@ -74,6 +78,19 @@ def test_merge_aes(self):
7478
if key != 'size' and key != 'shape':
7579
self.assertTrue(layer2.aes[key] is None)
7680

81+
def test_sequence_layers(self):
82+
layer1 = rplot.Layer(self.data)
83+
layer2 = rplot.GeomPoint(x='SepalLength', y='SepalWidth', size=rplot.ScaleSize('PetalLength'))
84+
layer3 = rplot.GeomPolyFit(2)
85+
result = rplot.sequence_layers([layer1, layer2, layer3])
86+
self.assertEqual(len(result), 3)
87+
last = result[-1]
88+
self.assertEqual(last.aes['x'], 'SepalLength')
89+
self.assertEqual(last.aes['y'], 'SepalWidth')
90+
self.assertTrue(isinstance(last.aes['size'], rplot.ScaleSize))
91+
self.assertTrue(self.data is last.data)
92+
self.assertTrue(rplot.sequence_layers([layer1])[0] is layer1)
93+
7794
class TestScaleGradient(unittest.TestCase):
7895
def setUp(self):
7996
path = os.path.join(curpath(), 'data/iris.csv')

0 commit comments

Comments
 (0)