def test_pad_data_basic(): """Not 100% sure what it's meant to do but check something.""" out = _psf.pad_data([1, 2, 3, 4, 5, 6, 7], [7], [10]) assert len(out) == 10 assert isinstance(out, np.ndarray) assert out == pytest.approx([1, 2, 3, 4, 5, 6, 7, 0, 0, 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)
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)
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)
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)
def test_pad_data_error3(): with pytest.raises(TypeError) as te: _psf.pad_data([1, 2, 3], [2], [3]) assert str(te.value) == 'input array sizes do not match dimensions, kernel size: 3 vs kernel dim: 2'