Beispiel #1
0
 def check_uv_primes_inverse_1(self, xyz0, verbose):
     ''' Check that uv_primes() and uv_primes_inverse() are inverses. '''
     up0, vp0 = colormodels.uv_primes(xyz0)
     xyz1 = colormodels.uv_primes_inverse(up0, vp0, xyz0[1])
     # Check error.
     dxyz = (xyz1 - xyz0)
     error = math.sqrt(numpy.dot(dxyz, dxyz))
     tolerance = 1.0e-13
     self.assertLessEqual(error, tolerance)
     msg = 'xyz0: %s    up: %g    vp: %g    xyz(up,vp): %s    Error: %g' % (
         str(xyz0), up0, vp0, str(xyz1), error)
     if verbose:
         print(msg)
 def check_uv_primes_inverse_1(self, xyz0, verbose):
     ''' Check that uv_primes() and uv_primes_inverse() are inverses. '''
     up0, vp0 = colormodels.uv_primes (xyz0)
     xyz1 = colormodels.uv_primes_inverse (up0, vp0, xyz0[1])
     # Check error.
     dxyz = (xyz1 - xyz0)
     error = math.sqrt (numpy.dot (dxyz, dxyz))
     tolerance = 1.0e-13
     self.assertLessEqual(error, tolerance)
     msg = 'xyz0: %s    up: %g    vp: %g    xyz(up,vp): %s    Error: %g' % (
         str (xyz0), up0, vp0, str(xyz1), error)
     if verbose:
         print (msg)
 def check_uv_primes_inverse_2(self, up0, vp0, y0, verbose):
     ''' Check that uv_primes() and uv_primes_inverse() are inverses. '''
     xyz0 = colormodels.uv_primes_inverse (up0, vp0, y0)
     up1, vp1 = colormodels.uv_primes (xyz0)
     # Check error.
     error_up = up1 - up0
     error_vp = vp1 - vp0
     error = numpy.hypot (error_up, error_vp)
     tolerance = 1.0e-13
     self.assertLessEqual(error, tolerance)
     msg = 'up0, vp0, y0: %g, %g, %g    xyz(up0,vp0,y0): %s    (up,vp)(xyz): %g, %g    Error: %g' % (
         up0, vp0, y0, str (xyz0), up1, vp1, error)
     if verbose:
         print (msg)
Beispiel #4
0
 def check_uv_primes_inverse_2(self, up0, vp0, y0, verbose):
     ''' Check that uv_primes() and uv_primes_inverse() are inverses. '''
     xyz0 = colormodels.uv_primes_inverse(up0, vp0, y0)
     up1, vp1 = colormodels.uv_primes(xyz0)
     # Check error.
     error_up = up1 - up0
     error_vp = vp1 - vp0
     error = numpy.hypot(error_up, error_vp)
     tolerance = 1.0e-13
     self.assertLessEqual(error, tolerance)
     msg = 'up0, vp0, y0: %g, %g, %g    xyz(up0,vp0,y0): %s    (up,vp)(xyz): %g, %g    Error: %g' % (
         up0, vp0, y0, str(xyz0), up1, vp1, error)
     if verbose:
         print(msg)
Beispiel #5
0
 def test_A(xyz0, tolerance=0.0, verbose=1):
     (up0, vp0) = colormodels.uv_primes(xyz0)
     xyz1 = colormodels.uv_primes_inverse(up0, vp0, xyz0[1])
     # check error
     dxyz = (xyz1 - xyz0)
     error = math.sqrt(numpy.dot(dxyz, dxyz))
     passed = (error <= tolerance)
     if passed:
         status = 'pass'
     else:
         status = 'FAILED'
     msg = 'test_uv_primes.test_A() : xyz0 = %s, (up,vp) = (%g,%g), xyz(up,vp) = %s, error = %g, %s' % (
         str(xyz0), up0, vp0, str(xyz1), error, status)
     if verbose >= 1:
         print(msg)
     if not passed:
         pass
         raise ValueError(msg)
     return passed
Beispiel #6
0
 def test_A (xyz0, tolerance=0.0, verbose=1):
     (up0, vp0) = colormodels.uv_primes (xyz0)
     xyz1 = colormodels.uv_primes_inverse (up0, vp0, xyz0[1])
     # check error
     dxyz = (xyz1 - xyz0)
     error = math.sqrt (numpy.dot (dxyz, dxyz))
     passed = (error <= tolerance)
     if passed:
         status = 'pass'
     else:
         status = 'FAILED'
     msg = 'test_uv_primes.test_A() : xyz0 = %s, (up,vp) = (%g,%g), xyz(up,vp) = %s, error = %g, %s' % (
         str (xyz0), up0, vp0, str(xyz1), error, status)
     if verbose >= 1:
         print msg
     if not passed:
         pass
         raise ValueError, msg
     return passed
Beispiel #7
0
 def test_B(up0, vp0, y0, tolerance=0.0, verbose=1):
     xyz0 = colormodels.uv_primes_inverse(up0, vp0, y0)
     (up1, vp1) = colormodels.uv_primes(xyz0)
     # check error
     error_up = up1 - up0
     error_vp = vp1 - vp0
     error = numpy.hypot(error_up, error_vp)
     passed = (error <= tolerance)
     if passed:
         status = 'pass'
     else:
         status = 'FAILED'
     msg = 'test_uv_primes.test_B() : (up0,vp0,y0) = (%g,%g,%g), xyz (up0,vp0,y0) = %s, (up,vp)(xyz) = (%g,%g), error = %g, %s' % (
         up0, vp0, y0, str(xyz0), up1, vp1, error, status)
     if verbose >= 1:
         print(msg)
     if not passed:
         pass
         raise ValueError(msg)
     return passed
Beispiel #8
0
 def test_B (up0, vp0, y0, tolerance=0.0, verbose=1):
     xyz0 = colormodels.uv_primes_inverse (up0, vp0, y0)
     (up1, vp1) = colormodels.uv_primes (xyz0)
     # check error
     error_up = up1 - up0
     error_vp = vp1 - vp0
     error = numpy.hypot (error_up, error_vp)
     passed = (error <= tolerance)
     if passed:
         status = 'pass'
     else:
         status = 'FAILED'
     msg = 'test_uv_primes.test_B() : (up0,vp0,y0) = (%g,%g,%g), xyz (up0,vp0,y0) = %s, (up,vp)(xyz) = (%g,%g), error = %g, %s' % (
         up0, vp0, y0, str (xyz0), up1, vp1, error, status)
     if verbose >= 1:
         print msg
     if not passed:
         pass
         raise ValueError, msg
     return passed