<commit_before>import unittest
import numpy
from copy import deepcopy
from nose.tools import assert_false, assert_true

from athenet.algorithm.sharpen_filters import sharpen_filters_in_layer
from mocks.mock_network import LayerMock


class SharpenFiltersTest(unittest.TestCase):
    shape = (6, 1, 10, 10)

    def get_conv_layer(self, shape=None):
        if shape is None:
            shape = self.shape
        return LayerMock(
            weights=numpy.random.uniform(low=-1, high=1, size=shape),
            biases=numpy.random.uniform(low=-1, high=1, size=shape)
        )

    def test_no_change(self):
        layer = self.get_conv_layer()
        changed_layer = deepcopy(layer)
        sharpen_filters_in_layer(changed_layer, (1, 0, (5, 75, 75)))
        assert_true(numpy.array_equal(layer.W, changed_layer.W))

    def test_all_zeros(self):
        layer = self.get_conv_layer()
        sharpen_filters_in_layer(layer, (0, 1, (5, 75, 75)))
        assert_false(layer.W.any())

    def test_flat_filter(self):
        layer = LayerMock(
            weights=numpy.full(self.shape, 0.4),
            biases=numpy.random.uniform(low=-1, high=1, size=self.shape)
        )

        for min_noise, max_value in [(0.1, 0.2), (0.1, 0.6), (0, 0.2)]:
            changed_layer = deepcopy(layer)
            sharpen_filters_in_layer(changed_layer,
                                     (min_noise, max_value, (5, 75, 75)))
            assert_true(numpy.array_equal(layer.W, changed_layer.W))

        changed_layer = deepcopy(layer)
        sharpen_filters_in_layer(changed_layer, (0, 0.6, (5, 75, 75)))
        assert_false(changed_layer.W.any())

    def test_small_values_in_filters(self):
        layer = LayerMock(
            weights=numpy.random.uniform(low=-0.2, high=0.2, size=self.shape),
            biases=numpy.random.uniform(low=-1, high=1, size=self.shape)
        )

        changed_layer = deepcopy(layer)
        sharpen_filters_in_layer(changed_layer, (0.1, 0.1, (5, 75, 75)))
        assert_true(changed_layer.W.any())

        changed_layer = deepcopy(layer)
        sharpen_filters_in_layer(changed_layer, (0, 0.3, (5, 75, 75)))
        assert_false(changed_layer.W.any())<commit_msg>delete tests for filters<commit_after>import unittest
import numpy
from copy import deepcopy
from nose.tools import assert_false, assert_true

from athenet.algorithm.sharpen_filters import sharpen_filters
from mocks.mock_network import LayerMock


class SharpenFiltersTest(unittest.TestCase):
    shape = (6, 1, 10, 10)

    def get_conv_layer(self, shape=None):
        if shape is None:
            shape = self.shape
        return LayerMock(
            weights=numpy.random.uniform(low=-1, high=1, size=shape),
            biases=numpy.random.uniform(low=-1, high=1, size=shape)
        )
{'fraction_non_alphanumeric': 0.11428571428571428, 'fraction_numerical': 0.030357142857142857, 'mean_word_length': 2.8741355463347165, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5200328', 'n_tokens_mistral': 979, 'n_tokens_neox': 921, 'n_words': 183}