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
f82b084e
Commit
f82b084e
authored
Mar 22, 2020
by
Martin Reinecke
Browse files
make sure that the RNG is in a reproducible state for every single test
parent
9020c956
Pipeline
#71181
passed with stages
in 16 minutes and 58 seconds
Changes
32
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
test/common.py
View file @
f82b084e
...
...
@@ -11,7 +11,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-20
19
Max-Planck-Society
# Copyright(C) 2013-20
20
Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
...
...
@@ -24,3 +24,13 @@ def list2fixture(lst):
return
request
.
param
return
myfixture
def
setup_function
():
import
nifty6
as
ift
ift
.
random
.
push_sseq_from_seed
(
42
)
def
teardown_function
():
import
nifty6
as
ift
ift
.
random
.
pop_sseq
()
test/test_energy_gradients.py
View file @
f82b084e
...
...
@@ -11,7 +11,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-20
19
Max-Planck-Society
# Copyright(C) 2013-20
20
Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
...
...
@@ -20,6 +20,7 @@ import pytest
import
nifty6
as
ift
from
itertools
import
product
from
.common
import
setup_function
,
teardown_function
# Currently it is not possible to parametrize fixtures. But this will
# hopefully be fixed in the future.
...
...
@@ -124,11 +125,9 @@ def testPoissonian(field):
def
test_bernoulli
(
field
):
if
isinstance
(
field
.
domain
,
ift
.
MultiDomain
):
return
ift
.
random
.
push_sseq_from_seed
(
42
)
field
=
field
.
sigmoid
()
space
=
field
.
domain
d
=
ift
.
random
.
current_rng
().
binomial
(
1
,
0.1
,
size
=
space
.
shape
)
d
=
ift
.
Field
(
space
,
d
)
energy
=
ift
.
BernoulliEnergy
(
d
)
ift
.
extra
.
check_jacobian_consistency
(
energy
,
field
,
tol
=
1e-5
)
ift
.
random
.
pop_sseq
()
test/test_field.py
View file @
f82b084e
...
...
@@ -20,6 +20,7 @@ import pytest
from
numpy.testing
import
assert_allclose
,
assert_equal
,
assert_raises
import
nifty6
as
ift
from
.common
import
setup_function
,
teardown_function
pmp
=
pytest
.
mark
.
parametrize
SPACES
=
[
ift
.
RGSpace
((
4
,)),
ift
.
RGSpace
((
5
))]
...
...
test/test_gaussian_energy.py
View file @
f82b084e
...
...
@@ -19,6 +19,7 @@ import numpy as np
import
pytest
import
nifty6
as
ift
from
.common
import
setup_function
,
teardown_function
def
_flat_PS
(
k
):
...
...
test/test_kl.py
View file @
f82b084e
...
...
@@ -20,6 +20,7 @@ import numpy as np
import
nifty6
as
ift
from
numpy.testing
import
assert_
,
assert_allclose
import
pytest
from
.common
import
setup_function
,
teardown_function
pmp
=
pytest
.
mark
.
parametrize
...
...
test/test_linearization.py
View file @
f82b084e
...
...
@@ -20,6 +20,7 @@ import pytest
from
numpy.testing
import
assert_
,
assert_allclose
import
nifty6
as
ift
from
.common
import
setup_function
,
teardown_function
pmp
=
pytest
.
mark
.
parametrize
...
...
test/test_minimizers.py
View file @
f82b084e
...
...
@@ -22,6 +22,7 @@ import pytest
from
numpy.testing
import
assert_allclose
,
assert_equal
import
nifty6
as
ift
from
.common
import
setup_function
,
teardown_function
pmp
=
pytest
.
mark
.
parametrize
IC
=
ift
.
GradientNormController
(
tol_abs_gradnorm
=
1e-5
,
iteration_limit
=
1000
)
...
...
@@ -119,7 +120,6 @@ def test_rosenbrock(minimizer):
from
scipy.optimize
import
rosen
,
rosen_der
,
rosen_hess_prod
except
ImportError
:
raise
SkipTest
ift
.
random
.
push_sseq_from_seed
(
42
)
space
=
ift
.
DomainTuple
.
make
(
ift
.
UnstructuredDomain
((
2
,)))
starting_point
=
ift
.
Field
.
from_random
(
'normal'
,
domain
=
space
)
*
10
...
...
@@ -171,7 +171,6 @@ def test_rosenbrock(minimizer):
assert_equal
(
convergence
,
IC
.
CONVERGED
)
assert_allclose
(
energy
.
position
.
val
,
1.
,
rtol
=
1e-3
,
atol
=
1e-3
)
ift
.
random
.
pop_sseq
()
@
pmp
(
'minimizer'
,
minimizers
+
slow_minimizers
)
...
...
test/test_multi_field.py
View file @
f82b084e
...
...
@@ -19,6 +19,7 @@ import numpy as np
from
numpy.testing
import
assert_allclose
,
assert_equal
import
nifty6
as
ift
from
.common
import
setup_function
,
teardown_function
dom
=
ift
.
makeDomain
({
"d1"
:
ift
.
RGSpace
(
10
)})
...
...
test/test_operators/test_adjoint.py
View file @
f82b084e
...
...
@@ -20,7 +20,7 @@ import pytest
import
nifty6
as
ift
from
..common
import
list2fixture
from
..common
import
list2fixture
,
setup_function
,
teardown_function
_h_RG_spaces
=
[
ift
.
RGSpace
(
7
,
distances
=
0.2
,
harmonic
=
True
),
...
...
test/test_operators/test_composed_operator.py
View file @
f82b084e
...
...
@@ -19,7 +19,7 @@ from numpy.testing import assert_allclose, assert_equal
import
nifty6
as
ift
from
..common
import
list2fixture
from
..common
import
list2fixture
,
setup_function
,
teardown_function
space1
=
list2fixture
([
ift
.
RGSpace
(
4
),
...
...
test/test_operators/test_convolution_operators.py
View file @
f82b084e
...
...
@@ -20,7 +20,7 @@ from numpy.testing import assert_allclose
import
nifty6
as
ift
import
numpy
as
np
from
..common
import
list2fixture
from
..common
import
list2fixture
,
setup_function
,
teardown_function
space
=
list2fixture
([
ift
.
RGSpace
(
4
),
...
...
test/test_operators/test_correlated_fields.py
View file @
f82b084e
...
...
@@ -19,6 +19,7 @@ import pytest
from
numpy.testing
import
assert_allclose
import
nifty6
as
ift
from
..common
import
setup_function
,
teardown_function
@
pytest
.
mark
.
parametrize
(
'sspace'
,
[
...
...
test/test_operators/test_diagonal_operator.py
View file @
f82b084e
...
...
@@ -19,7 +19,7 @@ from numpy.testing import assert_allclose, assert_equal
import
nifty6
as
ift
from
..common
import
list2fixture
from
..common
import
list2fixture
,
setup_function
,
teardown_function
space
=
list2fixture
([
ift
.
RGSpace
(
4
),
...
...
test/test_operators/test_fft_operator.py
View file @
f82b084e
...
...
@@ -21,7 +21,7 @@ from numpy.testing import assert_, assert_allclose
import
nifty6
as
ift
from
..common
import
list2fixture
from
..common
import
list2fixture
,
setup_function
,
teardown_function
def
_get_rtol
(
tp
):
...
...
test/test_operators/test_harmonic_transform_operator.py
View file @
f82b084e
...
...
@@ -21,7 +21,7 @@ from numpy.testing import assert_allclose
import
nifty6
as
ift
from
..common
import
list2fixture
from
..common
import
list2fixture
,
setup_function
,
teardown_function
def
_get_rtol
(
tp
):
...
...
test/test_operators/test_interpolated.py
View file @
f82b084e
...
...
@@ -22,7 +22,7 @@ from scipy.stats import invgamma, norm
import
nifty6
as
ift
from
..common
import
list2fixture
from
..common
import
list2fixture
,
setup_function
,
teardown_function
pmp
=
pytest
.
mark
.
parametrize
pmp
=
pytest
.
mark
.
parametrize
...
...
test/test_operators/test_jacobian.py
View file @
f82b084e
...
...
@@ -20,7 +20,7 @@ import pytest
import
nifty6
as
ift
from
..common
import
list2fixture
from
..common
import
list2fixture
,
setup_function
,
teardown_function
pmp
=
pytest
.
mark
.
parametrize
space
=
list2fixture
([
...
...
test/test_operators/test_nft.py
View file @
f82b084e
...
...
@@ -20,6 +20,7 @@ import pytest
from
numpy.testing
import
assert_
import
nifty6
as
ift
from
..common
import
setup_function
,
teardown_function
pmp
=
pytest
.
mark
.
parametrize
...
...
test/test_operators/test_partial_multifield_insert.py
View file @
f82b084e
...
...
@@ -21,7 +21,7 @@ from numpy.testing import assert_, assert_allclose
import
nifty6
as
ift
from
..common
import
list2fixture
from
..common
import
list2fixture
,
setup_function
,
teardown_function
pmp
=
pytest
.
mark
.
parametrize
dtype
=
list2fixture
([
np
.
float64
,
np
.
float32
,
np
.
complex64
,
np
.
complex128
])
...
...
test/test_operators/test_regridding.py
View file @
f82b084e
...
...
@@ -19,7 +19,7 @@ from numpy.testing import assert_allclose
import
nifty6
as
ift
from
..common
import
list2fixture
from
..common
import
list2fixture
,
setup_function
,
teardown_function
s
=
list2fixture
([
ift
.
RGSpace
(
8
,
distances
=
12.9
),
...
...
Prev
1
2
Next
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