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
FSL
fslpy
Commits
aba4d605
Commit
aba4d605
authored
Jul 25, 2017
by
Paul McCarthy
🚵
Browse files
Unit tests for new transform functions
parent
b65a61b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/test_transform.py
View file @
aba4d605
...
...
@@ -392,3 +392,35 @@ def test_sformToFlirtMatrix():
assert
np
.
all
(
np
.
isclose
(
result1
,
expected
))
assert
np
.
all
(
np
.
isclose
(
result2
,
expected
))
def
test_normalise
(
seed
):
vectors
=
-
100
+
200
*
np
.
random
.
random
((
50
,
3
))
def
parallel
(
v1
,
v2
):
v1
=
v1
/
transform
.
veclength
(
v1
)
v2
=
v2
/
transform
.
veclength
(
v2
)
return
np
.
isclose
(
np
.
dot
(
v1
,
v2
),
1
)
for
v
in
vectors
:
vn
=
transform
.
normalise
(
v
)
vl
=
transform
.
veclength
(
vn
)
assert
np
.
isclose
(
vl
,
1.0
)
assert
parallel
(
v
,
vn
)
def
test_veclength
(
seed
):
def
l
(
v
):
x
,
y
,
z
=
v
l
=
x
*
x
+
y
*
y
+
z
*
z
return
np
.
sqrt
(
l
)
vectors
=
-
100
+
200
*
np
.
random
.
random
((
50
,
3
))
for
v
in
vectors
:
assert
np
.
isclose
(
transform
.
veclength
(
v
),
l
(
v
))
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