def check_xyz_luv(self, xyz0, verbose): ''' Check that luv_from_xyz() and xyz_from_luv() are inverses. ''' tolerance = 1.0e-10 luv0 = colormodels.luv_from_xyz (xyz0) xyz1 = colormodels.xyz_from_luv (luv0) luv1 = colormodels.luv_from_xyz (xyz1) # Check errors. dluv = luv1 - luv0 error_luv = math.sqrt (numpy.dot (dluv, dluv)) dxyz = xyz1 - xyz0 error_xyz = math.sqrt (numpy.dot (dxyz, dxyz)) self.assertLessEqual(error_luv, tolerance) self.assertLessEqual(error_xyz, tolerance) msg = 'xyz0: %s luv0: %s xyz1: %s luv1: %s' % ( str(xyz0), str(luv0), str(xyz1), str(luv1)) if verbose: print (msg)
def check_xyz_luv(self, xyz0, verbose): ''' Check that luv_from_xyz() and xyz_from_luv() are inverses. ''' tolerance = 1.0e-10 luv0 = colormodels.luv_from_xyz(xyz0) xyz1 = colormodels.xyz_from_luv(luv0) luv1 = colormodels.luv_from_xyz(xyz1) # Check errors. dluv = luv1 - luv0 error_luv = math.sqrt(numpy.dot(dluv, dluv)) dxyz = xyz1 - xyz0 error_xyz = math.sqrt(numpy.dot(dxyz, dxyz)) self.assertLessEqual(error_luv, tolerance) self.assertLessEqual(error_xyz, tolerance) msg = 'xyz0: %s luv0: %s xyz1: %s luv1: %s' % ( str(xyz0), str(luv0), str(xyz1), str(luv1)) if verbose: print(msg)
def test_A (xyz0, tolerance=1.0e-10, verbose=1): '''Test that luv_from_xyz() and xyz_from_luv() are inverses.''' luv0 = colormodels.luv_from_xyz (xyz0) xyz1 = colormodels.xyz_from_luv (luv0) luv1 = colormodels.luv_from_xyz (xyz1) # check errors dluv = luv1 - luv0 error_luv = math.sqrt (numpy.dot (dluv, dluv)) dxyz = xyz1 - xyz0 error_xyz = math.sqrt (numpy.dot (dxyz, dxyz)) passed = (error_luv <= tolerance) and (error_xyz <= tolerance) if passed: status = 'pass' else: status = 'FAILED' msg = 'test_xyz_luv.test_A() : xyz0 = %s, luv(xyz0) = %s, xyz(luv(xyz0)) = %s, luv(xyz(luv(xyz0))) = %s, errors = (%g, %g), %s' % ( str (xyz0), str (luv0), str (xyz1), str (luv1), error_luv, error_xyz, status) if verbose >= 1: print msg if not passed: pass raise ValueError, msg return passed
def test_A(xyz0, tolerance=1.0e-10, verbose=1): '''Test that luv_from_xyz() and xyz_from_luv() are inverses.''' luv0 = colormodels.luv_from_xyz(xyz0) xyz1 = colormodels.xyz_from_luv(luv0) luv1 = colormodels.luv_from_xyz(xyz1) # check errors dluv = luv1 - luv0 error_luv = math.sqrt(numpy.dot(dluv, dluv)) dxyz = xyz1 - xyz0 error_xyz = math.sqrt(numpy.dot(dxyz, dxyz)) passed = (error_luv <= tolerance) and (error_xyz <= tolerance) if passed: status = 'pass' else: status = 'FAILED' msg = 'test_xyz_luv.test_A() : xyz0 = %s, luv(xyz0) = %s, xyz(luv(xyz0)) = %s, luv(xyz(luv(xyz0))) = %s, errors = (%g, %g), %s' % ( str(xyz0), str(luv0), str(xyz1), str(luv1), error_luv, error_xyz, status) if verbose >= 1: print(msg) if not passed: pass raise ValueError(msg) return passed