odlgroup / odl

Operator Discretization Library https://odlgroup.github.io/odl/
Mozilla Public License 2.0
372 stars 105 forks source link

IndexError in prod_space[1:] for length 1 -> Chambolle-Pock broken in 1D #301

Closed kohr-h closed 8 years ago

kohr-h commented 8 years ago

The following code gives an IndexError:

>>> r2 = odl.Rn(2)
>>> prod_space = odl.ProductSpace(r2)
>>> prod_space[1:]
Traceback (most recent call last):
    ...

  File "/home/hkohr/Work/Projects/2015/LCR/odl/odl/set/pspace.py", line 425, in __getitem__
    return ProductSpace(*self.spaces[indices])

  File "/home/hkohr/Work/Projects/2015/LCR/odl/odl/set/pspace.py", line 202, in __init__
    super().__init__(spaces[0].field)

IndexError: tuple index out of range

This is in contrast to python lists, tuples and Numpy arrays which give an empty set. Maybe we don't want to handle empty products, but then we get errors in places like this instead of a silently ignored iteration. The net effect is now that we cannot run Chambolle-Pock on 1d examples.

kohr-h commented 8 years ago

Addition: running

>>> odl.ProductSpace()

has the same effect and raises the same exception. The error message could be better.

kohr-h commented 8 years ago

Looking good.