Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
692f4322
Commit
692f4322
authored
May 06, 2021
by
Gordian Edenhofer
Browse files
Use python-native types in favor of numpy's
This resolves deprecation warnings in numpy>=1.2 .
parent
bc908a54
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/domains/gl_space.py
View file @
692f4322
...
...
@@ -59,11 +59,11 @@ class GLSpace(StructuredDomain):
@
property
def
shape
(
self
):
return
(
np
.
int
((
self
.
nlat
*
self
.
nlon
)),)
return
(
int
((
self
.
nlat
*
self
.
nlon
)),)
@
property
def
size
(
self
):
return
np
.
int
((
self
.
nlat
*
self
.
nlon
))
return
int
((
self
.
nlat
*
self
.
nlon
))
@
property
def
scalar_dvol
(
self
):
...
...
src/domains/hp_space.py
View file @
692f4322
...
...
@@ -53,7 +53,7 @@ class HPSpace(StructuredDomain):
@
property
def
size
(
self
):
return
np
.
int
(
12
*
self
.
nside
*
self
.
nside
)
return
int
(
12
*
self
.
nside
*
self
.
nside
)
@
property
def
scalar_dvol
(
self
):
...
...
src/domains/lm_space.py
View file @
692f4322
...
...
@@ -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
(
np
.
int
)
k_lengths
=
self
.
get_k_length_array
().
val
.
astype
(
int
)
return
Field
.
from_raw
(
self
,
kernel_lm
[
k_lengths
])
@
property
...
...
src/field.py
View file @
692f4322
...
...
@@ -259,7 +259,7 @@ class Field(Operator):
if
np
.
isscalar
(
wgt
):
fct
*=
wgt
else
:
new_shape
=
np
.
ones
(
len
(
self
.
shape
),
dtype
=
np
.
int
)
new_shape
=
np
.
ones
(
len
(
self
.
shape
),
dtype
=
int
)
new_shape
[
self
.
_domain
.
axes
[
ind
][
0
]:
self
.
_domain
.
axes
[
ind
][
-
1
]
+
1
]
=
wgt
.
shape
wgt
=
wgt
.
reshape
(
new_shape
)
...
...
src/library/los_response.py
View file @
692f4322
...
...
@@ -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
=
np
.
int
)
pos1
=
np
.
asarray
((
start
[:,
i
]
+
dmin
*
direction
),
dtype
=
int
)
pos1
=
np
.
sum
(
pos1
*
inc
)
cdist
=
np
.
empty
(
0
,
dtype
=
np
.
float64
)
add
=
np
.
empty
(
0
,
dtype
=
np
.
int
)
add
=
np
.
empty
(
0
,
dtype
=
int
)
for
j
in
range
(
ndim
):
if
direction
[
j
]
!=
0
:
step
=
inc
[
j
]
if
direction
[
j
]
>
0
else
-
inc
[
j
]
...
...
src/minimization/line_search.py
View file @
692f4322
...
...
@@ -138,8 +138,8 @@ class LineSearch(metaclass=NiftyMeta):
max_zoom_iterations
=
100
):
self
.
preferred_initial_step_size
=
preferred_initial_step_size
self
.
c1
=
np
.
float
(
c1
)
self
.
c2
=
np
.
float
(
c2
)
self
.
c1
=
float
(
c1
)
self
.
c2
=
float
(
c2
)
self
.
max_step_size
=
max_step_size
self
.
max_iterations
=
int
(
max_iterations
)
self
.
max_zoom_iterations
=
int
(
max_zoom_iterations
)
...
...
src/operators/distributors.py
View file @
692f4322
...
...
@@ -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
=
np
.
int
)
postsize
=
np
.
prod
(
arrshape
[
lastaxis
+
1
:],
dtype
=
np
.
int
)
presize
=
np
.
prod
(
arrshape
[
0
:
firstaxis
],
dtype
=
int
)
postsize
=
np
.
prod
(
arrshape
[
lastaxis
+
1
:],
dtype
=
int
)
self
.
_hshape
=
(
presize
,
self
.
_domain
[
self
.
_space
].
shape
[
0
],
postsize
)
self
.
_pshape
=
(
presize
,
self
.
_dofdex
.
size
,
postsize
)
...
...
src/operators/regridding_operator.py
View file @
692f4322
...
...
@@ -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
(
np
.
int
))
self
.
_bindex
[
d
]
=
np
.
minimum
(
dom
.
shape
[
d
]
-
2
,
tmp
.
astype
(
int
))
self
.
_frac
[
d
]
=
tmp
-
self
.
_bindex
[
d
]
def
apply
(
self
,
x
,
mode
):
...
...
test/test_field.py
View file @
692f4322
...
...
@@ -31,7 +31,7 @@ SPACE_COMBINATIONS = [(), SPACES[0], SPACES[1], SPACES]
@
pmp
(
'domain'
,
SPACE_COMBINATIONS
)
@
pmp
(
'attribute_desired_type'
,
[[
'domain'
,
ift
.
DomainTuple
],
[
'val'
,
np
.
ndarray
],
[
'shape'
,
tuple
],
[
'size'
,
(
np
.
int
,
np
.
int64
)]])
[
'shape'
,
tuple
],
[
'size'
,
(
int
,
np
.
int64
)]])
def
test_return_types
(
domain
,
attribute_desired_type
):
attribute
=
attribute_desired_type
[
0
]
desired_type
=
attribute_desired_type
[
1
]
...
...
@@ -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
,
np
.
int
)
assert_equal
(
f
.
dtype
,
int
)
fx
=
ift
.
full
(
f
.
domain
,
0
)
assert_equal
(
f
.
dtype
,
fx
.
dtype
)
assert_equal
(
f
.
shape
,
fx
.
shape
)
...
...
Gordian Edenhofer
@gedenhof
mentioned in merge request
!619 (merged)
·
May 17, 2021
mentioned in merge request
!619 (merged)
mentioned in merge request !619
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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