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
735e5757
Commit
735e5757
authored
Jul 01, 2020
by
Philipp Arras
Browse files
Do not use deprecated numpy.assert_ any more
parent
31843af9
Changes
19
Hide whitespace changes
Inline
Side-by-side
src/__init__.py
View file @
735e5757
...
...
@@ -92,7 +92,7 @@ from .library.correlated_fields_simple import SimpleCorrelatedField
from
.
import
extra
from
.utilities
import
memo
,
frozendict
from
.utilities
import
memo
,
frozendict
,
myassert
from
.logger
import
logger
...
...
src/extra.py
View file @
735e5757
...
...
@@ -18,7 +18,6 @@
from
itertools
import
combinations
import
numpy
as
np
from
numpy.testing
import
assert_
from
.domain_tuple
import
DomainTuple
from
.field
import
Field
...
...
@@ -29,6 +28,7 @@ from .operators.energy_operators import EnergyOperator
from
.operators.linear_operator
import
LinearOperator
from
.operators.operator
import
Operator
from
.sugar
import
from_random
from
.utilities
import
myassert
__all__
=
[
"check_linear_operator"
,
"check_operator"
,
"assert_allclose"
]
...
...
@@ -137,20 +137,6 @@ def assert_equal(f1, f2):
assert_equal
(
val
,
f2
[
key
])
def
_nozero
(
fld
):
if
isinstance
(
fld
,
Field
):
return
np
.
testing
.
assert_
((
fld
!=
0
).
s_all
())
for
val
in
fld
.
values
():
_nozero
(
val
)
def
_allzero
(
fld
):
if
isinstance
(
fld
,
Field
):
return
np
.
testing
.
assert_
((
fld
==
0.
).
s_all
())
for
val
in
fld
.
values
():
_allzero
(
val
)
def
_adjoint_implementation
(
op
,
domain_dtype
,
target_dtype
,
atol
,
rtol
,
only_r_linear
):
needed_cap
=
op
.
TIMES
|
op
.
ADJOINT_TIMES
...
...
@@ -206,32 +192,32 @@ def _domain_check_linear(op, domain_dtype=None, inp=None):
inp
=
from_random
(
op
.
domain
,
"normal"
,
dtype
=
domain_dtype
)
elif
inp
is
None
:
raise
ValueError
(
'Need to specify either dtype or inp'
)
assert
_
(
inp
.
domain
is
op
.
domain
)
assert
_
(
op
(
inp
).
domain
is
op
.
target
)
my
assert
(
inp
.
domain
is
op
.
domain
)
my
assert
(
op
(
inp
).
domain
is
op
.
target
)
def
_domain_check_nonlinear
(
op
,
loc
):
_domain_check
(
op
)
assert
_
(
isinstance
(
loc
,
(
Field
,
MultiField
)))
assert
_
(
loc
.
domain
is
op
.
domain
)
my
assert
(
isinstance
(
loc
,
(
Field
,
MultiField
)))
my
assert
(
loc
.
domain
is
op
.
domain
)
for
wm
in
[
False
,
True
]:
lin
=
Linearization
.
make_var
(
loc
,
wm
)
reslin
=
op
(
lin
)
assert
_
(
lin
.
domain
is
op
.
domain
)
assert
_
(
lin
.
target
is
op
.
domain
)
assert
_
(
lin
.
val
.
domain
is
lin
.
domain
)
assert
_
(
reslin
.
domain
is
op
.
domain
)
assert
_
(
reslin
.
target
is
op
.
target
)
assert
_
(
reslin
.
val
.
domain
is
reslin
.
target
)
assert
_
(
reslin
.
target
is
op
.
target
)
assert
_
(
reslin
.
jac
.
domain
is
reslin
.
domain
)
assert
_
(
reslin
.
jac
.
target
is
reslin
.
target
)
assert
_
(
lin
.
want_metric
==
reslin
.
want_metric
)
my
assert
(
lin
.
domain
is
op
.
domain
)
my
assert
(
lin
.
target
is
op
.
domain
)
my
assert
(
lin
.
val
.
domain
is
lin
.
domain
)
my
assert
(
reslin
.
domain
is
op
.
domain
)
my
assert
(
reslin
.
target
is
op
.
target
)
my
assert
(
reslin
.
val
.
domain
is
reslin
.
target
)
my
assert
(
reslin
.
target
is
op
.
target
)
my
assert
(
reslin
.
jac
.
domain
is
reslin
.
domain
)
my
assert
(
reslin
.
jac
.
target
is
reslin
.
target
)
my
assert
(
lin
.
want_metric
==
reslin
.
want_metric
)
_domain_check_linear
(
reslin
.
jac
,
inp
=
loc
)
_domain_check_linear
(
reslin
.
jac
.
adjoint
,
inp
=
reslin
.
jac
(
loc
))
if
reslin
.
metric
is
not
None
:
assert
_
(
reslin
.
metric
.
domain
is
reslin
.
metric
.
target
)
assert
_
(
reslin
.
metric
.
domain
is
op
.
domain
)
my
assert
(
reslin
.
metric
.
domain
is
reslin
.
metric
.
target
)
my
assert
(
reslin
.
metric
.
domain
is
op
.
domain
)
def
_domain_check
(
op
):
...
...
src/utilities.py
View file @
735e5757
...
...
@@ -405,3 +405,10 @@ def lognormal_moments(mean, sigma, N=0):
logsigma
=
np
.
sqrt
(
np
.
log1p
((
sigma
/
mean
)
**
2
))
logmean
=
np
.
log
(
mean
)
-
logsigma
**
2
/
2
return
logmean
,
logsigma
def
myassert
(
val
):
"""Safe alternative to python's assert statement which is active even if
`__debug__` is False."""
if
not
val
:
raise
AssertionError
test/test_kl.py
View file @
735e5757
...
...
@@ -17,9 +17,10 @@
import
numpy
as
np
import
pytest
from
numpy.testing
import
assert_
,
assert_allclose
,
assert_raises
from
numpy.testing
import
assert_allclose
,
assert_raises
import
nifty7
as
ift
from
nifty7
import
myassert
from
.common
import
setup_function
,
teardown_function
...
...
@@ -55,13 +56,13 @@ def test_kl(constants, point_estimates, mirror_samples, mf):
ift
.
MetricGaussianKL
.
make
(
**
args
)
return
kl
=
ift
.
MetricGaussianKL
.
make
(
**
args
)
assert
_
(
len
(
ic
.
history
)
>
0
)
assert
_
(
len
(
ic
.
history
)
==
len
(
ic
.
history
.
time_stamps
))
assert
_
(
len
(
ic
.
history
)
==
len
(
ic
.
history
.
energy_values
))
my
assert
(
len
(
ic
.
history
)
>
0
)
my
assert
(
len
(
ic
.
history
)
==
len
(
ic
.
history
.
time_stamps
))
my
assert
(
len
(
ic
.
history
)
==
len
(
ic
.
history
.
energy_values
))
ic
.
history
.
reset
()
assert
_
(
len
(
ic
.
history
)
==
0
)
assert
_
(
len
(
ic
.
history
)
==
len
(
ic
.
history
.
time_stamps
))
assert
_
(
len
(
ic
.
history
)
==
len
(
ic
.
history
.
energy_values
))
my
assert
(
len
(
ic
.
history
)
==
0
)
my
assert
(
len
(
ic
.
history
)
==
len
(
ic
.
history
.
time_stamps
))
my
assert
(
len
(
ic
.
history
)
==
len
(
ic
.
history
.
energy_values
))
locsamp
=
kl
.
_local_samples
if
isinstance
(
mean0
,
ift
.
MultiField
):
...
...
@@ -74,7 +75,7 @@ def test_kl(constants, point_estimates, mirror_samples, mf):
# Test number of samples
expected_nsamps
=
2
*
nsamps
if
mirror_samples
else
nsamps
assert
_
(
len
(
tuple
(
kl
.
samples
))
==
expected_nsamps
)
my
assert
(
len
(
tuple
(
kl
.
samples
))
==
expected_nsamps
)
# Test value
assert_allclose
(
kl
.
value
,
klpure
.
value
)
...
...
test/test_linearization.py
View file @
735e5757
...
...
@@ -17,7 +17,7 @@
import
numpy
as
np
import
pytest
from
numpy.testing
import
assert_
,
assert_allclose
from
numpy.testing
import
assert_allclose
import
nifty7
as
ift
from
.common
import
setup_function
,
teardown_function
...
...
@@ -44,7 +44,7 @@ def test_special_gradients():
assert_allclose
(
_lin2grad
(
ift
.
Linearization
.
make_var
(
0
*
f
).
ptw
(
"sinc"
)),
np
.
zeros
(
s
.
shape
))
assert
_
(
np
.
isnan
(
_lin2grad
(
ift
.
Linearization
.
make_var
(
0
*
f
).
ptw
(
"abs"
))))
ift
.
my
assert
(
np
.
isnan
(
_lin2grad
(
ift
.
Linearization
.
make_var
(
0
*
f
).
ptw
(
"abs"
))))
assert_allclose
(
_lin2grad
(
ift
.
Linearization
.
make_var
(
0
*
f
+
10
).
ptw
(
"abs"
)),
np
.
ones
(
s
.
shape
))
...
...
test/test_mpi/test_kl.py
View file @
735e5757
...
...
@@ -18,7 +18,7 @@
import
numpy
as
np
import
pytest
from
mpi4py
import
MPI
from
numpy.testing
import
assert_
,
assert_equal
,
assert_raises
from
numpy.testing
import
assert_equal
,
assert_raises
import
nifty7
as
ift
...
...
@@ -84,8 +84,8 @@ def test_kl(constants, point_estimates, mirror_samples, mode, mf):
# Test number of samples
expected_nsamps
=
2
*
nsamps
if
mirror_samples
else
nsamps
assert
_
(
len
(
tuple
(
kl0
.
samples
))
==
expected_nsamps
)
assert
_
(
len
(
tuple
(
kl1
.
samples
))
==
expected_nsamps
)
ift
.
my
assert
(
len
(
tuple
(
kl0
.
samples
))
==
expected_nsamps
)
ift
.
my
assert
(
len
(
tuple
(
kl1
.
samples
))
==
expected_nsamps
)
# Test value
assert_equal
(
kl0
.
value
,
kl1
.
value
)
...
...
test/test_operator_tree_optimiser.py
View file @
735e5757
...
...
@@ -16,14 +16,16 @@
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
from
numpy.testing
import
assert_
,
assert_allclose
import
numpy
as
np
from
copy
import
deepcopy
import
numpy
as
np
from
numpy.testing
import
assert_allclose
import
nifty7
as
ift
class
CountingOp
(
ift
.
Operator
):
#FIXME: Not a LinearOperator since ChainOps not supported yet
#
FIXME: Not a LinearOperator since ChainOps not supported yet
def
__init__
(
self
,
domain
):
self
.
_domain
=
self
.
_target
=
ift
.
sugar
.
makeDomain
(
domain
)
self
.
_count
=
0
...
...
@@ -56,6 +58,6 @@ def test_operator_tree_optimiser():
op_orig
=
deepcopy
(
op
)
op
=
ift
.
operator_tree_optimiser
.
_optimise_operator
(
op
)
assert_allclose
(
op
(
fld
).
val
,
op_orig
(
fld
).
val
,
rtol
=
np
.
finfo
(
np
.
float64
).
eps
)
assert
_
(
1
==
(
(
cop4
.
count
-
1
)
*
cop3
.
count
*
cop2
.
count
*
cop1
.
count
))
ift
.
my
assert
(
1
==
((
cop4
.
count
-
1
)
*
cop3
.
count
*
cop2
.
count
*
cop1
.
count
))
# test testing
ift
.
optimise_operator
(
op_orig
)
test/test_operators/test_einsum.py
View file @
735e5757
...
...
@@ -17,10 +17,10 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
import
numpy
as
np
from
numpy.testing
import
assert_
,
assert_allclose
from
numpy.testing
import
assert_allclose
import
nifty7
as
ift
from
nifty7.extra
import
check_operator
,
check_
linear_
operator
from
nifty7.extra
import
check_
linear_
operator
,
check_operator
from
..common
import
list2fixture
,
setup_function
,
teardown_function
...
...
@@ -42,7 +42,7 @@ def test_linear_einsum_outer(space1, space2, dtype, n_invocations=10):
ss
=
"i,ij,j->ij"
key_order
=
(
"dom01"
,
"dom02"
)
le
=
ift
.
LinearEinsum
(
space2
,
mf
,
ss
,
key_order
=
key_order
)
assert
_
(
check_linear_operator
(
le
,
domain_dtype
=
dtype
,
target_dtype
=
dtype
)
is
None
)
ift
.
my
assert
(
check_linear_operator
(
le
,
domain_dtype
=
dtype
,
target_dtype
=
dtype
)
is
None
)
le_ift
=
ift
.
DiagonalOperator
(
mf
[
"dom01"
],
domain
=
mf_dom
[
"dom02"
],
spaces
=
0
)
@
ift
.
DiagonalOperator
(
mf
[
"dom02"
])
le_ift
=
le_ift
@
ift
.
OuterProduct
(
ift
.
DomainTuple
.
make
(
mf_dom
[
"dom02"
][
1
]),
...
...
@@ -63,7 +63,7 @@ def test_linear_einsum_contraction(space1, space2, dtype, n_invocations=10):
ss
=
"i,ij,j->i"
key_order
=
(
"dom01"
,
"dom02"
)
le
=
ift
.
LinearEinsum
(
space2
,
mf
,
ss
,
key_order
=
key_order
)
assert
_
(
check_linear_operator
(
le
,
domain_dtype
=
dtype
,
target_dtype
=
dtype
)
is
None
)
ift
.
my
assert
(
check_linear_operator
(
le
,
domain_dtype
=
dtype
,
target_dtype
=
dtype
)
is
None
)
le_ift
=
ift
.
ContractionOperator
(
mf_dom
[
"dom02"
],
1
)
le_ift
=
le_ift
@
ift
.
DiagonalOperator
(
mf
[
"dom01"
],
domain
=
mf_dom
[
"dom02"
],
spaces
=
0
)
...
...
@@ -116,7 +116,7 @@ def test_linear_einsum_transpose(space1, space2, dtype, n_invocations=10):
mf
=
ift
.
MultiField
.
from_dict
({})
ss
=
"ij->ji"
le
=
ift
.
LinearEinsum
(
dom
,
mf
,
ss
)
assert
_
(
check_linear_operator
(
le
,
domain_dtype
=
dtype
,
target_dtype
=
dtype
)
is
None
)
ift
.
my
assert
(
check_linear_operator
(
le
,
domain_dtype
=
dtype
,
target_dtype
=
dtype
)
is
None
)
# SwitchSpacesOperator is equivalent to LinearEinsum with "ij->ji"
le_ift
=
_SwitchSpacesOperator
(
dom
,
1
)
...
...
test/test_operators/test_fft_operator.py
View file @
735e5757
...
...
@@ -17,7 +17,7 @@
import
numpy
as
np
import
pytest
from
numpy.testing
import
assert_
,
assert_allclose
from
numpy.testing
import
assert_allclose
import
nifty7
as
ift
...
...
@@ -63,7 +63,7 @@ def test_fft1D(d, dtype, op):
@
pmp
(
'nthreads'
,
[
-
1
,
1
,
2
,
3
,
4
])
def
test_fft2D
(
dim1
,
dim2
,
d1
,
d2
,
dtype
,
op
,
nthreads
):
ift
.
fft
.
set_nthreads
(
nthreads
)
assert
_
(
ift
.
fft
.
nthreads
()
==
nthreads
)
ift
.
my
assert
(
ift
.
fft
.
nthreads
()
==
nthreads
)
tol
=
_get_rtol
(
dtype
)
a
=
ift
.
RGSpace
([
dim1
,
dim2
],
distances
=
[
d1
,
d2
])
b
=
ift
.
RGSpace
(
...
...
test/test_operators/test_nft.py
View file @
735e5757
...
...
@@ -17,9 +17,9 @@
import
numpy
as
np
import
pytest
from
numpy.testing
import
assert_
import
nifty7
as
ift
from
..common
import
setup_function
,
teardown_function
pmp
=
pytest
.
mark
.
parametrize
...
...
@@ -57,7 +57,7 @@ def test_gridding(nu, nv, N, eps):
for
i
in
range
(
N
):
dft
+=
(
vis
[
i
]
*
np
.
exp
(
2j
*
np
.
pi
*
(
x
*
uv
[
i
,
0
]
*
dstx
+
y
*
uv
[
i
,
1
]
*
dsty
))).
real
assert
_
(
_l2error
(
dft
,
pynu
)
<
eps
)
ift
.
my
assert
(
_l2error
(
dft
,
pynu
)
<
eps
)
def
test_cartesian
():
...
...
test/test_operators/test_partial_multifield_insert.py
View file @
735e5757
...
...
@@ -17,7 +17,7 @@
import
numpy
as
np
import
pytest
from
numpy.testing
import
assert_
,
assert_allclose
from
numpy.testing
import
assert_allclose
import
nifty7
as
ift
...
...
@@ -40,9 +40,9 @@ def test_part_mf_insert():
op
=
a
.
partial_insert
(
b
)
fld
=
ift
.
from_random
(
op
.
domain
,
'normal'
)
ift
.
extra
.
check_operator
(
op
,
fld
,
ntries
=
ntries
)
assert
_
(
op
.
domain
is
ift
.
MultiDomain
.
union
(
ift
.
my
assert
(
op
.
domain
is
ift
.
MultiDomain
.
union
(
[
op1
.
domain
,
op2
.
domain
,
op4
.
domain
,
op5
.
domain
]))
assert
_
(
op
.
target
is
ift
.
MultiDomain
.
union
(
ift
.
my
assert
(
op
.
target
is
ift
.
MultiDomain
.
union
(
[
op1
.
target
,
op2
.
target
,
op3
.
target
,
op5
.
target
]))
x
,
y
=
fld
.
val
,
op
(
fld
).
val
assert_allclose
(
y
[
'a1'
],
x
[
'a'
]
*
1.32
)
...
...
test/test_operators/test_simplification.py
View file @
735e5757
...
...
@@ -15,7 +15,7 @@
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
from
numpy.testing
import
assert_
,
assert_allclose
,
assert_raises
from
numpy.testing
import
assert_allclose
,
assert_raises
import
nifty7
as
ift
from
nifty7.operators.simplify_for_const
import
ConstantOperator
...
...
@@ -26,7 +26,7 @@ def test_simplification():
f1
=
ift
.
full
(
dom
,
2.
)
op
=
ift
.
FFTOperator
(
f1
.
domain
[
"a"
]).
ducktape
(
"a"
)
_
,
op2
=
op
.
simplify_for_constant_input
(
f1
)
assert
_
(
isinstance
(
op2
,
ConstantOperator
))
ift
.
my
assert
(
isinstance
(
op2
,
ConstantOperator
))
assert_allclose
(
op
(
f1
).
val
,
op2
.
force
(
f1
).
val
)
dom
=
{
"a"
:
ift
.
RGSpace
(
10
),
"b"
:
ift
.
RGSpace
(
5
)}
...
...
test/test_operators/test_value_inserter.py
View file @
735e5757
...
...
@@ -17,9 +17,9 @@
import
numpy
as
np
import
pytest
from
numpy.testing
import
assert_
import
nifty7
as
ift
from
..common
import
setup_function
,
teardown_function
...
...
@@ -38,5 +38,5 @@ def test_value_inserter(sp, seed):
f
=
ift
.
from_random
(
op
.
domain
,
'normal'
)
inp
=
f
.
val
ret
=
op
(
f
).
val
assert
_
(
ret
[
ind
]
==
inp
)
assert
_
(
np
.
sum
(
ret
)
==
inp
)
ift
.
my
assert
(
ret
[
ind
]
==
inp
)
ift
.
my
assert
(
np
.
sum
(
ret
)
==
inp
)
test/test_spaces/test_gl_space.py
View file @
735e5757
...
...
@@ -19,10 +19,10 @@ import itertools
import
numpy
as
np
import
pytest
from
numpy.testing
import
(
assert_
,
assert_almost_equal
,
assert_equal
,
assert_raises
)
from
numpy.testing
import
assert_almost_equal
,
assert_equal
,
assert_raises
from
nifty7
import
GLSpace
,
myassert
from
nifty7
import
GLSpace
from
..common
import
setup_function
,
teardown_function
pmp
=
pytest
.
mark
.
parametrize
...
...
@@ -56,7 +56,7 @@ def get_dvol_configs():
@
pmp
(
'attribute'
,
[
'nlat'
,
'nlon'
])
def
test_property_ret_type
(
attribute
):
g
=
GLSpace
(
2
)
assert
_
(
isinstance
(
getattr
(
g
,
attribute
),
int
))
my
assert
(
isinstance
(
getattr
(
g
,
attribute
),
int
))
@
pmp
(
'nlat, nlon, expected'
,
CONSTRUCTOR_CONFIGS
)
...
...
test/test_spaces/test_hp_space.py
View file @
735e5757
...
...
@@ -17,10 +17,10 @@
import
numpy
as
np
import
pytest
from
numpy.testing
import
(
assert_
,
assert_almost_equal
,
assert_equal
,
assert_raises
)
from
numpy.testing
import
assert_almost_equal
,
assert_equal
,
assert_raises
from
nifty7
import
HPSpace
,
myassert
from
nifty7
import
HPSpace
from
..common
import
setup_function
,
teardown_function
pmp
=
pytest
.
mark
.
parametrize
...
...
@@ -49,7 +49,7 @@ CONSTRUCTOR_CONFIGS = [[
def
test_property_ret_type
():
x
=
HPSpace
(
2
)
assert
_
(
isinstance
(
getattr
(
x
,
'nside'
),
int
))
my
assert
(
isinstance
(
getattr
(
x
,
'nside'
),
int
))
@
pmp
(
'nside, expected'
,
CONSTRUCTOR_CONFIGS
)
...
...
test/test_spaces/test_interface.py
View file @
735e5757
...
...
@@ -18,9 +18,9 @@
from
types
import
LambdaType
import
pytest
from
numpy.testing
import
assert_
import
nifty7
as
ift
from
..common
import
setup_function
,
teardown_function
pmp
=
pytest
.
mark
.
parametrize
...
...
@@ -36,7 +36,7 @@ pmp = pytest.mark.parametrize
ift
.
GLSpace
(
4
)
])
def
test_property_ret_type
(
space
,
attr_expected_type
):
assert
_
(
ift
.
my
assert
(
isinstance
(
getattr
(
space
,
attr_expected_type
[
0
]),
attr_expected_type
[
1
]))
...
...
@@ -46,7 +46,7 @@ def test_property_ret_type(space, attr_expected_type):
[
'get_fft_smoothing_kernel_function'
,
2.0
,
LambdaType
]])
@
pmp
(
'space'
,
[
ift
.
RGSpace
(
4
,
harmonic
=
True
),
ift
.
LMSpace
(
5
)])
def
test_method_ret_type
(
space
,
method_expected_type
):
assert
_
(
ift
.
my
assert
(
type
(
getattr
(
space
,
method_expected_type
[
0
])
(
*
method_expected_type
[
1
:
-
1
]))
is
method_expected_type
[
-
1
])
test/test_spaces/test_lm_space.py
View file @
735e5757
...
...
@@ -17,9 +17,10 @@
import
numpy
as
np
import
pytest
from
numpy.testing
import
assert_
,
assert_allclose
,
assert_equal
,
assert_raises
from
numpy.testing
import
assert_allclose
,
assert_equal
,
assert_raises
import
nifty7
as
ift
from
..common
import
setup_function
,
teardown_function
pmp
=
pytest
.
mark
.
parametrize
...
...
@@ -67,7 +68,7 @@ def get_k_length_array_configs():
@
pmp
(
'attribute'
,
[
'lmax'
,
'mmax'
,
'size'
])
def
test_property_ret_type
(
attribute
):
assert
_
(
isinstance
(
getattr
(
ift
.
LMSpace
(
7
,
5
),
attribute
),
int
))
ift
.
my
assert
(
isinstance
(
getattr
(
ift
.
LMSpace
(
7
,
5
),
attribute
),
int
))
@
pmp
(
'lmax, mmax, expected'
,
CONSTRUCTOR_CONFIGS
)
...
...
test/test_spaces/test_power_space.py
View file @
735e5757
...
...
@@ -19,9 +19,10 @@ from itertools import chain, product
import
numpy
as
np
import
pytest
from
numpy.testing
import
assert_
,
assert_allclose
,
assert_equal
,
assert_raises
from
numpy.testing
import
assert_allclose
,
assert_equal
,
assert_raises
import
nifty7
as
ift
from
..common
import
setup_function
,
teardown_function
pmp
=
pytest
.
mark
.
parametrize
...
...
@@ -104,7 +105,7 @@ def k_lengths_configs():
def
test_property_ret_type
(
attribute
,
expected_type
):
r
=
ift
.
RGSpace
((
4
,
4
),
harmonic
=
True
)
p
=
ift
.
PowerSpace
(
r
)
assert
_
(
isinstance
(
getattr
(
p
,
attribute
),
expected_type
))
ift
.
my
assert
(
isinstance
(
getattr
(
p
,
attribute
),
expected_type
))
@
pmp
(
'harmonic_partner, binbounds, nbin, logarithmic'
,
CONSISTENCY_CONFIGS
)
...
...
test/test_spaces/test_rg_space.py
View file @
735e5757
...
...
@@ -17,9 +17,10 @@
import
numpy
as
np
import
pytest
from
numpy.testing
import
assert_
,
assert_allclose
,
assert_equal
from
numpy.testing
import
assert_allclose
,
assert_equal
import
nifty7
as
ift
from
..common
import
setup_function
,
teardown_function
pmp
=
pytest
.
mark
.
parametrize
...
...
@@ -77,7 +78,7 @@ def get_dvol_configs():
@
pmp
(
'attribute, expected_type'
,
[[
'distances'
,
tuple
]])
def
test_property_ret_type
(
attribute
,
expected_type
):
x
=
ift
.
RGSpace
(
1
)
assert
_
(
isinstance
(
getattr
(
x
,
attribute
),
expected_type
))
ift
.
my
assert
(
isinstance
(
getattr
(
x
,
attribute
),
expected_type
))
@
pmp
(
'shape, distances, harmonic, expected'
,
CONSTRUCTOR_CONFIGS
)
...
...
Write
Preview
Supports
Markdown
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