Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Neel Shah
NIFTy
Commits
0236e1cc
Commit
0236e1cc
authored
May 19, 2021
by
Martin Reinecke
Browse files
Merge branch 'fix_deprecation_warnings' into 'NIFTy_7'
fix numpy deprecation warnings See merge request
!619
parents
f8d19b19
0c406f77
Changes
11
Hide whitespace changes
Inline
Side-by-side
src/domains/gl_space.py
View file @
0236e1cc
...
...
@@ -59,11 +59,11 @@ class GLSpace(StructuredDomain):
@
property
def
shape
(
self
):
return
(
int
(
(
self
.
nlat
*
self
.
nlon
)
)
,)
return
(
int
(
self
.
nlat
*
self
.
nlon
),)
@
property
def
size
(
self
):
return
int
(
(
self
.
nlat
*
self
.
nlon
)
)
return
int
(
self
.
nlat
*
self
.
nlon
)
@
property
def
scalar_dvol
(
self
):
...
...
src/domains/lm_space.py
View file @
0236e1cc
...
...
@@ -131,7 +131,7 @@ class LMSpace(StructuredDomain):
op
=
HarmonicTransformOperator
(
lm0
,
gl
)
kernel_lm
=
op
.
adjoint_times
(
kernel_sphere
.
weight
(
1
)).
val
# 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
.
int
64
)
return
Field
.
from_raw
(
self
,
kernel_lm
[
k_lengths
])
@
property
...
...
src/domains/rg_space.py
View file @
0236e1cc
...
...
@@ -122,7 +122,7 @@ class RGSpace(StructuredDomain):
if
np
.
all
(
self
.
distances
==
self
.
distances
[
0
]):
# shortcut
maxdist
=
np
.
asarray
(
self
.
shape
)
//
2
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
*=
t2
for
i
in
range
(
1
,
dimensions
):
...
...
src/field.py
View file @
0236e1cc
...
...
@@ -259,7 +259,7 @@ class Field(Operator):
if
np
.
isscalar
(
wgt
):
fct
*=
wgt
else
:
new_shape
=
np
.
ones
(
len
(
self
.
shape
),
dtype
=
int
)
new_shape
=
np
.
ones
(
len
(
self
.
shape
),
dtype
=
np
.
int
64
)
new_shape
[
self
.
_domain
.
axes
[
ind
][
0
]:
self
.
_domain
.
axes
[
ind
][
-
1
]
+
1
]
=
wgt
.
shape
wgt
=
wgt
.
reshape
(
new_shape
)
...
...
src/library/light_cone_operator.py
View file @
0236e1cc
...
...
@@ -68,9 +68,9 @@ class _LightConeDerivative(LinearOperator):
def
_cone_arrays
(
c
,
domain
,
sigx
,
want_gradient
):
x
=
_make_coords
(
domain
)
a
=
np
.
zeros
(
domain
.
shape
,
dtype
=
np
.
complex
)
a
=
np
.
zeros
(
domain
.
shape
,
dtype
=
np
.
complex
128
)
if
want_gradient
:
derivs
=
np
.
zeros
((
c
.
size
,)
+
domain
.
shape
,
dtype
=
np
.
complex
)
derivs
=
np
.
zeros
((
c
.
size
,)
+
domain
.
shape
,
dtype
=
np
.
complex
128
)
else
:
derivs
=
None
a
-=
(
x
[
0
]
/
(
sigx
*
domain
[
0
].
distances
[
0
]))
**
2
...
...
src/library/los_response.py
View file @
0236e1cc
...
...
@@ -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
.
where
(
direction
>
0.
,
c_first
,
c_first
-
1.
)
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
.
int
64
)
pos1
=
np
.
sum
(
pos1
*
inc
)
cdist
=
np
.
empty
(
0
,
dtype
=
np
.
float64
)
add
=
np
.
empty
(
0
,
dtype
=
int
)
add
=
np
.
empty
(
0
,
dtype
=
np
.
int
64
)
for
j
in
range
(
ndim
):
if
direction
[
j
]
!=
0
:
step
=
inc
[
j
]
if
direction
[
j
]
>
0
else
-
inc
[
j
]
...
...
src/minimization/descent_minimizers.py
View file @
0236e1cc
...
...
@@ -393,7 +393,7 @@ class _InformationStore(object):
m
=
self
.
history_length
mmax
=
self
.
max_history_length
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
.
float
64
)
# update the stores
k1
=
(
k
-
1
)
%
mmax
...
...
@@ -435,10 +435,10 @@ class _InformationStore(object):
m
=
self
.
history_length
b_dot_b
=
self
.
b_dot_b
delta
=
np
.
zeros
(
2
*
m
+
1
,
dtype
=
np
.
float
)
delta
=
np
.
zeros
(
2
*
m
+
1
,
dtype
=
np
.
float
64
)
delta
[
2
*
m
]
=
-
1
alpha
=
np
.
empty
(
m
,
dtype
=
np
.
float
)
alpha
=
np
.
empty
(
m
,
dtype
=
np
.
float
64
)
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
)])
...
...
src/operators/distributors.py
View file @
0236e1cc
...
...
@@ -97,8 +97,8 @@ class DOFDistributor(LinearOperator):
firstaxis
=
self
.
_target
.
axes
[
self
.
_space
][
0
]
lastaxis
=
self
.
_target
.
axes
[
self
.
_space
][
-
1
]
arrshape
=
self
.
_target
.
shape
presize
=
np
.
prod
(
arrshape
[
0
:
firstaxis
],
dtype
=
int
)
postsize
=
np
.
prod
(
arrshape
[
lastaxis
+
1
:],
dtype
=
int
)
presize
=
np
.
prod
(
arrshape
[
0
:
firstaxis
],
dtype
=
np
.
int
64
)
postsize
=
np
.
prod
(
arrshape
[
lastaxis
+
1
:],
dtype
=
np
.
int
64
)
self
.
_hshape
=
(
presize
,
self
.
_domain
[
self
.
_space
].
shape
[
0
],
postsize
)
self
.
_pshape
=
(
presize
,
self
.
_dofdex
.
size
,
postsize
)
...
...
src/operators/regridding_operator.py
View file @
0236e1cc
...
...
@@ -66,7 +66,7 @@ class RegriddingOperator(LinearOperator):
self
.
_frac
=
[
None
]
*
ndim
for
d
in
range
(
ndim
):
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
.
int
64
))
self
.
_frac
[
d
]
=
tmp
-
self
.
_bindex
[
d
]
def
apply
(
self
,
x
,
mode
):
...
...
test/test_field.py
View file @
0236e1cc
...
...
@@ -286,7 +286,7 @@ def test_stdfunc():
f
=
ift
.
Field
.
full
(
s
,
27
)
assert_equal
(
f
.
val
,
27
)
assert_equal
(
f
.
shape
,
(
200
,))
assert_equal
(
f
.
dtype
,
int
)
assert_equal
(
f
.
dtype
,
np
.
int
64
)
fx
=
ift
.
full
(
f
.
domain
,
0
)
assert_equal
(
f
.
dtype
,
fx
.
dtype
)
assert_equal
(
f
.
shape
,
fx
.
shape
)
...
...
test/test_minimizers.py
View file @
0236e1cc
...
...
@@ -51,26 +51,27 @@ slow_minimizers = ['ift.SteepestDescent(IC)']
slow_minimizers
)
@
pmp
(
'space'
,
spaces
)
def
test_quadratic_minimization
(
minimizer
,
space
):
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
=
ift
.
DiagonalOperator
(
covariance_diagonal
)
required_result
=
ift
.
full
(
space
,
1.
)
try
:
minimizer
=
eval
(
minimizer
)
energy
=
ift
.
QuadraticEnergy
(
A
=
covariance
,
b
=
required_result
,
position
=
starting_point
)
(
energy
,
convergence
)
=
minimizer
(
energy
)
except
NotImplementedError
:
pytest
.
skip
()
assert_equal
(
convergence
,
IC
.
CONVERGED
)
assert_allclose
(
energy
.
position
.
val
,
1.
/
covariance_diagonal
.
val
,
rtol
=
1e-3
,
atol
=
1e-3
)
with
ift
.
random
.
Context
(
98765
):
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
=
ift
.
DiagonalOperator
(
covariance_diagonal
)
required_result
=
ift
.
full
(
space
,
1.
)
try
:
minimizer
=
eval
(
minimizer
)
energy
=
ift
.
QuadraticEnergy
(
A
=
covariance
,
b
=
required_result
,
position
=
starting_point
)
(
energy
,
convergence
)
=
minimizer
(
energy
)
except
NotImplementedError
:
pytest
.
skip
()
assert_equal
(
convergence
,
IC
.
CONVERGED
)
assert_allclose
(
energy
.
position
.
val
,
1.
/
covariance_diagonal
.
val
,
rtol
=
1e-3
,
atol
=
1e-3
)
@
pmp
(
'space'
,
spaces
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment