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
ac4abe63
Commit
ac4abe63
authored
Jul 20, 2020
by
Paul McCarthy
🚵
Browse files
TEST: Unit test for generateVest function
parent
e48b6ac2
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/test_vest.py
View file @
ac4abe63
...
...
@@ -7,6 +7,7 @@
import
os.path
as
op
import
io
import
shutil
import
tempfile
import
warnings
...
...
@@ -214,3 +215,36 @@ def test_loadVestLutFile():
finally
:
shutil
.
rmtree
(
testdir
)
def
test_generateVest
():
def
readvest
(
vstr
):
lines
=
vstr
.
split
(
'
\n
'
)
nrows
=
[
l
for
l
in
lines
if
'NumPoints'
in
l
][
0
]
ncols
=
[
l
for
l
in
lines
if
'NumWaves'
in
l
][
0
]
nrows
=
int
(
nrows
.
split
()[
1
])
ncols
=
int
(
ncols
.
split
()[
1
])
data
=
'
\n
'
.
join
(
lines
[
3
:])
data
=
np
.
loadtxt
(
io
.
StringIO
(
data
)).
reshape
((
nrows
,
ncols
))
return
((
nrows
,
ncols
),
data
)
# shape, expectedshape
tests
=
[
((
10
,
),
(
1
,
10
)),
((
10
,
1
),
(
10
,
1
)),
((
1
,
10
),
(
1
,
10
)),
((
3
,
5
),
(
3
,
5
)),
((
5
,
3
),
(
5
,
3
))
]
for
shape
,
expshape
in
tests
:
data
=
np
.
random
.
random
(
shape
)
vstr
=
vest
.
generateVest
(
data
)
gotshape
,
gotdata
=
readvest
(
vstr
)
data
=
data
.
reshape
(
expshape
)
assert
expshape
==
gotshape
assert
np
.
all
(
np
.
isclose
(
data
,
gotdata
))
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