コード例 #1
0
 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
コード例 #2
0
ファイル: instrument.py プロジェクト: DougBurke/sherpa
 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
コード例 #3
0
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])
コード例 #4
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)
コード例 #5
0
ファイル: instrument.py プロジェクト: DougBurke/sherpa
    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)
コード例 #6
0
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'