Commit 723b64b2 authored by Martin Reinecke's avatar Martin Reinecke

Merge branch 'check_negatives' into 'NIFTy_5'

Check for negative number of pixels or negative binbounds

See merge request !335
parents 35da33ea e9e5774c
Pipeline #52954 passed with stages
in 23 minutes and 1 second
......@@ -50,6 +50,8 @@ class LogRGSpace(StructuredDomain):
self._bindistances = tuple(bindistances)
self._t_0 = tuple(t_0)
if min(self._bindistances) <= 0:
raise ValueError('Non-positive bindistances encountered')
self._dim = int(reduce(lambda x, y: x*y, self._shape))
self._dvol = float(reduce(lambda x, y: x*y, self._bindistances))
......
......@@ -165,6 +165,8 @@ class PowerSpace(StructuredDomain):
if binbounds is not None:
binbounds = tuple(binbounds)
if min(binbounds) < 0:
raise ValueError('Negative binbounds encountered')
key = (harmonic_partner, binbounds)
if self._powerIndexCache.get(key) is None:
......
......@@ -54,6 +54,8 @@ class RGSpace(StructuredDomain):
if np.isscalar(shape):
shape = (shape,)
self._shape = tuple(int(i) for i in shape)
if min(self._shape) < 0:
raise ValueError('Negative number of pixels encountered')
if distances is None:
if self.harmonic:
......@@ -66,6 +68,8 @@ class RGSpace(StructuredDomain):
temp = np.empty(len(self.shape), dtype=np.float64)
temp[:] = distances
self._distances = tuple(temp)
if min(self._distances) <= 0:
raise ValueError('Non-positive distances encountered')
self._dvol = float(reduce(lambda x, y: x*y, self._distances))
self._size = int(reduce(lambda x, y: x*y, self._shape))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment