def deinit(self, vals): if self.renorm is not None: vals = unpad_data(vals, self.renorm_shape, self.dshape) vals = vals / self.renorm if self.do_pad: vals = vals[self.pad_mask] return vals
def deinit(self, vals): if self.renorm is not None: vals = unpad_data(vals, self.renorm_shape, self.dshape) vals = vals / self.renorm if self.do_pad: vals = vals[self.pad_mask] return vals
def test_unpad_data_basic(): """Not 100% sure what it's meant to do but check something. Check we can "invert" pad_data """ out = _psf.unpad_data([1, 2, 3, 4, 5, 6, 7, 0, 0, 0], [10], [7]) assert len(out) == 7 assert isinstance(out, np.ndarray) assert out == pytest.approx([1, 2, 3, 4, 5, 6, 7])
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_unpad_data_error3(): with pytest.raises(TypeError) as te: _psf.unpad_data([1, 2, 3], [4], [3]) assert str(te.value) == 'input array sizes do not match dimensions, kernel size: 3 vs kernel dim: 4'