コード例 #1
0
 def check_xyz_irgb(self, xyz0, verbose):
     ''' Check the direct conversions from xyz to irgb. '''
     irgb0 = colormodels.irgb_from_rgb(colormodels.rgb_from_xyz(xyz0))
     irgb1 = colormodels.irgb_from_xyz(xyz0)
     self.assertEqual(irgb0[0], irgb1[0])
     self.assertEqual(irgb0[1], irgb1[1])
     self.assertEqual(irgb0[2], irgb1[2])
     # The string should also match.
     irgbs0 = colormodels.irgb_string_from_rgb(
         colormodels.rgb_from_xyz(xyz0))
     irgbs1 = colormodels.irgb_string_from_xyz(xyz0)
     msg = 'irgb0: %s    text0: %s        irgb1: %s    text1: %s' % (
         str(irgb0), irgbs0, str(irgb1), irgbs1)
     if verbose:
         print(msg)
     self.assertEqual(irgbs0, irgbs1)
コード例 #2
0
 def check_xyz_irgb(self, xyz0, verbose):
     ''' Check the direct conversions from xyz to irgb. '''
     irgb0 = colormodels.irgb_from_rgb (
         colormodels.rgb_from_xyz (xyz0))
     irgb1 = colormodels.irgb_from_xyz (xyz0)
     self.assertEqual(irgb0[0], irgb1[0])
     self.assertEqual(irgb0[1], irgb1[1])
     self.assertEqual(irgb0[2], irgb1[2])
     # The string should also match.
     irgbs0 = colormodels.irgb_string_from_rgb (
         colormodels.rgb_from_xyz (xyz0))
     irgbs1 = colormodels.irgb_string_from_xyz (xyz0)
     msg = 'irgb0: %s    text0: %s        irgb1: %s    text1: %s' % (
         str(irgb0), irgbs0, str(irgb1), irgbs1)
     if verbose:
         print (msg)
     self.assertEqual(irgbs0, irgbs1)
コード例 #3
0
ファイル: test_colormodels.py プロジェクト: sseo42/Univ_TMM
def test_xyz_irgb(verbose=1):
    '''Test the direct conversions from xyz to irgb.'''
    for i in xrange(0, 100):
        x0 = 10.0 * random.random()
        y0 = 10.0 * random.random()
        z0 = 10.0 * random.random()
        xyz0 = colormodels.xyz_color(x0, y0, z0)
        irgb0 = colormodels.irgb_from_rgb(colormodels.rgb_from_xyz(xyz0))
        irgb1 = colormodels.irgb_from_xyz(xyz0)
        if (irgb0[0] != irgb1[0]) or (irgb0[1] != irgb1[1]) or (irgb0[2] !=
                                                                irgb1[2]):
            raise ValueError
        irgbs0 = colormodels.irgb_string_from_rgb(
            colormodels.rgb_from_xyz(xyz0))
        irgbs1 = colormodels.irgb_string_from_xyz(xyz0)
        if irgbs0 != irgbs1:
            raise ValueError
    print('Passed test_xyz_irgb()')
コード例 #4
0
ファイル: test_colormodels.py プロジェクト: Stanpol/ColorPy
def test_xyz_irgb (verbose=1):
    '''Test the direct conversions from xyz to irgb.'''
    for i in xrange (0, 100):
        x0 = 10.0 * random.random()
        y0 = 10.0 * random.random()
        z0 = 10.0 * random.random()
        xyz0 = colormodels.xyz_color (x0,y0,z0)
        irgb0 = colormodels.irgb_from_rgb (
            colormodels.rgb_from_xyz (xyz0))
        irgb1 = colormodels.irgb_from_xyz (xyz0)
        if (irgb0[0] != irgb1[0]) or (irgb0[1] != irgb1[1]) or (irgb0[2] != irgb1[2]):
            raise ValueError
        irgbs0 = colormodels.irgb_string_from_rgb (
            colormodels.rgb_from_xyz (xyz0))
        irgbs1 = colormodels.irgb_string_from_xyz (xyz0)
        if irgbs0 != irgbs1:
            raise ValueError
    print 'Passed test_xyz_irgb()'