コード例 #1
0
ファイル: colors.py プロジェクト: JoseCarlosGarcia95/Wolfie
def xyz_to_lab(x, y, z, *rest):
    # see http://www.brucelindbloom.com/Eqn_XYZ_to_Lab.html
    xyz = array([u / v for u, v in zip([x, y, z], _ref_white.xyz)])
    x, y, z = map(_scale_xyz_to_lab, xyz)

    # MMA scales by 1/100
    return ((1.16 * y) - 0.16, 5. * (x - y), 2. * (y - z)) + rest
コード例 #2
0
ファイル: colors.py プロジェクト: Piruzzolo/Mathics
def xyz_to_lab(x, y, z, *rest):
    # see http://www.brucelindbloom.com/Eqn_XYZ_to_Lab.html
    xyz = array([u / v for u, v in zip([x, y, z], _ref_white.xyz)])
    x, y, z = map(_scale_xyz_to_lab, xyz)

    # MMA scales by 1/100
    return ((1.16 * y) - 0.16, 5. * (x - y), 2. * (y - z)) + rest
コード例 #3
0
ファイル: test_color.py プロジェクト: Piruzzolo/Mathics
    def _checkImageConversion(self, size, convert):
        pixels = [[random(), random(), random()] for _ in range(size * size)]
        refs = [convert(p) for p in pixels]

        image = [[pixels[x * size + y] for y in range(size)] for x in range(size)]
        image = convert(array(image))

        for x in range(size):
            for y in range(size):
                p1 = image[x][y]
                p2 = refs[x * size + y]
                self.assertEqual(len(p1), len(p2))
                for a, b in zip(p1, p2):
                    self.assertAlmostEqual(a, b, 12)
コード例 #4
0
ファイル: test_color.py プロジェクト: weakit/Mathics
    def _checkImageConversion(self, size, convert):
        pixels = [[random(), random(), random()] for _ in range(size * size)]
        refs = [convert(p) for p in pixels]

        image = [[pixels[x * size + y] for y in range(size)] for x in range(size)]
        image = convert(array(image))

        for x in range(size):
            for y in range(size):
                p1 = image[x][y]
                p2 = refs[x * size + y]
                self.assertEqual(len(p1), len(p2))
                for a, b in zip(p1, p2):
                    self.assertAlmostEqual(a, b, 12)
コード例 #5
0
 def testConditionalComplex(self):
     a = array([[[1, 2], [4, 5]], [[7, 8], [10, 11]]])
     a = vectorize(a, 0, _test_complex_conditional)
     self.assertEqualArrays(a,
                            [[[-1, -1], [40, 50]], [[70, 80], [100, 111]]])
コード例 #6
0
 def testSimpleConditional(self):
     a = array([[[0.1, 0.6], [1.8, 0.4]], [[-0.1, -0.8], [1.1, 0.5]]])
     a = vectorize(a, 0, _test_simple_conditional)
     self.assertEqualArrays(
         a, [[[-0.1, 1.6], [2.8, -0.4]], [[0.1, 0.8], [2.1, -0.5]]])
コード例 #7
0
 def testMod(self):
     self.assertEqualArrays(
         mod(array([[10, 20], [30, 40]]), [[7, 7], [7, 7]]),
         [[3, 6], [2, 5]])
コード例 #8
0
 def testClip(self):
     a = array([[[-0.1, 0.6], [-1.8, -0.4]], [[0.1, 0.8], [1.1, 0.5]]])
     a = clip(a, 0, 1)
     self.assertEqualArrays(
         a, [[[0., 0.6], [0., 0.]], [[0.1, 0.8], [1., 0.5]]])
コード例 #9
0
ファイル: test_numpy_utils.py プロジェクト: Piruzzolo/Mathics
 def testConditionalComplex(self):
     a = array([[[1, 2], [4, 5]], [[7, 8], [10, 11]]])
     a = vectorize(a, 0, _test_complex_conditional)
     self.assertEqualArrays(a, [[[-1, -1], [40, 50]], [[70, 80], [100, 111]]])
コード例 #10
0
ファイル: test_numpy_utils.py プロジェクト: Piruzzolo/Mathics
 def testSimpleConditional(self):
     a = array([[[0.1, 0.6], [1.8, 0.4]], [[-0.1, -0.8], [1.1, 0.5]]])
     a = vectorize(a, 0, _test_simple_conditional)
     self.assertEqualArrays(a, [[[-0.1, 1.6], [2.8, -0.4]], [[0.1, 0.8], [2.1, -0.5]]])
コード例 #11
0
ファイル: test_numpy_utils.py プロジェクト: Piruzzolo/Mathics
 def testMod(self):
     self.assertEqualArrays(mod(array([[10, 20], [30, 40]]), [[7, 7], [7, 7]]), [[3, 6], [2, 5]])
コード例 #12
0
ファイル: test_numpy_utils.py プロジェクト: Piruzzolo/Mathics
 def testClip(self):
     a = array([[[-0.1, 0.6], [-1.8, -0.4]], [[0.1, 0.8], [1.1, 0.5]]])
     a = clip(a, 0, 1)
     self.assertEqualArrays(a, [[[0., 0.6], [0., 0.]], [[0.1, 0.8], [1., 0.5]]])