Skip to content

Commit

Permalink
MAINT: Fix bug with ZeroOperator when domain!=range
Browse files Browse the repository at this point in the history
  • Loading branch information
adler-j committed Oct 5, 2016
1 parent 6aebe8a commit 5b22e42
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions odl/operator/default_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,12 @@ def __init__(self, domain, range=None):
>>> op = odl.ZeroOperator(odl.rn(3))
>>> op([1, 2, 3])
rn(3).element([0.0, 0.0, 0.0])
Also works with domain != range
>>> op = odl.ZeroOperator(odl.rn(3), odl.cn(4))
>>> op([1, 2, 3])
cn(4).element([0j, 0j, 0j, 0j])
"""
if range is None:
range = domain
Expand All @@ -847,10 +853,17 @@ def __init__(self, domain, range=None):

def _call(self, x, out=None):
"""Return the constant vector or assign it to ``out``."""
if out is None:
out = 0 * x
if self.domain == self.range:
if out is None:
out = 0 * x
else:
out.lincomb(0, x)
else:
out.lincomb(0, x)
result = self.range.zero()
if out is None:
out = result
else:
out.assign(result)
return out

@property
Expand Down

0 comments on commit 5b22e42

Please sign in to comment.