Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
fslpy
Commits
8e21227d
Commit
8e21227d
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: test fslmaths LOAD behaviour
parent
7d5e6305
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/__init__.py
+4
-1
4 additions, 1 deletion
tests/__init__.py
tests/test_wrappers.py
+23
-2
23 additions, 2 deletions
tests/test_wrappers.py
with
27 additions
and
3 deletions
tests/__init__.py
+
4
−
1
View file @
8e21227d
...
@@ -50,7 +50,10 @@ def mockFSLDIR(**kwargs):
...
@@ -50,7 +50,10 @@ def mockFSLDIR(**kwargs):
if
not
op
.
isdir
(
subdir
):
if
not
op
.
isdir
(
subdir
):
os
.
makedirs
(
subdir
)
os
.
makedirs
(
subdir
)
for
fname
in
files
:
for
fname
in
files
:
touch
(
op
.
join
(
subdir
,
fname
))
fname
=
op
.
join
(
subdir
,
fname
)
touch
(
fname
)
if
subdir
==
bindir
:
os
.
chmod
(
fname
,
0o755
)
fslplatform
.
fsldir
=
fsldir
fslplatform
.
fsldir
=
fsldir
fslplatform
.
fsldevdir
=
None
fslplatform
.
fsldevdir
=
None
...
...
This diff is collapsed.
Click to expand it.
tests/test_wrappers.py
+
23
−
2
View file @
8e21227d
...
@@ -5,14 +5,19 @@
...
@@ -5,14 +5,19 @@
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
#
import
os
import
os.path
as
op
import
os.path
as
op
import
itertools
as
it
import
itertools
as
it
import
textwrap
as
tw
import
numpy
as
np
import
fsl.wrappers
as
fw
import
fsl.wrappers
as
fw
import
fsl.utils.assertions
as
asrt
import
fsl.utils.assertions
as
asrt
import
fsl.utils.run
as
run
import
fsl.utils.run
as
run
from
fsl.utils.tempdir
import
tempdir
from
.
import
mockFSLDIR
from
.
import
mockFSLDIR
,
make_random_image
def
checkResult
(
cmd
,
base
,
args
,
stripdir
=
None
):
def
checkResult
(
cmd
,
base
,
args
,
stripdir
=
None
):
...
@@ -272,7 +277,23 @@ def test_fslmaths():
...
@@ -272,7 +277,23 @@ def test_fslmaths():
assert
result
.
output
[
0
]
==
expected
assert
result
.
output
[
0
]
==
expected
# TODO test LOAD output
# test LOAD output
with
tempdir
()
as
td
,
mockFSLDIR
(
bin
=
(
'
fslmaths
'
,))
as
fsldir
:
expect
=
make_random_image
(
op
.
join
(
td
,
'
output.nii.gz
'
))
with
open
(
op
.
join
(
fsldir
,
'
bin
'
,
'
fslmaths
'
),
'
wt
'
)
as
f
:
f
.
write
(
tw
.
dedent
(
"""
#!/usr/bin/env python
import sys
import shutil
shutil.copy(
'
{}
'
, sys.argv[2])
"""
.
format
(
op
.
join
(
td
,
'
output.nii.gz
'
))).
strip
())
os
.
chmod
(
op
.
join
(
fsldir
,
'
bin
'
,
'
fslmaths
'
),
0o755
)
got
=
fw
.
fslmaths
(
'
input
'
).
run
()
assert
np
.
all
(
expect
.
dataobj
[:]
==
got
.
dataobj
[:])
got
=
fw
.
fslmaths
(
'
input
'
).
run
(
fw
.
LOAD
)
assert
np
.
all
(
expect
.
dataobj
[:]
==
got
.
dataobj
[:])
def
test_fast
():
def
test_fast
():
with
asrt
.
disabled
(),
run
.
dryrun
(),
mockFSLDIR
(
bin
=
(
'
fast
'
,))
as
fsldir
:
with
asrt
.
disabled
(),
run
.
dryrun
(),
mockFSLDIR
(
bin
=
(
'
fast
'
,))
as
fsldir
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment