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
66ea2424
Commit
66ea2424
authored
Jan 23, 2019
by
Reimar H Leike
Browse files
added a few trivial tests of field.py
parent
f3302289
Changes
1
Hide whitespace changes
Inline
Side-by-side
test/test_field.py
View file @
66ea2424
...
@@ -199,12 +199,18 @@ def test_empty_domain():
...
@@ -199,12 +199,18 @@ def test_empty_domain():
def
test_trivialities
():
def
test_trivialities
():
s1
=
ift
.
RGSpace
((
10
,))
s1
=
ift
.
RGSpace
((
10
,))
f1
=
ift
.
Field
.
full
(
s1
,
27
)
f1
=
ift
.
Field
.
full
(
s1
,
27
)
assert_equal
(
f1
.
clip
(
min
=
29
).
local_data
,
29.
)
assert_equal
(
f1
.
clip
(
max
=
25
).
local_data
,
25.
)
assert_equal
(
f1
.
local_data
,
f1
.
real
.
local_data
)
assert_equal
(
f1
.
local_data
,
f1
.
real
.
local_data
)
assert_equal
(
f1
.
local_data
,
(
+
f1
).
local_data
)
print
(
f1
)
print
(
str
(
f1
))
f1
=
ift
.
Field
.
full
(
s1
,
27.
+
3j
)
f1
=
ift
.
Field
.
full
(
s1
,
27.
+
3j
)
assert_equal
(
f1
.
one_over
().
local_data
,
(
1.
/
f1
).
local_data
)
assert_equal
(
f1
.
real
.
local_data
,
27.
)
assert_equal
(
f1
.
real
.
local_data
,
27.
)
assert_equal
(
f1
.
imag
.
local_data
,
3.
)
assert_equal
(
f1
.
imag
.
local_data
,
3.
)
assert_equal
(
f1
.
local_data
,
+
f1
.
local_data
)
assert_equal
(
f1
.
sum
(),
f1
.
sum
(
0
))
assert_equal
(
f1
.
sum
(),
f1
.
sum
(
0
))
assert_equal
(
f1
.
conjugate
().
local_data
,
ift
.
Field
.
full
(
s1
,
27.
-
3j
).
local_data
)
f1
=
ift
.
from_global_data
(
s1
,
np
.
arange
(
10
))
f1
=
ift
.
from_global_data
(
s1
,
np
.
arange
(
10
))
# assert_equal(f1.min(), 0)
# assert_equal(f1.min(), 0)
# assert_equal(f1.max(), 9)
# assert_equal(f1.max(), 9)
...
@@ -266,6 +272,17 @@ def test_err():
...
@@ -266,6 +272,17 @@ def test_err():
f1
.
vdot
(
ift
.
Field
.
full
(
s2
,
1.
))
f1
.
vdot
(
ift
.
Field
.
full
(
s2
,
1.
))
with
assert_raises
(
TypeError
):
with
assert_raises
(
TypeError
):
ift
.
full
(
s1
,
[
2
,
3
])
ift
.
full
(
s1
,
[
2
,
3
])
with
assert_raises
(
TypeError
):
ift
.
from_global_data
(
s2
,
[
0
,
1
])
with
assert_raises
(
TypeError
):
f1
.
outer
([
0
,
1
])
with
assert_raises
(
ValueError
):
f1
.
extract
(
s2
)
with
assert_raises
(
TypeError
):
f1
+=
f1
f2
=
ift
.
Field
.
full
(
s2
,
27
)
with
assert_raises
(
ValueError
):
f1
+
f2
def
test_stdfunc
():
def
test_stdfunc
():
...
...
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