def test_other(self, dtype, input, sigma):
        theano.config.compute_test_value = 'ignore'
        sigma_theano = theano.shared(sigma)
        window_radius = int(sigma * 4)
        if input == 'pixel':
            test_data = np.ones((100, 100))
            test_data[50, 50] = 2
        elif input == 'random':
            test_data = 10 * np.ones((100, 100))
            test_data += np.random.randn(100, 100)

        else:
            raise ValueError(input)

        test_data = test_data.astype(dtype)
        data = T.tensor3('data', dtype=dtype)
        data.tag.test_value = test_data[np.newaxis, :, :]
        print(data.dtype)

        blur = gaussian_filter(data, sigma_theano, window_radius)

        f = theano.function([data], blur)
        out = f(test_data[np.newaxis, :, :])[0, :, :]

        scipy_out = scipy_filter(test_data, sigma, mode='nearest')

        if dtype == 'float32':
            rtol = 5e-6
        else:
            rtol = 1e-7
        np.testing.assert_allclose(out, scipy_out, rtol=rtol)
    def check_other(self, dtype, input, sigma):
        theano.config.compute_test_value = 'ignore'
        sigma_theano = theano.shared(sigma)
        window_radius = int(sigma*4)
        if input == 'pixel':
            test_data = np.ones((100, 100))
            test_data[50, 50] = 2
        elif input == 'random':
            test_data = 10*np.ones((100, 100))
            test_data += np.random.randn(100, 100)

        else:
            raise ValueError(input)

        test_data = test_data.astype(dtype)
        data = T.tensor3('data', dtype=dtype)
        data.tag.test_value = test_data[np.newaxis, :, :]
        print(data.dtype)

        blur = gaussian_filter(data, sigma_theano, window_radius)

        f = theano.function([data], blur)
        out = f(test_data[np.newaxis, :, :])[0, :, :]

        scipy_out = scipy_filter(test_data, sigma, mode='nearest')

        if dtype == 'float32':
            rtol = 1e-6
        else:
            rtol = 1e-7
        np.testing.assert_allclose(out, scipy_out, rtol=rtol)
    def test_blur_ones(self):
        sigma = theano.shared(20.0)
        window_radius = 20 * 4
        data = T.tensor3('data', dtype='float64')
        data.tag.test_value = np.zeros((1, 10, 10))

        blur = gaussian_filter(data, sigma, window_radius)

        f = theano.function([data], blur)

        test_data = np.ones((1000, 1000))
        out = f(test_data[np.newaxis, :, :])[0, :, :]

        np.testing.assert_allclose(out, 1)
    def test_blur_ones(self):
        sigma = theano.shared(20.0)
        window_radius = 20*4
        data = T.tensor3('data', dtype='float64')
        data.tag.test_value = np.zeros((1, 10, 10))

        blur = gaussian_filter(data, sigma, window_radius)

        f = theano.function([data], blur)

        test_data = np.ones((1000, 1000))
        out = f(test_data[np.newaxis, :, :])[0, :, :]

        np.testing.assert_allclose(out, 1)