Back to index

python3.2  3.2.2
Public Member Functions
test.test_colorsys.ColorsysTest Class Reference

List of all members.

Public Member Functions

def assertTripleEqual
def test_hsv_roundtrip
def test_hsv_values
def test_hls_roundtrip
def test_hls_values

Detailed Description

Definition at line 9 of file test_colorsys.py.


Member Function Documentation

def test.test_colorsys.ColorsysTest.assertTripleEqual (   self,
  tr1,
  tr2 
)

Definition at line 11 of file test_colorsys.py.

00011 
00012     def assertTripleEqual(self, tr1, tr2):
00013         self.assertEqual(len(tr1), 3)
00014         self.assertEqual(len(tr2), 3)
00015         self.assertAlmostEqual(tr1[0], tr2[0])
00016         self.assertAlmostEqual(tr1[1], tr2[1])
00017         self.assertAlmostEqual(tr1[2], tr2[2])

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 45 of file test_colorsys.py.

00045 
00046     def test_hls_roundtrip(self):
00047         for r in frange(0.0, 1.0, 0.2):
00048             for g in frange(0.0, 1.0, 0.2):
00049                 for b in frange(0.0, 1.0, 0.2):
00050                     rgb = (r, g, b)
00051                     self.assertTripleEqual(
00052                         rgb,
00053                         colorsys.hls_to_rgb(*colorsys.rgb_to_hls(*rgb))
00054                     )

Here is the call graph for this function:

Definition at line 55 of file test_colorsys.py.

00055 
00056     def test_hls_values(self):
00057         values = [
00058             # rgb, hls
00059             ((0.0, 0.0, 0.0), (  0  , 0.0, 0.0)), # black
00060             ((0.0, 0.0, 1.0), (4./6., 0.5, 1.0)), # blue
00061             ((0.0, 1.0, 0.0), (2./6., 0.5, 1.0)), # green
00062             ((0.0, 1.0, 1.0), (3./6., 0.5, 1.0)), # cyan
00063             ((1.0, 0.0, 0.0), (  0  , 0.5, 1.0)), # red
00064             ((1.0, 0.0, 1.0), (5./6., 0.5, 1.0)), # purple
00065             ((1.0, 1.0, 0.0), (1./6., 0.5, 1.0)), # yellow
00066             ((1.0, 1.0, 1.0), (  0  , 1.0, 0.0)), # white
00067             ((0.5, 0.5, 0.5), (  0  , 0.5, 0.0)), # grey
00068         ]
00069         for (rgb, hls) in values:
00070             self.assertTripleEqual(hls, colorsys.rgb_to_hls(*rgb))
00071             self.assertTripleEqual(rgb, colorsys.hls_to_rgb(*hls))

Here is the call graph for this function:

Definition at line 18 of file test_colorsys.py.

00018 
00019     def test_hsv_roundtrip(self):
00020         for r in frange(0.0, 1.0, 0.2):
00021             for g in frange(0.0, 1.0, 0.2):
00022                 for b in frange(0.0, 1.0, 0.2):
00023                     rgb = (r, g, b)
00024                     self.assertTripleEqual(
00025                         rgb,
00026                         colorsys.hsv_to_rgb(*colorsys.rgb_to_hsv(*rgb))
00027                     )

Here is the call graph for this function:

Definition at line 28 of file test_colorsys.py.

00028 
00029     def test_hsv_values(self):
00030         values = [
00031             # rgb, hsv
00032             ((0.0, 0.0, 0.0), (  0  , 0.0, 0.0)), # black
00033             ((0.0, 0.0, 1.0), (4./6., 1.0, 1.0)), # blue
00034             ((0.0, 1.0, 0.0), (2./6., 1.0, 1.0)), # green
00035             ((0.0, 1.0, 1.0), (3./6., 1.0, 1.0)), # cyan
00036             ((1.0, 0.0, 0.0), (  0  , 1.0, 1.0)), # red
00037             ((1.0, 0.0, 1.0), (5./6., 1.0, 1.0)), # purple
00038             ((1.0, 1.0, 0.0), (1./6., 1.0, 1.0)), # yellow
00039             ((1.0, 1.0, 1.0), (  0  , 0.0, 1.0)), # white
00040             ((0.5, 0.5, 0.5), (  0  , 0.0, 0.5)), # grey
00041         ]
00042         for (rgb, hsv) in values:
00043             self.assertTripleEqual(hsv, colorsys.rgb_to_hsv(*rgb))
00044             self.assertTripleEqual(rgb, colorsys.hsv_to_rgb(*hsv))

Here is the call graph for this function:


The documentation for this class was generated from the following file: