def test_algorithms(self):
        expl_algo = ExplicitPermutationsAlgorithm(permutations=[[0, 1, 2], [1, 2, 3]])
        expl_algo2 = ExplicitPermutationsAlgorithm.from_dict(expl_algo.as_dict)
        self.assertEqual(expl_algo.permutations, expl_algo2.permutations)

        sepplane_algos_oct = allcg["O:6"].algorithms
        self.assertEqual(len(sepplane_algos_oct[0].safe_separation_permutations()), 24)
        self.assertEqual(len(sepplane_algos_oct[1].safe_separation_permutations()), 36)

        sepplane_algos_oct_0 = SeparationPlane.from_dict(sepplane_algos_oct[0].as_dict)
        self.assertEqual(sepplane_algos_oct[0].plane_points, sepplane_algos_oct_0.plane_points)
        self.assertEqual(sepplane_algos_oct[0].mirror_plane, sepplane_algos_oct_0.mirror_plane)
        self.assertEqual(sepplane_algos_oct[0].ordered_plane, sepplane_algos_oct_0.ordered_plane)
        self.assertEqual(sepplane_algos_oct[0].point_groups, sepplane_algos_oct_0.point_groups)
        self.assertEqual(
            sepplane_algos_oct[0].ordered_point_groups,
            sepplane_algos_oct_0.ordered_point_groups,
        )
        self.assertTrue(
            all(
                [
                    np.array_equal(
                        perm,
                        sepplane_algos_oct_0.explicit_optimized_permutations[iperm],
                    )
                    for iperm, perm in enumerate(sepplane_algos_oct[0].explicit_optimized_permutations)
                ]
            )
        )

        self.assertEqual(
            sepplane_algos_oct[0].__str__(),
            "Separation plane algorithm with the following reference separation :\n[[4]] | [[0, 2, 1, 3]] | [[5]]",
        )
Example #2
0
    def test_algorithms(self):
        expl_algo = ExplicitPermutationsAlgorithm(
            permutations=[[0, 1, 2], [1, 2, 3]])
        expl_algo2 = ExplicitPermutationsAlgorithm.from_dict(expl_algo.as_dict)
        self.assertEqual(expl_algo.permutations, expl_algo2.permutations)

        sepplane_algos_oct = allcg['O:6'].algorithms
        self.assertEqual(
            len(sepplane_algos_oct[0].safe_separation_permutations()), 24)
        self.assertEqual(
            len(sepplane_algos_oct[1].safe_separation_permutations()), 36)

        sepplane_algos_oct_0 = SeparationPlane.from_dict(
            sepplane_algos_oct[0].as_dict)
        self.assertEqual(sepplane_algos_oct[0].plane_points,
                         sepplane_algos_oct_0.plane_points)
        self.assertEqual(sepplane_algos_oct[0].mirror_plane,
                         sepplane_algos_oct_0.mirror_plane)
        self.assertEqual(sepplane_algos_oct[0].ordered_plane,
                         sepplane_algos_oct_0.ordered_plane)
        self.assertEqual(sepplane_algos_oct[0].point_groups,
                         sepplane_algos_oct_0.point_groups)
        self.assertEqual(sepplane_algos_oct[0].ordered_point_groups,
                         sepplane_algos_oct_0.ordered_point_groups)
        self.assertEqual(sepplane_algos_oct[0].explicit_optimized_permutations,
                         sepplane_algos_oct_0.explicit_optimized_permutations)

        self.assertEqual(
            sepplane_algos_oct[0].__str__(),
            'Separation plane algorithm with the following reference separation :\n'
            '[[4]] | [[0, 2, 1, 3]] | [[5]]')
    def test_algorithms(self):
        expl_algo = ExplicitPermutationsAlgorithm(permutations=[[0, 1, 2], [1, 2, 3]])
        expl_algo2 = ExplicitPermutationsAlgorithm.from_dict(expl_algo.as_dict)
        self.assertEqual(expl_algo.permutations, expl_algo2.permutations)

        sepplane_algos_oct = allcg['O:6'].algorithms
        self.assertEqual(len(sepplane_algos_oct[0].safe_separation_permutations()), 24)
        self.assertEqual(len(sepplane_algos_oct[1].safe_separation_permutations()), 36)

        sepplane_algos_oct_0 = SeparationPlane.from_dict(sepplane_algos_oct[0].as_dict)
        self.assertEqual(sepplane_algos_oct[0].plane_points, sepplane_algos_oct_0.plane_points)
        self.assertEqual(sepplane_algos_oct[0].mirror_plane, sepplane_algos_oct_0.mirror_plane)
        self.assertEqual(sepplane_algos_oct[0].ordered_plane, sepplane_algos_oct_0.ordered_plane)
        self.assertEqual(sepplane_algos_oct[0].point_groups, sepplane_algos_oct_0.point_groups)
        self.assertEqual(sepplane_algos_oct[0].ordered_point_groups, sepplane_algos_oct_0.ordered_point_groups)
        self.assertEqual(sepplane_algos_oct[0].explicit_optimized_permutations,
                         sepplane_algos_oct_0.explicit_optimized_permutations)

        self.assertEqual(sepplane_algos_oct[0].__str__(),
                         'Separation plane algorithm with the following reference separation :\n'
                         '[[4]] | [[0, 2, 1, 3]] | [[5]]')
Example #4
0
            if np.isclose(csm, csm2):
                found = True
                break
        if not found:
            csms_with_recorded_permutation.append(csm)
            explicit_permutations.append(perms[icsm])

    print('Permutations found : ')
    print(explicit_permutations)

    print('Current algorithm(s) :')
    for algo in cg.algorithms:
        print(algo)
        if algo.algorithm_type == 'EXPLICIT_PERMUTATIONS':
            print(algo.permutations)
        else:
            raise ValueError('WRONG ALGORITHM !')

    test = raw_input('Save it ? ("y" to confirm)')
    if test == 'y':
        if len(cg.algorithms) != 1:
            raise ValueError('Multiple algorithms !')
        cg._algorithms = [
            ExplicitPermutationsAlgorithm(permutations=explicit_permutations)
        ]
        newgeom_dir = 'new_geometry_files'
        if not os.path.exists(newgeom_dir):
            os.makedirs(newgeom_dir)
        f = open('{}/{}.json'.format(newgeom_dir, cg_symbol), 'w')
        json.dump(cg.as_dict(), f)
        f.close()
Example #5
0
        for csm2 in csms_with_recorded_permutation:
            if np.isclose(csm, csm2):
                found = True
                break
        if not found:
            csms_with_recorded_permutation.append(csm)
            explicit_permutations.append(perms[icsm])

    print("Permutations found : ")
    print(explicit_permutations)

    print("Current algorithm(s) :")
    for algo in cg.algorithms:
        print(algo)
        if algo.algorithm_type == "EXPLICIT_PERMUTATIONS":
            print(algo.permutations)
        else:
            raise ValueError("WRONG ALGORITHM !")

    test = input('Save it ? ("y" to confirm)')
    if test == "y":
        if len(cg.algorithms) != 1:
            raise ValueError("Multiple algorithms !")
        cg._algorithms = [ExplicitPermutationsAlgorithm(permutations=explicit_permutations)]
        newgeom_dir = "new_geometry_files"
        if not os.path.exists(newgeom_dir):
            os.makedirs(newgeom_dir)
        f = open(f"{newgeom_dir}/{cg_symbol}.json", "w")
        json.dump(cg.as_dict(), f)
        f.close()