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
Michiel Cottaar
fslpy
Commits
e1fcb14b
Commit
e1fcb14b
authored
Jul 15, 2017
by
Paul McCarthy
🚵
Browse files
Expanded test for scaleoffsetxform
parent
5003e83e
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/test_transform.py
View file @
e1fcb14b
...
...
@@ -92,6 +92,7 @@ def test_concat():
def
test_scaleOffsetXform
():
# Test numerically
testfile
=
op
.
join
(
datadir
,
'test_transform_test_scaleoffsetxform.txt'
)
lines
=
readlines
(
testfile
)
ntests
=
len
(
lines
)
//
5
...
...
@@ -108,11 +109,51 @@ def test_scaleOffsetXform():
expected
=
[[
float
(
v
)
for
v
in
l
.
split
()]
for
l
in
expected
]
expected
=
np
.
array
(
expected
)
result1
=
transform
.
scaleOffsetXform
(
scales
,
offsets
)
result2
=
transform
.
scaleOffsetXform
(
tuple
(
scales
),
tuple
(
offsets
))
result
=
transform
.
scaleOffsetXform
(
scales
,
offsets
)
assert
np
.
all
(
np
.
isclose
(
result
,
expected
))
# Test that different input types work:
# - scalars
# - lists/tuples of length <= 3
# - numpy arrays
a
=
np
.
array
stests
=
[
(
5
,
[
5
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
]),
([
5
],
[
5
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
]),
((
5
,),
[
5
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
]),
(
a
([
5
]),
[
5
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
]),
([
5
,
6
],
[
5
,
0
,
0
,
0
,
0
,
6
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,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7
,
0
,
0
,
0
,
1
]),
((
5
,
6
,
7
),
[
1
,
0
,
0
,
5
,
0
,
1
,
0
,
6
,
0
,
0
,
1
,
7
,
0
,
0
,
0
,
1
]),
(
a
([
5
,
6
,
7
]),
[
1
,
0
,
0
,
5
,
0
,
1
,
0
,
6
,
0
,
0
,
1
,
7
,
0
,
0
,
0
,
1
]),
]
for
(
scale
,
expected
)
in
stests
:
expected
=
np
.
array
(
expected
).
reshape
(
4
,
4
)
result
=
transform
.
scaleOffsetXform
(
scale
,
0
)
assert
np
.
all
(
np
.
isclose
(
result
,
expected
))
for
(
offset
,
expected
)
in
otests
:
expected
=
np
.
array
(
expected
).
reshape
(
4
,
4
)
result
=
transform
.
scaleOffsetXform
(
1
,
offset
)
assert
np
.
all
(
np
.
isclose
(
result
,
expected
))
assert
np
.
all
(
np
.
isclose
(
result1
,
expected
))
assert
np
.
all
(
np
.
isclose
(
result2
,
expected
))
def
test_compose_and_decompose
():
...
...
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