def test_append(self, integer):
     la = LayeredArray()
     assert len(la.data) == 0
     assert len(la.start_indices) == 1
     la.append(integer)
     assert len(la.data) == 1
     assert len(la.start_indices) == 1
 def test_close_layer(self):
     la = LayeredArray()
     assert len(la.data) == 0
     assert len(la.start_indices) == 1
     la.close_layer()
     assert len(la.data) == 0
     assert len(la.start_indices) == 2
Beispiel #3
0
    def test_print_layer_expansion_info(self):
        cube = Cube(N=3)

        unique_cubes = LayeredArray()
        mutation_node = MutationNode(None, None, None)
        unique_cubes.append(MutatedCube(cube, mutation_node))
        unique_cubes.close_layer()

        dup_mut_seqs = LayeredArray()
        dup_mut_seqs.close_layer()

        _print_layer_expansion_info(True, 0, unique_cubes, dup_mut_seqs)
        _print_layer_expansion_info(False, 0, unique_cubes, dup_mut_seqs)
 def test_get_layer(self, a, b):
     la = LayeredArray()
     la.close_layer()
     la.append(a)
     la.append(b)
     la.close_layer()
     assert len(la.data) == 2
     assert len(la.start_indices) == 3
     assert la.get_layer(0) == []
     assert la.get_layer(1) == [a, b]
Beispiel #5
0
    def test_is_duplicate(self):
        mut_seq = [
            CubeMutation(AxisEnum.X, RotationEnum.CW, 0),
            CubeMutation(AxisEnum.Y, RotationEnum.HT, 1),
        ]

        dup_mut_seq = LayeredArray()
        dup_mut_seq.append([CubeMutation.e])

        assert not _is_duplicate(mut_seq, dup_mut_seq)

        dup_mut_seq.close_layer()
        dup_mut_seq.append(mut_seq)
        dup_mut_seq.close_layer()

        assert _is_duplicate(mut_seq, dup_mut_seq)
Beispiel #6
0
    def test_is_essentially_unique(self):
        cube = Cube(N=3)

        unique_cubes = LayeredArray()
        unique_cubes.append(MutatedCube(cube, None))
        unique_cubes.close_layer()

        assert not _is_essentially_unique(cube, 1, unique_cubes)

        mutation = CubeMutation(AxisEnum.X, RotationEnum.CW, 0)
        mutated_cube = deepcopy(cube)
        mutated_cube.mutate(mutation)

        assert _is_essentially_unique(mutated_cube, 1, unique_cubes)

        unique_cubes.append(MutatedCube(mutated_cube, mutation))

        assert not _is_essentially_unique(mutated_cube, 1, unique_cubes)

        mutated_cube_2 = deepcopy(mutated_cube)
        mutated_cube_2.mutate(CubeMutation(AxisEnum.Z, RotationEnum.HT, -1))

        assert not _is_essentially_unique(mutated_cube_2, 1, unique_cubes)
 def test_get_layer_slice_fail(self):
     la = LayeredArray()
     with raises(IndexError):
         la.get_layer_slice(0)
 def test_get_layer_slice(self):
     la = LayeredArray()
     la.close_layer()
     layer_slice = la.get_layer_slice(0)
     assert layer_slice.start == 0
     assert layer_slice.stop == 0
 def test_construction(self):
     LayeredArray()
Beispiel #10
0
    def test_expand_layer(self):
        cube = Cube(N=2)
        mutation_basis = cube.get_nonisomorphic_mutations()

        unique_cubes = LayeredArray()
        mutation_node = MutationNode(None, None, None)
        unique_cubes.append(MutatedCube(cube, mutation_node))
        unique_cubes.close_layer()

        dup_mut_seqs = LayeredArray()
        dup_mut_seqs.close_layer()

        _expand_layer(1, mutation_basis, unique_cubes, dup_mut_seqs)

        assert unique_cubes.get_layer_size(1) == 9
        assert dup_mut_seqs.get_layer_size(1) == 9