コード例 #1
0
 def check_xyz_lab(self, xyz0, verbose):
     ''' Check that lab_from_xyz() and xyz_from_lab() are inverses. '''
     tolerance = 1.0e-10
     lab0 = colormodels.lab_from_xyz (xyz0)
     xyz1 = colormodels.xyz_from_lab (lab0)
     lab1 = colormodels.lab_from_xyz (xyz1)
     # Check errors.
     dlab = lab1 - lab0
     error_lab = math.sqrt (numpy.dot (dlab, dlab))
     dxyz = xyz1 - xyz0
     error_xyz = math.sqrt (numpy.dot (dxyz, dxyz))
     self.assertLessEqual(error_lab, tolerance)
     self.assertLessEqual(error_xyz, tolerance)
     msg = 'xyz0: %s    lab0: %s    xyz1: %s    lab1: %s' % (
         str(xyz0), str(lab0), str(xyz1), str(lab1))
     if verbose:
         print (msg)
コード例 #2
0
 def check_xyz_lab(self, xyz0, verbose):
     ''' Check that lab_from_xyz() and xyz_from_lab() are inverses. '''
     tolerance = 1.0e-10
     lab0 = colormodels.lab_from_xyz(xyz0)
     xyz1 = colormodels.xyz_from_lab(lab0)
     lab1 = colormodels.lab_from_xyz(xyz1)
     # Check errors.
     dlab = lab1 - lab0
     error_lab = math.sqrt(numpy.dot(dlab, dlab))
     dxyz = xyz1 - xyz0
     error_xyz = math.sqrt(numpy.dot(dxyz, dxyz))
     self.assertLessEqual(error_lab, tolerance)
     self.assertLessEqual(error_xyz, tolerance)
     msg = 'xyz0: %s    lab0: %s    xyz1: %s    lab1: %s' % (
         str(xyz0), str(lab0), str(xyz1), str(lab1))
     if verbose:
         print(msg)
コード例 #3
0
ファイル: test_colormodels.py プロジェクト: Stanpol/ColorPy
 def test_A (xyz0, tolerance=1.0e-10, verbose=1):
     '''Test that lab_from_xyz() and xyz_from_lab() are inverses.'''
     lab0 = colormodels.lab_from_xyz (xyz0)
     xyz1 = colormodels.xyz_from_lab (lab0)
     lab1 = colormodels.lab_from_xyz (xyz1)
     # check errors
     dlab = lab1 - lab0
     error_lab = math.sqrt (numpy.dot (dlab, dlab))
     dxyz = xyz1 - xyz0
     error_xyz = math.sqrt (numpy.dot (dxyz, dxyz))
     passed = (error_lab <= tolerance) and (error_xyz <= tolerance)
     if passed:
         status = 'pass'
     else:
         status = 'FAILED'
     msg = 'test_xyz_lab.test_A() : xyz0 = %s, lab(xyz0) = %s, xyz(lab(xyz0)) = %s, lab(xyz(lab(xyz0))) = %s, errors = (%g, %g), %s' % (
         str (xyz0), str (lab0), str (xyz1), str (lab1), error_lab, error_xyz, status)
     if verbose >= 1:
         print msg
     if not passed:
         pass
         raise ValueError, msg
     return passed
コード例 #4
0
ファイル: test_colormodels.py プロジェクト: sseo42/Univ_TMM
 def test_A(xyz0, tolerance=1.0e-10, verbose=1):
     '''Test that lab_from_xyz() and xyz_from_lab() are inverses.'''
     lab0 = colormodels.lab_from_xyz(xyz0)
     xyz1 = colormodels.xyz_from_lab(lab0)
     lab1 = colormodels.lab_from_xyz(xyz1)
     # check errors
     dlab = lab1 - lab0
     error_lab = math.sqrt(numpy.dot(dlab, dlab))
     dxyz = xyz1 - xyz0
     error_xyz = math.sqrt(numpy.dot(dxyz, dxyz))
     passed = (error_lab <= tolerance) and (error_xyz <= tolerance)
     if passed:
         status = 'pass'
     else:
         status = 'FAILED'
     msg = 'test_xyz_lab.test_A() : xyz0 = %s, lab(xyz0) = %s, xyz(lab(xyz0)) = %s, lab(xyz(lab(xyz0))) = %s, errors = (%g, %g), %s' % (
         str(xyz0), str(lab0), str(xyz1), str(lab1), error_lab, error_xyz,
         status)
     if verbose >= 1:
         print(msg)
     if not passed:
         pass
         raise ValueError(msg)
     return passed