Exemplo n.º 1
0
def test_get_padsize_too_large():
    """Pick one larger than the current maximum"""

    with pytest.raises(TypeError) as te:
        _psf.get_padsize(32401)

    assert str(te.value) == 'Padding dimension length 32401 not supported'
Exemplo n.º 2
0
def test_get_padsize(actual, expected):
    """These are taken from the hard-coded table, so will need updating
    wenever we update it in the code.
    """

    got = _psf.get_padsize(actual)
    assert got == expected
Exemplo n.º 3
0
    def init_data(self, data):
        if self.renorm_shape is None:
            renorm_shape = []
            for axis in self.dshape:
                renorm_shape.append(get_padsize(2 * axis))
            self.renorm_shape = tuple(renorm_shape)

        # pad the data and convolve with unpadded kernel
        datapad = pad_data(data, self.dshape, self.renorm_shape)
        return (datapad, self.renorm_shape)
Exemplo n.º 4
0
    def init_data(self, data):
        if self.renorm_shape is None:
            renorm_shape = []
            for axis in self.dshape:
                renorm_shape.append(get_padsize(2 * axis))
            self.renorm_shape = tuple(renorm_shape)

        # pad the data and convolve with unpadded kernel
        datapad = pad_data(data, self.dshape, self.renorm_shape)
        return (datapad, self.renorm_shape)
Exemplo n.º 5
0
    def init_kernel(self, kernel):
        if not self.frozen:
            self._tcd.clear_kernel_fft()

        renorm_shape = []
        for axis in self.dshape:
            renorm_shape.append(get_padsize(2 * axis))
        self.renorm_shape = tuple(renorm_shape)

        kernpad = pad_data(kernel, self.dshape, self.renorm_shape)

        self.renorm = self._tcd.convolve(numpy.ones(len(kernel)), kernpad,
                                         self.dshape, renorm_shape,
                                         self.origin)
        self.renorm = unpad_data(self.renorm, renorm_shape, self.dshape)
        return (kernel, self.dshape)
Exemplo n.º 6
0
    def init_kernel(self, kernel):
        if not self.frozen:
            self._tcd.clear_kernel_fft()

        renorm_shape = []
        for axis in self.dshape:
            renorm_shape.append(get_padsize(2 * axis))
        self.renorm_shape = tuple(renorm_shape)

        kernpad = pad_data(kernel, self.dshape, self.renorm_shape)

        self.renorm = self._tcd.convolve(numpy.ones(len(kernel)), kernpad,
                                         self.dshape, renorm_shape,
                                         self.origin)
        self.renorm = unpad_data(self.renorm, renorm_shape, self.dshape)
        return (kernel, self.dshape)