inverse """ if self.is_orthogonal: scale = self.range.partition.cell_volume return scale * self.inverse else: # TODO: put adjoint here return super().adjoint @property def inverse(self): """Inverse of this operator. Returns ------- inverse : `WaveletTransform` See Also -------- adjoint """ return WaveletTransform( domain=self.range, nlevels=self.nlevels, wavelet=self.pywt_wavelet, pad_mode=self.pad_mode, pad_const=self.pad_const, impl=self.impl) if __name__ == '__main__': # pylint: disable=wrong-import-position from odl.util.testutils import run_doctests run_doctests(skip_if=not PYWT_AVAILABLE)
# at a long edge x0 = (cen + 2 * dx)[1] x1 = (cen + 3 * dx)[1] y1 = cen[1] z = (cen - dx)[2] phan[x0:x1, y:y1, z:-z] = 1 return discr_space.element(phan) if __name__ == '__main__': # Show the phantoms import odl # 1D discr = odl.uniform_discr(-1, 1, 300) cuboid(discr).show('cuboid 1d') # 2D discr = odl.uniform_discr([-1, -1], [1, 1], [300, 300]) cuboid(discr).show('cuboid 2d') # 3D discr = odl.uniform_discr([-1, -1, -1], [1, 1, 1], [300, 300, 300]) cuboid(discr).show('cuboid 3d') indicate_proj_axis(discr).show('indicate_proj_axis 3d') # Run also the doctests # pylint: disable=wrong-import-position from odl.util.testutils import run_doctests run_doctests()
raise_from(IndexError('axis index {} out of range for array ' 'with {} axes' ''.format(axes[-1], arr_out.ndim)), err) if arr_in.shape != tuple(in_shape): raise ValueError('expected input shape {}, got {}' ''.format(tuple(in_shape), arr_in.shape)) if is_real_dtype(arr_out.dtype): in_dtype = complex_dtype(arr_out.dtype) elif halfcomplex: raise ValueError('cannot combine halfcomplex backward transform ' 'with complex output') else: in_dtype = arr_out.dtype if arr_in.dtype != in_dtype: raise ValueError('expected input dtype {}, got {}' ''.format(dtype_repr(in_dtype), dtype_repr(arr_in.dtype))) else: # Shouldn't happen raise RuntimeError if __name__ == '__main__': # pylint: disable=wrong-import-position from odl.util.testutils import run_doctests run_doctests(skip_if=not PYFFTW_AVAILABLE)
-------- inverse """ if self.is_orthogonal: scale = self.range.partition.cell_volume return scale * self.inverse else: # TODO: put adjoint here return super(WaveletTransformInverse, self).adjoint @property def inverse(self): """Inverse of this operator. Returns ------- inverse : `WaveletTransform` See Also -------- adjoint """ return WaveletTransform( domain=self.range, wavelet=self.pywt_wavelet, nlevels=self.nlevels, pad_mode=self.pad_mode, pad_const=self.pad_const, impl=self.impl) if __name__ == '__main__': from odl.util.testutils import run_doctests run_doctests(skip_if=not PYWT_AVAILABLE)
to: .. math:: \sigma = \frac{0.9}{\tau \|L\|^2} - If both are given, they are returned as-is without further validation. """ if tau is None and sigma is None: L_norm = L.norm(estimate=True) tau = sigma = np.sqrt(0.9) / L_norm return tau, sigma elif tau is None: L_norm = L.norm(estimate=True) tau = 0.9 / (sigma * L_norm**2) return tau, float(sigma) elif sigma is None: L_norm = L.norm(estimate=True) sigma = 0.9 / (tau * L_norm**2) return float(tau), sigma else: return float(tau), float(sigma) if __name__ == '__main__': from odl.util.testutils import run_doctests run_doctests()
in_shape[axes[-1]] = arr_out.shape[axes[-1]] // 2 + 1 except IndexError as err: raise IndexError('axis index {} out of range for array ' 'with {} axes' ''.format(axes[-1], arr_out.ndim)) if arr_in.shape != tuple(in_shape): raise ValueError('expected input shape {}, got {}' ''.format(tuple(in_shape), arr_in.shape)) if is_real_dtype(arr_out.dtype): in_dtype = complex_dtype(arr_out.dtype) elif halfcomplex: raise ValueError('cannot combine halfcomplex backward transform ' 'with complex output') else: in_dtype = arr_out.dtype if arr_in.dtype != in_dtype: raise ValueError('expected input dtype {}, got {}' ''.format(dtype_repr(in_dtype), dtype_repr(arr_in.dtype))) else: # Shouldn't happen raise RuntimeError if __name__ == '__main__': from odl.util.testutils import run_doctests run_doctests(skip_if=not PYFFTW_AVAILABLE)
# Reshape the resulting stack to the expected output shape stack_flat_xtra = torch.stack(results) return stack_flat_xtra.view(extra_shape + op_out_shape) def __repr__(self): """Return ``repr(self)``.""" op_name = self.op_func.operator.__class__.__name__ op_dom_shape = self.op_func.operator.domain.shape if len(op_dom_shape) == 1: op_dom_shape = op_dom_shape[0] op_ran_shape = self.op_func.operator.range.shape if len(op_ran_shape) == 1: op_ran_shape = op_ran_shape[0] return '{}({}) ({} -> {})'.format(self.__class__.__name__, op_name, op_dom_shape, op_ran_shape) if __name__ == '__main__': from odl.util.testutils import run_doctests import odl from torch import autograd, nn run_doctests(extraglobs={ 'np': np, 'odl': odl, 'torch': torch, 'nn': nn, 'autograd': autograd })