Skip to content

Commit 3be9987

Browse files
committed
Added TestScaleRandomColour class
1 parent 67bfe03 commit 3be9987

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pandas/tests/test_rplot.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,23 @@ def test_gradient2(self):
116116
self.assertTrue(between(g2, g3, g))
117117
self.assertTrue(between(b2, b3, b))
118118

119+
class TestScaleRandomColour(unittest.TestCase):
120+
def setUp(self):
121+
path = os.path.join(curpath(), 'data/iris.csv')
122+
self.data = read_csv(path, sep=',')
123+
self.colour = rplot.ScaleRandomColour('SepalLength')
124+
125+
def test_random_colour(self):
126+
for index in range(len(self.data)):
127+
colour = self.colour(self.data, index)
128+
self.assertEqual(len(colour), 3)
129+
r, g, b = colour
130+
self.assertGreaterEqual(r, 0.0)
131+
self.assertGreaterEqual(g, 0.0)
132+
self.assertGreaterEqual(b, 0.0)
133+
self.assertLessEqual(r, 1.0)
134+
self.assertLessEqual(g, 1.0)
135+
self.assertLessEqual(b, 1.0)
136+
119137
if __name__ == '__main__':
120138
unittest.main()

0 commit comments

Comments
 (0)