Exemplo n.º 1
0
	def test_forward_inverse(self):
		trials = 100000
		for i in range(trials):
			x = random.random()
			y = srgbtransform.srgb_to_linear(x)
			z = srgbtransform.linear_to_srgb(x)
			self.assertAlmostEqual(x, srgbtransform.linear_to_srgb(y), delta=DELTA)
			self.assertAlmostEqual(x, srgbtransform.srgb_to_linear(z), delta=DELTA)
	def test_forward_inverse(self):
		trials = 100000
		for i in range(trials):
			x = random.random()
			y = srgbtransform.srgb_to_linear(x)
			z = srgbtransform.linear_to_srgb(x)
			self.assertAlmostEqual(x, srgbtransform.linear_to_srgb(y), delta=SrgbTransformTest._DELTA)
			self.assertAlmostEqual(x, srgbtransform.srgb_to_linear(z), delta=SrgbTransformTest._DELTA)
Exemplo n.º 3
0
	def test_monotonicity(self):
		trials = 100000
		for i in range(trials):
			x = random.random() * 2 - 0.5
			y = random.random() * 2 - 0.5
			if y < x:
				x, y = y, x
			if y - x > DELTA:
				self.assertTrue(srgbtransform.srgb_to_linear(x) <= srgbtransform.srgb_to_linear(y))
				self.assertTrue(srgbtransform.linear_to_srgb(x) <= srgbtransform.linear_to_srgb(y))
				self.assertTrue(srgbtransform.linear_to_srgb_8bit(x) <= srgbtransform.linear_to_srgb_8bit(y))
	def test_monotonicity(self):
		trials = 100000
		for i in range(trials):
			x = random.random() * 2 - 0.5
			y = random.random() * 2 - 0.5
			if y < x:
				x, y = y, x
			if y - x > SrgbTransformTest._DELTA:
				self.assertTrue(srgbtransform.srgb_to_linear(x) <= srgbtransform.srgb_to_linear(y))
				self.assertTrue(srgbtransform.linear_to_srgb(x) <= srgbtransform.linear_to_srgb(y))
				self.assertTrue(srgbtransform.linear_to_srgb_8bit(x) <= srgbtransform.linear_to_srgb_8bit(y))
 def test_8bit(self):
     for i in range(256):
         self.assertTrue(
             srgbtransform.linear_to_srgb_8bit(
                 srgbtransform.srgb_8bit_to_linear(i)) == i)
         self.assertTrue(
             abs(
                 srgbtransform.linear_to_srgb(
                     srgbtransform.srgb_8bit_to_linear(i)) * 255 - i) < 1)
	def test_8bit(self):
		for i in range(256):
			self.assertTrue(srgbtransform.linear_to_srgb_8bit(srgbtransform.srgb_8bit_to_linear(i)) == i);
			self.assertTrue(abs(srgbtransform.linear_to_srgb(srgbtransform.srgb_8bit_to_linear(i)) * 255 - i) < 1);