How to use the permuta.MeshPattern function in permuta

To help you get started, we’ve selected a few permuta examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PermutaTriangle / Permuta / oldtests / test_mesh_pattern.py View on Github external
def test_list_perm(self):
        # TODO: What is this?
        self.assertTrue(Permutation([1,2,3,4,5]).contains(MeshPattern([1,2,3], set([(0,0)]))))
        self.assertEqual(set([(0,1),(0,2),(1,0),(1,1),(1,2),(2,0),(2,1)]), MeshPattern([2,1], set([])).non_pointless_boxes())
github PermutaTriangle / Permuta / oldtests / test_mesh_pattern.py View on Github external
def test_len(self):
        self.assertEqual(len(self.mesh1), 5)
        self.assertEqual(len(self.mesh2), 5)
        self.assertEqual(len(self.mesh3), 4)
        self.assertEqual(len(MeshPattern()), 0)
        self.assertEqual(len(MeshPattern((1,))), 1)
github PermutaTriangle / Permuta / oldtests / test_mesh_pattern.py View on Github external
shading = set([(1,0),(2,1),(2,2)])
        mesh_pattern = MeshPattern(pattern, shading)
        sub_mesh_pattern = self.mesh1.sub_mesh_pattern((1,2,3))
        self.assertEqual(sub_mesh_pattern, mesh_pattern)
        # Sub mesh pattern from indices 0, 1, and 4 of mesh1
        pattern = (1,2,3)
        shading = set([(0,0),(1,0),(3,0),(3,1)])
        mesh_pattern = MeshPattern(pattern, shading)
        sub_mesh_pattern = self.mesh1.sub_mesh_pattern((0,1,4))
        self.assertEqual(sub_mesh_pattern, mesh_pattern)
        # Sub mesh pattern from indices 3 and 4 of mesh1
        self.assertEqual(self.mesh1.sub_mesh_pattern((3,4)), MeshPattern((1,2)))
        # Sub mesh pattern from indices 2 and 3 of mesh1
        self.assertEqual(self.mesh1.sub_mesh_pattern((2,3)), MeshPattern((1,2), set([(1,1)])))
        # Sub mesh pattern from index 0 of mesh3
        self.assertEqual(self.mesh3.sub_mesh_pattern((0,)), MeshPattern((1,)))
        # Sub mesh pattern from indices 0, 1, and 3 of mesh3
        self.assertEqual(self.mesh3.sub_mesh_pattern((0,1,3)), MeshPattern((2,3,1), set([(0,3),(1,2),(3,3)])))
        # Some complete sub meshes
        self.assertEqual(self.mesh1.sub_mesh_pattern(range(len(self.mesh1))), self.mesh1)
        self.assertEqual(self.mesh2.sub_mesh_pattern(range(len(self.mesh2))), self.mesh2)
        self.assertEqual(self.mesh3.sub_mesh_pattern(range(len(self.mesh3))), self.mesh3)
github PermutaTriangle / Permuta / oldtests / test_mesh_pattern.py View on Github external
# Sub mesh pattern from indices 1, 2, and 3 of mesh1
        pattern = (1,2,3)
        shading = set([(1,0),(2,1),(2,2)])
        mesh_pattern = MeshPattern(pattern, shading)
        sub_mesh_pattern = self.mesh1.sub_mesh_pattern((1,2,3))
        self.assertEqual(sub_mesh_pattern, mesh_pattern)
        # Sub mesh pattern from indices 0, 1, and 4 of mesh1
        pattern = (1,2,3)
        shading = set([(0,0),(1,0),(3,0),(3,1)])
        mesh_pattern = MeshPattern(pattern, shading)
        sub_mesh_pattern = self.mesh1.sub_mesh_pattern((0,1,4))
        self.assertEqual(sub_mesh_pattern, mesh_pattern)
        # Sub mesh pattern from indices 3 and 4 of mesh1
        self.assertEqual(self.mesh1.sub_mesh_pattern((3,4)), MeshPattern((1,2)))
        # Sub mesh pattern from indices 2 and 3 of mesh1
        self.assertEqual(self.mesh1.sub_mesh_pattern((2,3)), MeshPattern((1,2), set([(1,1)])))
        # Sub mesh pattern from index 0 of mesh3
        self.assertEqual(self.mesh3.sub_mesh_pattern((0,)), MeshPattern((1,)))
        # Sub mesh pattern from indices 0, 1, and 3 of mesh3
        self.assertEqual(self.mesh3.sub_mesh_pattern((0,1,3)), MeshPattern((2,3,1), set([(0,3),(1,2),(3,3)])))
        # Some complete sub meshes
        self.assertEqual(self.mesh1.sub_mesh_pattern(range(len(self.mesh1))), self.mesh1)
        self.assertEqual(self.mesh2.sub_mesh_pattern(range(len(self.mesh2))), self.mesh2)
        self.assertEqual(self.mesh3.sub_mesh_pattern(range(len(self.mesh3))), self.mesh3)
github PermutaTriangle / Permuta / oldtests / test_mesh_pattern.py View on Github external
def test_eq(self):
        self.assertNotEqual(self.mesh1, self.mesh2)
        self.assertNotEqual(self.mesh1, self.mesh3)
        self.assertNotEqual(self.mesh2, self.mesh1)
        self.assertNotEqual(self.mesh2, self.mesh3)
        self.assertNotEqual(self.mesh3, self.mesh1)
        self.assertNotEqual(self.mesh3, self.mesh2)
        mesh1copy = MeshPattern(self.patt1, self.shad1)
        mesh2copy = MeshPattern(self.patt2, self.shad2)
        mesh3copy = MeshPattern(self.patt3, self.shad3)
        self.assertEqual(self.mesh1, mesh1copy)
        self.assertEqual(self.mesh2, mesh2copy)
        self.assertEqual(self.mesh3, mesh3copy)
        self.assertEqual(mesh1copy, mesh1copy)
        self.assertEqual(mesh2copy, mesh2copy)
        self.assertEqual(mesh3copy, mesh3copy)
github PermutaTriangle / Permuta / oldtests / test_mesh_pattern.py View on Github external
def test_unrank(self):
        pattern = Permutation([1,2])
        shading = set([(0,1),
                       (0,2),
                       (1,2),
                       (2,0),
                       (2,1)])
        number = 230
        mesh = MeshPattern(pattern, shading)
        self.assertEqual(MeshPattern.unrank(pattern, number), mesh)
        pattern = Permutation([3,1,2])
        shading = set([(0,0),
                       (0,1),
                       (0,2),
                       (1,0),
                       (1,2),
                       (2,0),
                       (2,1),
                       (2,2),
                       (2,3),
                       (3,0)])
        number = 8023
        mesh = MeshPattern(pattern, shading)
        self.assertEqual(MeshPattern.unrank(pattern, number), mesh)
        with self.assertRaises(AssertionError):
            self.assertEqual(MeshPattern.unrank([1,2,3], -1))
github PermutaTriangle / Permuta / oldtests / test_mesh_pattern.py View on Github external
def test_bool(self):
        self.assertTrue(self.mesh1)
        self.assertTrue(self.mesh2)
        self.assertTrue(self.mesh3)
        self.assertTrue(MeshPattern(Permutation((1,))))
        self.assertTrue(MeshPattern((), set([(0,0)])))
        self.assertFalse(MeshPattern())
github PermutaTriangle / Permuta / oldtests / test_mesh_pattern.py View on Github external
def test_bool(self):
        self.assertTrue(self.mesh1)
        self.assertTrue(self.mesh2)
        self.assertTrue(self.mesh3)
        self.assertTrue(MeshPattern(Permutation((1,))))
        self.assertTrue(MeshPattern((), set([(0,0)])))
        self.assertFalse(MeshPattern())
github PermutaTriangle / Permuta / oldtests / test_mesh_pattern.py View on Github external
def test_rotate(self):
        # Rotate once
        pattern = self.patt2.rotate()
        shading = set([(2,3),(3,2),(2,5),(1,4)])
        mesh = MeshPattern(pattern, shading)
        self.assertEqual(mesh, self.mesh2.rotate())
        # Rotate twice
        pattern = self.patt2.rotate(2)
        shading = set([(2,2),(3,3),(4,4),(5,3)])
        mesh = MeshPattern(pattern, shading)
        self.assertEqual(mesh, self.mesh2.rotate(2))
        # Rotate thrice
        pattern = self.patt2.rotate(3)
        shading = set([(2,3),(3,2),(4,1),(3,0)])
        mesh = MeshPattern(pattern, shading)
        self.assertEqual(mesh, self.mesh2.rotate(3))
github PermutaTriangle / Permuta / oldtests / test_mesh_pattern.py View on Github external
def test_eq(self):
        self.assertNotEqual(self.mesh1, self.mesh2)
        self.assertNotEqual(self.mesh1, self.mesh3)
        self.assertNotEqual(self.mesh2, self.mesh1)
        self.assertNotEqual(self.mesh2, self.mesh3)
        self.assertNotEqual(self.mesh3, self.mesh1)
        self.assertNotEqual(self.mesh3, self.mesh2)
        mesh1copy = MeshPattern(self.patt1, self.shad1)
        mesh2copy = MeshPattern(self.patt2, self.shad2)
        mesh3copy = MeshPattern(self.patt3, self.shad3)
        self.assertEqual(self.mesh1, mesh1copy)
        self.assertEqual(self.mesh2, mesh2copy)
        self.assertEqual(self.mesh3, mesh3copy)
        self.assertEqual(mesh1copy, mesh1copy)
        self.assertEqual(mesh2copy, mesh2copy)
        self.assertEqual(mesh3copy, mesh3copy)