def __init__(self, weight=.5, **kwargs): Distance.__init__(self, **kwargs) self._based_on_original = False self._signature_cache = None assert 0 <= weight <= 1 self._weight = weight self._cached_weights = None
def __init__(self, **kwargs): Distance.__init__(self, **kwargs) self._based_on_original = True self._signature_cache = None self.supported = { ProcessStartEvent: True, ProcessExitEvent: False, TrafficEvent: False }
def test_creation(self): test_algorithm = algorithm(ParentChildByNameTopologySignature()) test_algorithm.prototypes = ["1", "2", "3"] distance = Distance(signature_count=test_algorithm.signature.count) distance.init_distance( prototypes=test_algorithm.prototypes, signature_prototypes=test_algorithm.signature_prototypes) last_index = 0 for index, dist in enumerate( distance.iter_on_prototypes(test_algorithm.prototypes)): self.assertEqual(dist, [0]) last_index = index self.assertEqual(last_index, 2) self.assertEqual(distance.node_count(), [0]) self.assertFalse(distance.is_prototype_based_on_original())
def test_adding_of_results(self): distance = Distance() self.assertEqual( distance._add_result_dicts(base=[{ "1": 0, "2": 0 }], to_add=[{ "1": 1, "2": 1 }]), [{ "1": 1, "2": 1 }]) self.assertEqual( distance._add_result_dicts([{ "1": 1, "2": 1 }], [{ "1": 2, "2": -1 }]), [{ "1": 3, "2": 0 }]) self.assertEqual(distance._add_result_dicts([{ "1": 1 }], [{ "2": 1 }]), [{ "1": 1, "2": 1 }]) self.assertEqual( distance._add_result_dicts([{ "1": 2, "2": 0 }], [{ "1": -1, "3": -.5 }]), [{ "1": 1, "2": 0, "3": -.5 }])
def __init__(self, **kwargs): Distance.__init__(self, **kwargs) self._additional_nodes_dict = None self._missing_nodes_dict = None
def __init__(self, **kwargs): Distance.__init__(self, **kwargs) self._based_on_original = False self._signature_cache = None
def __init__(self, **kwargs): Distance.__init__(self, **kwargs) self._tree = None self._signature = None self._based_on_original = True
def __init__(self, max_count=3, wrapped_distance=None, **kwargs): Distance.__init__(self, **kwargs) self._max_count = max_count self._wrapped_distance = wrapped_distance(**kwargs) self._order_cache = None self._last_signatures = None
def test_raises(self): distance = Distance() self.assertRaises(NotImplementedError, distance.update_distance, None, None)