Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Michiel Cottaar
fslpy
Commits
4aad41a5
Commit
4aad41a5
authored
6 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TESt: Test outprefix with different types
parent
6009879c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_wrapperutils.py
+47
-0
47 additions, 0 deletions
tests/test_wrapperutils.py
with
47 additions
and
0 deletions
tests/test_wrapperutils.py
+
47
−
0
View file @
4aad41a5
...
...
@@ -355,6 +355,53 @@ def test_fileOrImage_outprefix():
cleardir
(
td
,
'
myout*
'
)
def
test_fileOrImage_outprefix_differentTypes
():
@wutils.fileOrImage
(
'
img
'
,
outprefix
=
'
outpref
'
)
def
func
(
img
,
outpref
):
img
=
nib
.
load
(
img
)
img
=
nib
.
nifti1
.
Nifti1Image
(
img
.
get_data
()
*
2
,
np
.
eye
(
4
))
text
=
'
1234567890
'
nib
.
save
(
img
,
'
{}_image.nii.gz
'
.
format
(
outpref
))
with
open
(
'
{}_text.txt
'
.
format
(
outpref
),
'
wt
'
)
as
f
:
f
.
write
(
text
)
with
tempdir
.
tempdir
()
as
td
:
img
=
nib
.
nifti1
.
Nifti1Image
(
np
.
array
([[
1
,
2
],
[
3
,
4
]]),
np
.
eye
(
4
))
expi
=
img
.
get_data
()
*
2
expt
=
'
1234567890
'
func
(
img
,
'
myout
'
)
assert
np
.
all
(
nib
.
load
(
'
myout_image.nii.gz
'
)
.
get_data
()
==
expi
)
with
open
(
'
myout_text.txt
'
,
'
rt
'
)
as
f
:
assert
f
.
read
().
strip
()
==
expt
cleardir
(
td
,
'
myout*
'
)
res
=
func
(
img
,
'
myout
'
,
myout_image
=
wutils
.
LOAD
)
assert
list
(
res
.
keys
())
==
[
'
myout_image
'
]
assert
np
.
all
(
res
[
'
myout_image
'
].
get_data
()
==
expi
)
cleardir
(
td
,
'
myout*
'
)
res
=
func
(
img
,
'
myout
'
,
myout
=
wutils
.
LOAD
)
assert
list
(
res
.
keys
())
==
[
'
myout_image
'
]
assert
np
.
all
(
res
[
'
myout_image
'
].
get_data
()
==
expi
)
cleardir
(
td
,
'
myout*
'
)
res
=
func
(
img
,
'
myout
'
,
myout_text
=
wutils
.
LOAD
)
assert
list
(
res
.
keys
())
==
[]
cleardir
(
td
,
'
myout*
'
)
# test directory
def
test_chained_fileOrImageAndArray
():
@wutils.fileOrImage
(
'
image
'
)
...
...
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