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
ift
NIFTy
Commits
7eee74d8
Commit
7eee74d8
authored
Feb 04, 2018
by
Philipp Arras
Browse files
Move it
parent
b4bf88f6
Pipeline
#24361
failed with stage
in 4 minutes
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty4/__init__.py
View file @
7eee74d8
...
...
@@ -53,6 +53,7 @@ from .minimization.line_energy import LineEnergy
from
.sugar
import
*
from
.plotting.plot
import
plot
from
.
import
library
from
.
import
extra
__all__
=
[
"Domain"
,
"UnstructuredDomain"
,
"StructuredDomain"
,
"RGSpace"
,
"LMSpace"
,
"HPSpace"
,
"GLSpace"
,
"DOFSpace"
,
"PowerSpace"
,
"DomainTuple"
,
...
...
nifty4/extra/__init__.py
0 → 100644
View file @
7eee74d8
from
.test_helpers
import
test_adjointness
,
test_inverse
nifty4/extra/test_helpers.py
0 → 100644
View file @
7eee74d8
import
numpy
as
np
from
..field
import
Field
__all__
=
[
'test_adjointness'
,
'test_inverse'
]
def
test_adjointness
(
self
,
domain_dtype
=
np
.
float64
,
target_dtype
=
np
.
float64
,
atol
=
0
,
rtol
=
1e-7
):
f1
=
Field
.
from_random
(
"normal"
,
domain
=
self
.
domain
,
dtype
=
domain_dtype
)
f2
=
Field
.
from_random
(
"normal"
,
domain
=
self
.
target
,
dtype
=
target_dtype
)
res1
=
f1
.
vdot
(
self
.
adjoint_times
(
f2
))
res2
=
self
.
times
(
f1
).
vdot
(
f2
)
np
.
testing
.
assert_allclose
(
res1
,
res2
,
atol
=
atol
,
rtol
=
rtol
)
# Return relative error
return
(
res1
-
res2
)
/
(
res1
+
res2
)
*
2
def
test_inverse
(
self
,
dtype_domain
=
np
.
float64
,
dtype_target
=
np
.
float64
,
atol
=
0
,
rtol
=
1e-7
):
foo
=
Field
.
from_random
(
domain
=
self
.
target
,
random_type
=
'normal'
,
dtype
=
dtype_target
)
res
=
self
.
times
(
self
.
inverse_times
(
foo
)).
val
ones
=
Field
.
ones
(
self
.
domain
).
val
np
.
testing
.
assert_allclose
(
res
,
ones
,
atol
=
atol
,
rtol
=
rtol
)
foo
=
Field
.
from_random
(
domain
=
self
.
domain
,
random_type
=
'normal'
,
dtype
=
dtype_domain
)
res
=
self
.
inverse_times
(
self
.
times
(
foo
)).
val
ones
=
Field
.
ones
(
self
.
target
).
val
np
.
testing
.
assert_allclose
(
res
,
ones
,
atol
=
atol
,
rtol
=
rtol
)
# Return relative error
return
(
res
-
ones
)
/
(
res
+
ones
)
*
2
nifty4/operators/linear_operator.py
View file @
7eee74d8
...
...
@@ -164,30 +164,3 @@ class LinearOperator(with_metaclass(
raise
ValueError
(
"The operator's and and field's domains "
"don't match."
)
def
test_adjointness
(
self
,
domain_dtype
=
np
.
float64
,
target_dtype
=
np
.
float64
,
atol
=
0
,
rtol
=
1e-7
):
f1
=
Field
.
from_random
(
"normal"
,
domain
=
self
.
domain
,
dtype
=
domain_dtype
)
f2
=
Field
.
from_random
(
"normal"
,
domain
=
self
.
target
,
dtype
=
target_dtype
)
res1
=
f1
.
vdot
(
self
.
adjoint_times
(
f2
))
res2
=
self
.
times
(
f1
).
vdot
(
f2
)
np
.
testing
.
assert_allclose
(
res1
,
res2
,
atol
=
atol
,
rtol
=
rtol
)
# Return relative error
return
(
res1
-
res2
)
/
(
res1
+
res2
)
*
2
def
test_inverse
(
self
,
dtype_domain
=
np
.
float64
,
dtype_target
=
np
.
float64
,
atol
=
0
,
rtol
=
1e-7
):
foo
=
Field
.
from_random
(
domain
=
self
.
target
,
random_type
=
'normal'
,
dtype
=
dtype_target
)
res
=
self
.
times
(
self
.
inverse_times
(
foo
)).
val
ones
=
Field
.
ones
(
self
.
domain
).
val
np
.
testing
.
assert_allclose
(
res
,
ones
,
atol
=
atol
,
rtol
=
rtol
)
foo
=
Field
.
from_random
(
domain
=
self
.
domain
,
random_type
=
'normal'
,
dtype
=
dtype_domain
)
res
=
self
.
inverse_times
(
self
.
times
(
foo
)).
val
ones
=
Field
.
ones
(
self
.
target
).
val
np
.
testing
.
assert_allclose
(
res
,
ones
,
atol
=
atol
,
rtol
=
rtol
)
# Return relative error
return
(
res
-
ones
)
/
(
res
+
ones
)
*
2
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