Commit 0236e1cc authored by Martin Reinecke's avatar Martin Reinecke
Browse files

Merge branch 'fix_deprecation_warnings' into 'NIFTy_7'

fix numpy deprecation warnings

See merge request ift/nifty!619
parents f8d19b19 0c406f77
...@@ -59,11 +59,11 @@ class GLSpace(StructuredDomain): ...@@ -59,11 +59,11 @@ class GLSpace(StructuredDomain):
@property @property
def shape(self): def shape(self):
return (int((self.nlat * self.nlon)),) return (int(self.nlat * self.nlon),)
@property @property
def size(self): def size(self):
return int((self.nlat * self.nlon)) return int(self.nlat * self.nlon)
@property @property
def scalar_dvol(self): def scalar_dvol(self):
......
...@@ -131,7 +131,7 @@ class LMSpace(StructuredDomain): ...@@ -131,7 +131,7 @@ class LMSpace(StructuredDomain):
op = HarmonicTransformOperator(lm0, gl) op = HarmonicTransformOperator(lm0, gl)
kernel_lm = op.adjoint_times(kernel_sphere.weight(1)).val kernel_lm = op.adjoint_times(kernel_sphere.weight(1)).val
# evaluate the k lengths of the harmonic space # evaluate the k lengths of the harmonic space
k_lengths = self.get_k_length_array().val.astype(int) k_lengths = self.get_k_length_array().val.astype(np.int64)
return Field.from_raw(self, kernel_lm[k_lengths]) return Field.from_raw(self, kernel_lm[k_lengths])
@property @property
......
...@@ -122,7 +122,7 @@ class RGSpace(StructuredDomain): ...@@ -122,7 +122,7 @@ class RGSpace(StructuredDomain):
if np.all(self.distances == self.distances[0]): # shortcut if np.all(self.distances == self.distances[0]): # shortcut
maxdist = np.asarray(self.shape)//2 maxdist = np.asarray(self.shape)//2
tmp = np.sum(maxdist*maxdist) tmp = np.sum(maxdist*maxdist)
tmp = np.zeros(tmp+1, dtype=np.bool) tmp = np.zeros(tmp+1, dtype=bool)
t2 = np.arange(maxdist[0]+1, dtype=np.int64) t2 = np.arange(maxdist[0]+1, dtype=np.int64)
t2 *= t2 t2 *= t2
for i in range(1, dimensions): for i in range(1, dimensions):
......
...@@ -259,7 +259,7 @@ class Field(Operator): ...@@ -259,7 +259,7 @@ class Field(Operator):
if np.isscalar(wgt): if np.isscalar(wgt):
fct *= wgt fct *= wgt
else: else:
new_shape = np.ones(len(self.shape), dtype=int) new_shape = np.ones(len(self.shape), dtype=np.int64)
new_shape[self._domain.axes[ind][0]: new_shape[self._domain.axes[ind][0]:
self._domain.axes[ind][-1]+1] = wgt.shape self._domain.axes[ind][-1]+1] = wgt.shape
wgt = wgt.reshape(new_shape) wgt = wgt.reshape(new_shape)
......
...@@ -68,9 +68,9 @@ class _LightConeDerivative(LinearOperator): ...@@ -68,9 +68,9 @@ class _LightConeDerivative(LinearOperator):
def _cone_arrays(c, domain, sigx, want_gradient): def _cone_arrays(c, domain, sigx, want_gradient):
x = _make_coords(domain) x = _make_coords(domain)
a = np.zeros(domain.shape, dtype=np.complex) a = np.zeros(domain.shape, dtype=np.complex128)
if want_gradient: if want_gradient:
derivs = np.zeros((c.size,) + domain.shape, dtype=np.complex) derivs = np.zeros((c.size,) + domain.shape, dtype=np.complex128)
else: else:
derivs = None derivs = None
a -= (x[0]/(sigx*domain[0].distances[0]))**2 a -= (x[0]/(sigx*domain[0].distances[0]))**2
......
...@@ -64,10 +64,10 @@ def _comp_traverse(start, end, shp, dist, lo, mid, hi, sig, erf): ...@@ -64,10 +64,10 @@ def _comp_traverse(start, end, shp, dist, lo, mid, hi, sig, erf):
c_first = np.ceil(start[:, i]+direction*dmin) c_first = np.ceil(start[:, i]+direction*dmin)
c_first = np.where(direction > 0., c_first, c_first-1.) c_first = np.where(direction > 0., c_first, c_first-1.)
c_first = (c_first-start[:, i])/dirx c_first = (c_first-start[:, i])/dirx
pos1 = np.asarray((start[:, i]+dmin*direction), dtype=int) pos1 = np.asarray((start[:, i]+dmin*direction), dtype=np.int64)
pos1 = np.sum(pos1*inc) pos1 = np.sum(pos1*inc)
cdist = np.empty(0, dtype=np.float64) cdist = np.empty(0, dtype=np.float64)
add = np.empty(0, dtype=int) add = np.empty(0, dtype=np.int64)
for j in range(ndim): for j in range(ndim):
if direction[j] != 0: if direction[j] != 0:
step = inc[j] if direction[j] > 0 else -inc[j] step = inc[j] if direction[j] > 0 else -inc[j]
......
...@@ -393,7 +393,7 @@ class _InformationStore(object): ...@@ -393,7 +393,7 @@ class _InformationStore(object):
m = self.history_length m = self.history_length
mmax = self.max_history_length mmax = self.max_history_length
k = self.k k = self.k
result = np.empty((2*m+1, 2*m+1), dtype=np.float) result = np.empty((2*m+1, 2*m+1), dtype=np.float64)
# update the stores # update the stores
k1 = (k-1) % mmax k1 = (k-1) % mmax
...@@ -435,10 +435,10 @@ class _InformationStore(object): ...@@ -435,10 +435,10 @@ class _InformationStore(object):
m = self.history_length m = self.history_length
b_dot_b = self.b_dot_b b_dot_b = self.b_dot_b
delta = np.zeros(2*m+1, dtype=np.float) delta = np.zeros(2*m+1, dtype=np.float64)
delta[2*m] = -1 delta[2*m] = -1
alpha = np.empty(m, dtype=np.float) alpha = np.empty(m, dtype=np.float64)
for j in range(m-1, -1, -1): for j in range(m-1, -1, -1):
delta_b_b = sum([delta[l] * b_dot_b[l, j] for l in range(2*m+1)]) delta_b_b = sum([delta[l] * b_dot_b[l, j] for l in range(2*m+1)])
......
...@@ -97,8 +97,8 @@ class DOFDistributor(LinearOperator): ...@@ -97,8 +97,8 @@ class DOFDistributor(LinearOperator):
firstaxis = self._target.axes[self._space][0] firstaxis = self._target.axes[self._space][0]
lastaxis = self._target.axes[self._space][-1] lastaxis = self._target.axes[self._space][-1]
arrshape = self._target.shape arrshape = self._target.shape
presize = np.prod(arrshape[0:firstaxis], dtype=int) presize = np.prod(arrshape[0:firstaxis], dtype=np.int64)
postsize = np.prod(arrshape[lastaxis+1:], dtype=int) postsize = np.prod(arrshape[lastaxis+1:], dtype=np.int64)
self._hshape = (presize, self._domain[self._space].shape[0], postsize) self._hshape = (presize, self._domain[self._space].shape[0], postsize)
self._pshape = (presize, self._dofdex.size, postsize) self._pshape = (presize, self._dofdex.size, postsize)
......
...@@ -66,7 +66,7 @@ class RegriddingOperator(LinearOperator): ...@@ -66,7 +66,7 @@ class RegriddingOperator(LinearOperator):
self._frac = [None] * ndim self._frac = [None] * ndim
for d in range(ndim): for d in range(ndim):
tmp = np.arange(new_shape[d])*(newdist[d]/dom.distances[d]) tmp = np.arange(new_shape[d])*(newdist[d]/dom.distances[d])
self._bindex[d] = np.minimum(dom.shape[d]-2, tmp.astype(int)) self._bindex[d] = np.minimum(dom.shape[d]-2, tmp.astype(np.int64))
self._frac[d] = tmp-self._bindex[d] self._frac[d] = tmp-self._bindex[d]
def apply(self, x, mode): def apply(self, x, mode):
......
...@@ -286,7 +286,7 @@ def test_stdfunc(): ...@@ -286,7 +286,7 @@ def test_stdfunc():
f = ift.Field.full(s, 27) f = ift.Field.full(s, 27)
assert_equal(f.val, 27) assert_equal(f.val, 27)
assert_equal(f.shape, (200,)) assert_equal(f.shape, (200,))
assert_equal(f.dtype, int) assert_equal(f.dtype, np.int64)
fx = ift.full(f.domain, 0) fx = ift.full(f.domain, 0)
assert_equal(f.dtype, fx.dtype) assert_equal(f.dtype, fx.dtype)
assert_equal(f.shape, fx.shape) assert_equal(f.shape, fx.shape)
......
...@@ -51,6 +51,7 @@ slow_minimizers = ['ift.SteepestDescent(IC)'] ...@@ -51,6 +51,7 @@ slow_minimizers = ['ift.SteepestDescent(IC)']
slow_minimizers) slow_minimizers)
@pmp('space', spaces) @pmp('space', spaces)
def test_quadratic_minimization(minimizer, space): def test_quadratic_minimization(minimizer, space):
with ift.random.Context(98765):
starting_point = ift.Field.from_random(domain=space, random_type='normal') * 10 starting_point = ift.Field.from_random(domain=space, random_type='normal') * 10
covariance_diagonal = ift.Field.from_random(domain=space, random_type='uniform') + 0.5 covariance_diagonal = ift.Field.from_random(domain=space, random_type='uniform') + 0.5
covariance = ift.DiagonalOperator(covariance_diagonal) covariance = ift.DiagonalOperator(covariance_diagonal)
......
Supports Markdown
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