Example #1
0
    def normalize(self):
        if not self._objects:
            return

        if max(self._weights) > self._max_weight:
            self._decrease_all()

        while avg(self._weights) > self._average_weight:
            self._decrease_all()
Example #2
0
    def normalize(self):
        if not self._objects:
            return

        if max(self._weights) > self._max_weight:
            self._decrease_all()

        while avg(self._weights) > self._average_weight:
            self._decrease_all()
Example #3
0
def make_samples(threshold, message):
    assert message, "Message can't be empty"

    active_impulses = [
        [i for i, a in enumerate(row) if a >= threshold] + [None]
        for row in message.rows()
    ]

    for sample in product(*active_impulses):
        values = [message.get(y, x) if x is not None else 0 for y, x in enumerate(sample)]
        activity = avg(values)
        if activity:
            yield sample, activity
Example #4
0
def similarity(it1, it2):
    return avg(int(x == y) for x, y in zip(it1, it2))
Example #5
0
def similarity(it1, it2):
    return avg(int(x == y) for x, y in zip(it1, it2))