Beispiel #1
0
    def test_CN_bias_weight(self):
        fake_nb_set = FakeNbSet()
        dummy_se = DummyStructureEnvironments()
        bias_weight1 = CNBiasNbSetWeight.linearly_equidistant(weight_cn1=1.0, weight_cn13=13.0)
        bias_weight2 = CNBiasNbSetWeight.geometrically_equidistant(weight_cn1=1.0, weight_cn13=1.1**12)
        bias_weight3 = CNBiasNbSetWeight.explicit(cn_weights={1: 1.0, 2: 3.0, 3: 3.2, 4: 4.0,
                                                              5: 4.1, 6: 4.2, 7: 4.3, 8: 4.4,
                                                              9: 4.5, 10: 4.6, 11: 4.6, 12: 4.7,
                                                              13: 4.8})
        with self.assertRaisesRegexp(ValueError, 'Weights should be provided for CN 1 to 13'):
            CNBiasNbSetWeight.explicit(cn_weights={1: 1.0, 13: 2.0})

        fake_nb_set.cn = 1
        w1 = bias_weight1.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w1, 1.0, delta=1e-8)
        w2 = bias_weight2.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w2, 1.0, delta=1e-8)
        w3 = bias_weight3.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w3, 1.0, delta=1e-8)
        fake_nb_set.cn = 7
        w1 = bias_weight1.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w1, 7.0, delta=1e-8)
        w2 = bias_weight2.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w2, 1.1**6, delta=1e-8)
        w3 = bias_weight3.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w3, 4.3, delta=1e-8)
        fake_nb_set.cn = 13
        w1 = bias_weight1.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w1, 13.0, delta=1e-8)
        w2 = bias_weight2.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w2, 1.1**12, delta=1e-8)
        w3 = bias_weight3.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w3, 4.8, delta=1e-8)
Beispiel #2
0
    def test_CN_bias_weight(self):
        fake_nb_set = FakeNbSet()
        dummy_se = DummyStructureEnvironments()
        bias_weight1 = CNBiasNbSetWeight.linearly_equidistant(weight_cn1=1.0, weight_cn13=13.0)
        bias_weight2 = CNBiasNbSetWeight.geometrically_equidistant(weight_cn1=1.0, weight_cn13=1.1**12)
        bias_weight3 = CNBiasNbSetWeight.explicit(cn_weights={1: 1.0, 2: 3.0, 3: 3.2, 4: 4.0,
                                                              5: 4.1, 6: 4.2, 7: 4.3, 8: 4.4,
                                                              9: 4.5, 10: 4.6, 11: 4.6, 12: 4.7,
                                                              13: 4.8})
        with self.assertRaisesRegexp(ValueError, 'Weights should be provided for CN 1 to 13'):
            CNBiasNbSetWeight.explicit(cn_weights={1: 1.0, 13: 2.0})

        fake_nb_set.cn = 1
        w1 = bias_weight1.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w1, 1.0, delta=1e-8)
        w2 = bias_weight2.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w2, 1.0, delta=1e-8)
        w3 = bias_weight3.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w3, 1.0, delta=1e-8)
        fake_nb_set.cn = 7
        w1 = bias_weight1.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w1, 7.0, delta=1e-8)
        w2 = bias_weight2.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w2, 1.1**6, delta=1e-8)
        w3 = bias_weight3.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w3, 4.3, delta=1e-8)
        fake_nb_set.cn = 13
        w1 = bias_weight1.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w1, 13.0, delta=1e-8)
        w2 = bias_weight2.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w2, 1.1**12, delta=1e-8)
        w3 = bias_weight3.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w3, 4.8, delta=1e-8)
Beispiel #3
0
    def test_CN_bias_weight(self):
        fake_nb_set = FakeNbSet()
        dummy_se = DummyStructureEnvironments()
        bias_weight1 = CNBiasNbSetWeight.linearly_equidistant(weight_cn1=1.0, weight_cn13=13.0)
        bias_weight2 = CNBiasNbSetWeight.geometrically_equidistant(weight_cn1=1.0, weight_cn13=1.1 ** 12)
        bias_weight3 = CNBiasNbSetWeight.explicit(cn_weights={1: 1.0, 2: 3.0, 3: 3.2, 4: 4.0,
                                                              5: 4.1, 6: 4.2, 7: 4.3, 8: 4.4,
                                                              9: 4.5, 10: 4.6, 11: 4.6, 12: 4.7,
                                                              13: 4.8})
        with self.assertRaisesRegex(ValueError, 'Weights should be provided for CN 1 to 13'):
            CNBiasNbSetWeight.explicit(cn_weights={1: 1.0, 13: 2.0})

        fake_nb_set.cn = 1
        w1 = bias_weight1.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w1, 1.0, delta=1e-8)
        w2 = bias_weight2.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w2, 1.0, delta=1e-8)
        w3 = bias_weight3.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w3, 1.0, delta=1e-8)
        fake_nb_set.cn = 7
        w1 = bias_weight1.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w1, 7.0, delta=1e-8)
        w2 = bias_weight2.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w2, 1.1 ** 6, delta=1e-8)
        w3 = bias_weight3.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w3, 4.3, delta=1e-8)
        fake_nb_set.cn = 13
        w1 = bias_weight1.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w1, 13.0, delta=1e-8)
        w2 = bias_weight2.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w2, 1.1 ** 12, delta=1e-8)
        w3 = bias_weight3.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w3, 4.8, delta=1e-8)

        bias_weight4 = CNBiasNbSetWeight.from_description({'type': 'linearly_equidistant',
                                                           'weight_cn1': 2.0,
                                                           'weight_cn13': 26.0})
        for cn in range(1, 14):
            self.assertAlmostEqual(bias_weight4.cn_weights[cn], 2.0 * cn)

        bias_weight5 = CNBiasNbSetWeight.from_description({'type': 'geometrically_equidistant',
                                                           'weight_cn1': 1.0,
                                                           'weight_cn13': 13.0})
        self.assertAlmostEqual(bias_weight5.cn_weights[1], 1.0)
        self.assertAlmostEqual(bias_weight5.cn_weights[3], 1.5334062370163877)
        self.assertAlmostEqual(bias_weight5.cn_weights[9], 5.5287748136788739)
        self.assertAlmostEqual(bias_weight5.cn_weights[12], 10.498197520079623)

        cn_weights = {cn: 0.0 for cn in range(1, 14)}
        cn_weights[6] = 2.0
        cn_weights[4] = 1.0
        bias_weight6 = CNBiasNbSetWeight.from_description({'type': 'explicit',
                                                           'cn_weights': cn_weights})

        self.assertAlmostEqual(bias_weight6.cn_weights[1], 0.0)
        self.assertAlmostEqual(bias_weight6.cn_weights[4], 1.0)
        self.assertAlmostEqual(bias_weight6.cn_weights[6], 2.0)
Beispiel #4
0
    def test_CN_bias_weight(self):
        fake_nb_set = FakeNbSet()
        dummy_se = DummyStructureEnvironments()
        bias_weight1 = CNBiasNbSetWeight.linearly_equidistant(weight_cn1=1.0, weight_cn13=13.0)
        bias_weight2 = CNBiasNbSetWeight.geometrically_equidistant(weight_cn1=1.0, weight_cn13=1.1**12)
        bias_weight3 = CNBiasNbSetWeight.explicit(cn_weights={1: 1.0, 2: 3.0, 3: 3.2, 4: 4.0,
                                                              5: 4.1, 6: 4.2, 7: 4.3, 8: 4.4,
                                                              9: 4.5, 10: 4.6, 11: 4.6, 12: 4.7,
                                                              13: 4.8})
        with self.assertRaisesRegex(ValueError, 'Weights should be provided for CN 1 to 13'):
            CNBiasNbSetWeight.explicit(cn_weights={1: 1.0, 13: 2.0})

        fake_nb_set.cn = 1
        w1 = bias_weight1.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w1, 1.0, delta=1e-8)
        w2 = bias_weight2.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w2, 1.0, delta=1e-8)
        w3 = bias_weight3.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w3, 1.0, delta=1e-8)
        fake_nb_set.cn = 7
        w1 = bias_weight1.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w1, 7.0, delta=1e-8)
        w2 = bias_weight2.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w2, 1.1**6, delta=1e-8)
        w3 = bias_weight3.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w3, 4.3, delta=1e-8)
        fake_nb_set.cn = 13
        w1 = bias_weight1.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w1, 13.0, delta=1e-8)
        w2 = bias_weight2.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w2, 1.1**12, delta=1e-8)
        w3 = bias_weight3.weight(nb_set=fake_nb_set, structure_environments=dummy_se)
        self.assertAlmostEqual(w3, 4.8, delta=1e-8)

        bias_weight4 = CNBiasNbSetWeight.from_description({'type': 'linearly_equidistant',
                                                           'weight_cn1': 2.0,
                                                           'weight_cn13': 26.0})
        for cn in range(1, 14):
            self.assertAlmostEqual(bias_weight4.cn_weights[cn], 2.0*cn)

        bias_weight5 = CNBiasNbSetWeight.from_description({'type': 'geometrically_equidistant',
                                                           'weight_cn1': 1.0,
                                                           'weight_cn13': 13.0})
        self.assertAlmostEqual(bias_weight5.cn_weights[1], 1.0)
        self.assertAlmostEqual(bias_weight5.cn_weights[3], 1.5334062370163877)
        self.assertAlmostEqual(bias_weight5.cn_weights[9], 5.5287748136788739)
        self.assertAlmostEqual(bias_weight5.cn_weights[12], 10.498197520079623)

        cn_weights = {cn: 0.0 for cn in range(1, 14)}
        cn_weights[6] = 2.0
        cn_weights[4] = 1.0
        bias_weight6 = CNBiasNbSetWeight.from_description({'type': 'explicit',
                                                           'cn_weights': cn_weights})

        self.assertAlmostEqual(bias_weight6.cn_weights[1], 0.0)
        self.assertAlmostEqual(bias_weight6.cn_weights[4], 1.0)
        self.assertAlmostEqual(bias_weight6.cn_weights[6], 2.0)
    def get_weights(self, weights_options):
        effective_csm_estimator = {"function": "power2_inverse_decreasing", "options": {"max_csm": 8.0}}

        self_weight_estimator = {
            "function": "power2_decreasing_exp",
            "options": {"max_csm": 5.4230949041608305, "alpha": 1.0},
        }

        self_csm_weight = SelfCSMNbSetWeight(
            effective_csm_estimator=effective_csm_estimator, weight_estimator=self_weight_estimator
        )

        surface_definition = {
            "type": "standard_elliptic",
            "distance_bounds": {"lower": 1.05, "upper": 2.0},
            "angle_bounds": {"lower": 0.05, "upper": 0.95},
        }

        da_area_weight = DistanceAngleAreaNbSetWeight(
            weight_type="has_intersection",
            surface_definition=surface_definition,
            nb_sets_from_hints="fallback_to_source",
            other_nb_sets="0_weight",
            additional_condition=DistanceAngleAreaNbSetWeight.AC.ONLY_ACB,
        )

        weight_estimator = {"function": "smootherstep", "options": {"delta_csm_min": 0.5, "delta_csm_max": 3.0}}

        symmetry_measure_type = "csm_wcs_ctwcc"
        delta_csm_weight = DeltaCSMNbSetWeight(
            effective_csm_estimator=effective_csm_estimator,
            weight_estimator=weight_estimator,
            symmetry_measure_type=symmetry_measure_type,
        )

        bias_weight = CNBiasNbSetWeight.linearly_equidistant(weight_cn1=1.0, weight_cn13=4.0)
        angle_weight = AngleNbSetWeight()

        nad_weight = NormalizedAngleDistanceNbSetWeight(average_type="geometric", aa=1, bb=1)

        weights = {
            "DistAngArea": da_area_weight,
            "SelfCSM": self_csm_weight,
            "DeltaCSM": delta_csm_weight,
            "CNBias": bias_weight,
            "Angle": angle_weight,
            "NormalizedAngDist": nad_weight,
        }

        return weights
    def get_weights(self, weights_options):
        effective_csm_estimator = {'function': 'power2_inverse_decreasing',
                                   'options': {'max_csm': 8.0}}

        self_weight_estimator = {'function': 'power2_decreasing_exp',
                                 'options': {'max_csm': 5.4230949041608305,
                                             'alpha': 1.0}}

        self_csm_weight = SelfCSMNbSetWeight(effective_csm_estimator=effective_csm_estimator,
                                             weight_estimator=self_weight_estimator)

        surface_definition = {'type': 'standard_elliptic',
                              'distance_bounds': {'lower': 1.05, 'upper': 2.0},
                              'angle_bounds': {'lower': 0.05, 'upper': 0.95}}

        da_area_weight = DistanceAngleAreaNbSetWeight(weight_type='has_intersection',
                                                      surface_definition=surface_definition,
                                                      nb_sets_from_hints='fallback_to_source',
                                                      other_nb_sets='0_weight',
                                                      additional_condition=DistanceAngleAreaNbSetWeight.AC.ONLY_ACB)

        weight_estimator = {'function': 'smootherstep',
                            'options': {'delta_csm_min': 0.5,
                                        'delta_csm_max': 3.0}}

        symmetry_measure_type = 'csm_wcs_ctwcc'
        delta_csm_weight = DeltaCSMNbSetWeight(effective_csm_estimator=effective_csm_estimator,
                                               weight_estimator=weight_estimator,
                                               symmetry_measure_type=symmetry_measure_type)

        bias_weight = CNBiasNbSetWeight.linearly_equidistant(weight_cn1=1.0, weight_cn13=4.0)
        angle_weight = AngleNbSetWeight()

        nad_weight = NormalizedAngleDistanceNbSetWeight(average_type='geometric', aa=1, bb=1)

        weights = {'DistAngArea': da_area_weight,
                   'SelfCSM': self_csm_weight,
                   'DeltaCSM': delta_csm_weight,
                   'CNBias': bias_weight,
                   'Angle': angle_weight,
                   'NormalizedAngDist': nad_weight}

        return weights
Beispiel #7
0
    def test_strategies(self):
        simplest_strategy_1 = SimplestChemenvStrategy()
        simplest_strategy_2 = SimplestChemenvStrategy(distance_cutoff=1.5,
                                                      angle_cutoff=0.5)
        self.assertFalse(simplest_strategy_1 == simplest_strategy_2)
        simplest_strategy_1_from_dict = SimplestChemenvStrategy.from_dict(
            simplest_strategy_1.as_dict())
        self.assertTrue(simplest_strategy_1, simplest_strategy_1_from_dict)

        effective_csm_estimator = {
            "function": "power2_inverse_decreasing",
            "options": {
                "max_csm": 8.0
            },
        }
        self_csm_weight = SelfCSMNbSetWeight()
        surface_definition = {
            "type": "standard_elliptic",
            "distance_bounds": {
                "lower": 1.1,
                "upper": 1.9
            },
            "angle_bounds": {
                "lower": 0.1,
                "upper": 0.9
            },
        }
        surface_definition_2 = {
            "type": "standard_elliptic",
            "distance_bounds": {
                "lower": 1.1,
                "upper": 1.9
            },
            "angle_bounds": {
                "lower": 0.1,
                "upper": 0.95
            },
        }
        da_area_weight = DistanceAngleAreaNbSetWeight(
            weight_type="has_intersection",
            surface_definition=surface_definition,
            nb_sets_from_hints="fallback_to_source",
            other_nb_sets="0_weight",
            additional_condition=DistanceAngleAreaNbSetWeight.AC.ONLY_ACB,
        )
        da_area_weight_2 = DistanceAngleAreaNbSetWeight(
            weight_type="has_intersection",
            surface_definition=surface_definition_2,
            nb_sets_from_hints="fallback_to_source",
            other_nb_sets="0_weight",
            additional_condition=DistanceAngleAreaNbSetWeight.AC.ONLY_ACB,
        )
        weight_estimator = {
            "function": "smootherstep",
            "options": {
                "delta_csm_min": 0.5,
                "delta_csm_max": 3.0
            },
        }
        symmetry_measure_type = "csm_wcs_ctwcc"
        delta_weight = DeltaCSMNbSetWeight(
            effective_csm_estimator=effective_csm_estimator,
            weight_estimator=weight_estimator,
            symmetry_measure_type=symmetry_measure_type,
        )
        bias_weight = CNBiasNbSetWeight.linearly_equidistant(weight_cn1=1.0,
                                                             weight_cn13=4.0)
        bias_weight_2 = CNBiasNbSetWeight.linearly_equidistant(weight_cn1=1.0,
                                                               weight_cn13=5.0)
        angle_weight = AngleNbSetWeight()
        nad_weight = NormalizedAngleDistanceNbSetWeight(
            average_type="geometric", aa=1, bb=1)
        multi_weights_strategy_1 = MultiWeightsChemenvStrategy(
            dist_ang_area_weight=da_area_weight,
            self_csm_weight=self_csm_weight,
            delta_csm_weight=delta_weight,
            cn_bias_weight=bias_weight,
            angle_weight=angle_weight,
            normalized_angle_distance_weight=nad_weight,
            symmetry_measure_type=symmetry_measure_type,
        )
        multi_weights_strategy_2 = MultiWeightsChemenvStrategy(
            dist_ang_area_weight=da_area_weight,
            self_csm_weight=self_csm_weight,
            delta_csm_weight=delta_weight,
            cn_bias_weight=bias_weight_2,
            angle_weight=angle_weight,
            normalized_angle_distance_weight=nad_weight,
            symmetry_measure_type=symmetry_measure_type,
        )
        multi_weights_strategy_3 = MultiWeightsChemenvStrategy(
            dist_ang_area_weight=da_area_weight_2,
            self_csm_weight=self_csm_weight,
            delta_csm_weight=delta_weight,
            cn_bias_weight=bias_weight,
            angle_weight=angle_weight,
            normalized_angle_distance_weight=nad_weight,
            symmetry_measure_type=symmetry_measure_type,
        )
        multi_weights_strategy_1_from_dict = MultiWeightsChemenvStrategy.from_dict(
            multi_weights_strategy_1.as_dict())

        self.assertTrue(
            multi_weights_strategy_1 == multi_weights_strategy_1_from_dict)
        self.assertFalse(simplest_strategy_1 == multi_weights_strategy_1)
        self.assertFalse(multi_weights_strategy_1 == multi_weights_strategy_2)
        self.assertFalse(multi_weights_strategy_1 == multi_weights_strategy_3)
        self.assertFalse(multi_weights_strategy_2 == multi_weights_strategy_3)
Beispiel #8
0
    def test_strategies(self):
        simplest_strategy_1 = SimplestChemenvStrategy()
        simplest_strategy_2 = SimplestChemenvStrategy(distance_cutoff=1.5, angle_cutoff=0.5)
        self.assertFalse(simplest_strategy_1 == simplest_strategy_2)
        simplest_strategy_1_from_dict = SimplestChemenvStrategy.from_dict(simplest_strategy_1.as_dict())
        self.assertTrue(simplest_strategy_1, simplest_strategy_1_from_dict)

        effective_csm_estimator = {'function': 'power2_inverse_decreasing',
                                   'options': {'max_csm': 8.0}}
        self_csm_weight = SelfCSMNbSetWeight()
        surface_definition = {'type': 'standard_elliptic',
                              'distance_bounds': {'lower': 1.1, 'upper': 1.9},
                              'angle_bounds': {'lower': 0.1, 'upper': 0.9}}
        surface_definition_2 = {'type': 'standard_elliptic',
                              'distance_bounds': {'lower': 1.1, 'upper': 1.9},
                              'angle_bounds': {'lower': 0.1, 'upper': 0.95}}
        da_area_weight = DistanceAngleAreaNbSetWeight(weight_type='has_intersection',
                                                      surface_definition=surface_definition,
                                                      nb_sets_from_hints='fallback_to_source',
                                                      other_nb_sets='0_weight',
                                                      additional_condition=DistanceAngleAreaNbSetWeight.AC.ONLY_ACB)
        da_area_weight_2 = DistanceAngleAreaNbSetWeight(weight_type='has_intersection',
                                                      surface_definition=surface_definition_2,
                                                      nb_sets_from_hints='fallback_to_source',
                                                      other_nb_sets='0_weight',
                                                      additional_condition=DistanceAngleAreaNbSetWeight.AC.ONLY_ACB)
        weight_estimator = {'function': 'smootherstep',
                            'options': {'delta_csm_min': 0.5,
                                        'delta_csm_max': 3.0}}
        symmetry_measure_type = 'csm_wcs_ctwcc'
        delta_weight = DeltaCSMNbSetWeight(effective_csm_estimator=effective_csm_estimator,
                                           weight_estimator=weight_estimator,
                                           symmetry_measure_type=symmetry_measure_type)
        bias_weight = CNBiasNbSetWeight.linearly_equidistant(weight_cn1=1.0, weight_cn13=4.0)
        bias_weight_2 = CNBiasNbSetWeight.linearly_equidistant(weight_cn1=1.0, weight_cn13=5.0)
        angle_weight = AngleNbSetWeight()
        nad_weight = NormalizedAngleDistanceNbSetWeight(average_type='geometric', aa=1, bb=1)
        multi_weights_strategy_1 = MultiWeightsChemenvStrategy(dist_ang_area_weight=da_area_weight,
                                                               self_csm_weight=self_csm_weight,
                                                               delta_csm_weight=delta_weight,
                                                               cn_bias_weight=bias_weight,
                                                               angle_weight=angle_weight,
                                                               normalized_angle_distance_weight=nad_weight,
                                                               symmetry_measure_type=symmetry_measure_type)
        multi_weights_strategy_2 = MultiWeightsChemenvStrategy(dist_ang_area_weight=da_area_weight,
                                                               self_csm_weight=self_csm_weight,
                                                               delta_csm_weight=delta_weight,
                                                               cn_bias_weight=bias_weight_2,
                                                               angle_weight=angle_weight,
                                                               normalized_angle_distance_weight=nad_weight,
                                                               symmetry_measure_type=symmetry_measure_type)
        multi_weights_strategy_3 = MultiWeightsChemenvStrategy(dist_ang_area_weight=da_area_weight_2,
                                                               self_csm_weight=self_csm_weight,
                                                               delta_csm_weight=delta_weight,
                                                               cn_bias_weight=bias_weight,
                                                               angle_weight=angle_weight,
                                                               normalized_angle_distance_weight=nad_weight,
                                                               symmetry_measure_type=symmetry_measure_type)
        multi_weights_strategy_1_from_dict = MultiWeightsChemenvStrategy.from_dict(multi_weights_strategy_1.as_dict())

        self.assertTrue(multi_weights_strategy_1 == multi_weights_strategy_1_from_dict)
        self.assertFalse(simplest_strategy_1 == multi_weights_strategy_1)
        self.assertFalse(multi_weights_strategy_1 == multi_weights_strategy_2)
        self.assertFalse(multi_weights_strategy_1 == multi_weights_strategy_3)
        self.assertFalse(multi_weights_strategy_2 == multi_weights_strategy_3)
    def get_weights(self, weights_options):
        effective_csm_estimator = {
            'function': 'power2_inverse_decreasing',
            'options': {
                'max_csm': 8.0
            }
        }

        self_weight_estimator = {
            'function': 'power2_decreasing_exp',
            'options': {
                'max_csm': 5.4230949041608305,
                'alpha': 1.0
            }
        }

        self_csm_weight = SelfCSMNbSetWeight(
            effective_csm_estimator=effective_csm_estimator,
            weight_estimator=self_weight_estimator)

        surface_definition = {
            'type': 'standard_elliptic',
            'distance_bounds': {
                'lower': 1.05,
                'upper': 2.0
            },
            'angle_bounds': {
                'lower': 0.05,
                'upper': 0.95
            }
        }

        da_area_weight = DistanceAngleAreaNbSetWeight(
            weight_type='has_intersection',
            surface_definition=surface_definition,
            nb_sets_from_hints='fallback_to_source',
            other_nb_sets='0_weight',
            additional_condition=DistanceAngleAreaNbSetWeight.AC.ONLY_ACB)

        weight_estimator = {
            'function': 'smootherstep',
            'options': {
                'delta_csm_min': 0.5,
                'delta_csm_max': 3.0
            }
        }

        symmetry_measure_type = 'csm_wcs_ctwcc'
        delta_csm_weight = DeltaCSMNbSetWeight(
            effective_csm_estimator=effective_csm_estimator,
            weight_estimator=weight_estimator,
            symmetry_measure_type=symmetry_measure_type)

        bias_weight = CNBiasNbSetWeight.linearly_equidistant(weight_cn1=1.0,
                                                             weight_cn13=4.0)
        angle_weight = AngleNbSetWeight()

        nad_weight = NormalizedAngleDistanceNbSetWeight(
            average_type='geometric', aa=1, bb=1)

        weights = {
            'DistAngArea': da_area_weight,
            'SelfCSM': self_csm_weight,
            'DeltaCSM': delta_csm_weight,
            'CNBias': bias_weight,
            'Angle': angle_weight,
            'NormalizedAngDist': nad_weight
        }

        return weights
Beispiel #10
0
    def test_strategies(self):
        simplest_strategy_1 = SimplestChemenvStrategy()
        simplest_strategy_2 = SimplestChemenvStrategy(distance_cutoff=1.5,
                                                      angle_cutoff=0.5)
        self.assertFalse(simplest_strategy_1 == simplest_strategy_2)
        simplest_strategy_1_from_dict = SimplestChemenvStrategy.from_dict(
            simplest_strategy_1.as_dict())
        self.assertTrue(simplest_strategy_1, simplest_strategy_1_from_dict)

        effective_csm_estimator = {
            'function': 'power2_inverse_decreasing',
            'options': {
                'max_csm': 8.0
            }
        }
        self_csm_weight = SelfCSMNbSetWeight()
        surface_definition = {
            'type': 'standard_elliptic',
            'distance_bounds': {
                'lower': 1.1,
                'upper': 1.9
            },
            'angle_bounds': {
                'lower': 0.1,
                'upper': 0.9
            }
        }
        surface_definition_2 = {
            'type': 'standard_elliptic',
            'distance_bounds': {
                'lower': 1.1,
                'upper': 1.9
            },
            'angle_bounds': {
                'lower': 0.1,
                'upper': 0.95
            }
        }
        da_area_weight = DistanceAngleAreaNbSetWeight(
            weight_type='has_intersection',
            surface_definition=surface_definition,
            nb_sets_from_hints='fallback_to_source',
            other_nb_sets='0_weight',
            additional_condition=DistanceAngleAreaNbSetWeight.AC.ONLY_ACB)
        da_area_weight_2 = DistanceAngleAreaNbSetWeight(
            weight_type='has_intersection',
            surface_definition=surface_definition_2,
            nb_sets_from_hints='fallback_to_source',
            other_nb_sets='0_weight',
            additional_condition=DistanceAngleAreaNbSetWeight.AC.ONLY_ACB)
        weight_estimator = {
            'function': 'smootherstep',
            'options': {
                'delta_csm_min': 0.5,
                'delta_csm_max': 3.0
            }
        }
        symmetry_measure_type = 'csm_wcs_ctwcc'
        delta_weight = DeltaCSMNbSetWeight(
            effective_csm_estimator=effective_csm_estimator,
            weight_estimator=weight_estimator,
            symmetry_measure_type=symmetry_measure_type)
        bias_weight = CNBiasNbSetWeight.linearly_equidistant(weight_cn1=1.0,
                                                             weight_cn13=4.0)
        bias_weight_2 = CNBiasNbSetWeight.linearly_equidistant(weight_cn1=1.0,
                                                               weight_cn13=5.0)
        angle_weight = AngleNbSetWeight()
        nad_weight = NormalizedAngleDistanceNbSetWeight(
            average_type='geometric', aa=1, bb=1)
        multi_weights_strategy_1 = MultiWeightsChemenvStrategy(
            dist_ang_area_weight=da_area_weight,
            self_csm_weight=self_csm_weight,
            delta_csm_weight=delta_weight,
            cn_bias_weight=bias_weight,
            angle_weight=angle_weight,
            normalized_angle_distance_weight=nad_weight,
            symmetry_measure_type=symmetry_measure_type)
        multi_weights_strategy_2 = MultiWeightsChemenvStrategy(
            dist_ang_area_weight=da_area_weight,
            self_csm_weight=self_csm_weight,
            delta_csm_weight=delta_weight,
            cn_bias_weight=bias_weight_2,
            angle_weight=angle_weight,
            normalized_angle_distance_weight=nad_weight,
            symmetry_measure_type=symmetry_measure_type)
        multi_weights_strategy_3 = MultiWeightsChemenvStrategy(
            dist_ang_area_weight=da_area_weight_2,
            self_csm_weight=self_csm_weight,
            delta_csm_weight=delta_weight,
            cn_bias_weight=bias_weight,
            angle_weight=angle_weight,
            normalized_angle_distance_weight=nad_weight,
            symmetry_measure_type=symmetry_measure_type)
        multi_weights_strategy_1_from_dict = MultiWeightsChemenvStrategy.from_dict(
            multi_weights_strategy_1.as_dict())

        self.assertTrue(
            multi_weights_strategy_1 == multi_weights_strategy_1_from_dict)
        self.assertFalse(simplest_strategy_1 == multi_weights_strategy_1)
        self.assertFalse(multi_weights_strategy_1 == multi_weights_strategy_2)
        self.assertFalse(multi_weights_strategy_1 == multi_weights_strategy_3)
        self.assertFalse(multi_weights_strategy_2 == multi_weights_strategy_3)