Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Tensor-valued DiscreteLp #1238

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
41b1d8e
ENH: implement tensor-valued DiscreteLp
Nov 13, 2017
a165e9c
ENH: support adding new axes to spaces
kohr-h Jan 29, 2018
d6b96e3
ENH: speed up bool array indexing and other indexing ops
kohr-h Jan 30, 2018
ac8be7f
ENH: make show work with tensor-valued functions
kohr-h Jan 31, 2018
08359d3
ENH: make DiscreteLp.astype work properly with shaped dtype
kohr-h Jan 31, 2018
b1f51f7
BUG: fix issue with axis_labels in slicing and show
kohr-h Jan 31, 2018
7eb0592
ENH: complete and improve byaxis in fspace and DiscreteLp
kohr-h Jan 31, 2018
a4ce850
MAINT: harmonize names shape_out and dtype_out
kohr-h Jan 31, 2018
8d7de2f
BUG: remove const from per-axis weighting due to issues with __eq__
kohr-h Jan 31, 2018
3fe5515
BUG: fix byaxis of fspace and lp_discr
kohr-h Jun 30, 2018
e3c6267
ENH: add npy_erroroptions contex mgr and silence test warnings
kohr-h Jun 30, 2018
38c3431
ENH: add ProductSpaceElement.astype, closes #1397
kohr-h Jun 30, 2018
78622e5
MAINT: fix/improve various tests
kohr-h Jun 30, 2018
1ba4320
BUG: Fix is_int to not accept floats like 2.0
kohr-h Jun 30, 2018
587f4a3
ENH: add array_hash utility
kohr-h Jun 30, 2018
013be00
MAINT: indexing and other fixes
kohr-h Jun 30, 2018
b62d023
ENH: support exponent -inf and harmonize norm defs
kohr-h Jun 30, 2018
f4a6fd5
DOC: fix typo in lp_discr doctest
kohr-h Jul 1, 2018
d9f0874
BUG: fix is_int utility
kohr-h Jul 1, 2018
4829f1d
TST: remove weighing in expected inf-norm
kohr-h Jul 1, 2018
6e6187d
DOC: minor doctest fix in numerics.py
kohr-h Jul 1, 2018
723d0bf
BUG: fix string failure in is_int
kohr-h Jul 1, 2018
abfdb0d
DOC: improve doc of is_int
kohr-h Jul 1, 2018
688c0d5
ENH: support astype with shaped dtype in DiscreteLp
kohr-h Jul 2, 2018
0a93baf
BUG: fix weight propagation in default case in NumpyTensorSpace
kohr-h Sep 12, 2018
e094e86
MAINT: avoid ComplexWarning in c2r FT
kohr-h Sep 12, 2018
527bf45
API: make `data` an abstract method of `Tensor`
kohr-h Sep 12, 2018
5270eb4
ENH: use np precision instead of hardcoded one in npy tensor repr
kohr-h Sep 12, 2018
b9d03b0
ENH: add `newaxis` to TensorSpace and use it in DiscreteLp.astype
kohr-h Sep 13, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/tomo/ray_trafo_parallel_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# projection data (or any element in the projection space).
backproj = ray_trafo.adjoint(proj_data)

# Shows a slice of the phantom, projections, and reconstruction
# Show a slice of the phantom, projections, and reconstruction
phantom.show(title='Phantom')
proj_data.show(title='Projection data (sinogram)')
backproj.show(title='Back-projected data', force_show=True)
11 changes: 6 additions & 5 deletions odl/discr/discr_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ def __init__(self, map_type, fspace, partition, tspace, linear=False):
'of the function set {}'
''.format(partition, fspace.domain, fspace))

if tspace.shape != partition.shape:
raise ValueError('`tspace.shape` not equal to `partition.shape`: '
'{} != {}'
''.format(tspace.shape, partition.shape))
if tspace.shape != fspace.shape_out + partition.shape:
raise ValueError(
'`tspace.shape` not equal to '
'`fspace.shape_out + partition.shape`: {} != {}'
''.format(tspace.shape, fspace.shape_out + partition.shape))

domain = fspace if map_type == 'sampling' else tspace
range = tspace if map_type == 'sampling' else fspace
Expand Down Expand Up @@ -323,7 +324,7 @@ def __init__(self, fspace, partition, tspace, variant='left'):
data type in 2d:

>>> rect = odl.IntervalProd([0, 0], [1, 1])
>>> fspace = odl.FunctionSpace(rect, out_dtype='U1')
>>> fspace = odl.FunctionSpace(rect, dtype_out='U1')

Partitioning the domain uniformly with no nodes on the boundary
(will shift the grid points):
Expand Down
2 changes: 1 addition & 1 deletion odl/discr/discr_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def _resize_discr(discr, newshp, offset, discr_kwargs):
new_maxpt.append(grid_max[axis] + (num_r + 0.5) * cell_size[axis])

fspace = FunctionSpace(IntervalProd(new_minpt, new_maxpt),
out_dtype=dtype)
dtype_out=dtype)
tspace = tensor_space(newshp, dtype=dtype, impl=impl, exponent=exponent,
weighting=weighting)

Expand Down
13 changes: 10 additions & 3 deletions odl/discr/discretization.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,13 @@ def __eq__(self, other):
def __getitem__(self, indices):
"""Return ``self[indices]``.

.. note::
This is a basic implementation that does little more than
propagating the indexing to the `tensor` attribute. In
particular, the result will **not** be wrapped as a
`DiscretizedSpaceElement` again. Subclasses should take
care of that by overriding ``__getitem__``.

Parameters
----------
indices : int or `slice`
Expand Down Expand Up @@ -417,9 +424,9 @@ def sampling(self, ufunc, **kwargs):
Parameters
----------
ufunc : ``self.space.fspace`` element
The continuous function that should be samplingicted.
The continuous function that should be sampled.
kwargs :
Additional arugments for the sampling operator implementation
Additional arguments for the sampling operator implementation.

Examples
--------
Expand All @@ -445,7 +452,7 @@ def interpolation(self):
Returns
-------
interpolation_op : `FunctionSpaceMapping`
Operatior representing a continuous interpolation of this
Operator representing a continuous interpolation of this
element.

Examples
Expand Down
7 changes: 4 additions & 3 deletions odl/discr/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from odl.set import Set, IntervalProd
from odl.util import (
normalized_index_expression, normalized_scalar_param_list, safe_int_conv,
array_str, signature_string, indent, npy_printoptions)
array_str, signature_string, indent, npy_printoptions, array_hash)


__all__ = ('RectGrid', 'uniform_grid', 'uniform_grid_fromintv')
Expand Down Expand Up @@ -521,8 +521,9 @@ def __eq__(self, other):
def __hash__(self):
"""Return ``hash(self)``."""
# TODO: update with #841
coord_vec_str = tuple(cv.tobytes() for cv in self.coord_vectors)
return hash((type(self), coord_vec_str))
return hash(
(type(self), tuple(array_hash(cv) for cv in self.coord_vectors))
)

def approx_contains(self, other, atol):
"""Test if ``other`` belongs to this grid up to a tolerance.
Expand Down
Loading