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
45742245
Commit
45742245
authored
6 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: Test passing sequence as input
parent
9b38aec1
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
+52
-3
52 additions, 3 deletions
tests/test_wrapperutils.py
with
52 additions
and
3 deletions
tests/test_wrapperutils.py
+
52
−
3
View file @
45742245
...
...
@@ -13,6 +13,7 @@ import textwrap
try
:
from
unittest
import
mock
except
ImportError
:
import
mock
import
six
import
pytest
import
numpy
as
np
...
...
@@ -309,7 +310,55 @@ def test_fileOrImage():
assert
np
.
all
(
result
.
get_data
()[:]
==
expected
)
def
test_fileOrImage_outprefix
():
def
test_fileOrThing_sequence
():
@wutils.fileOrArray
(
'
arrs
'
,
'
out
'
)
def
func
(
arrs
,
out
):
if
isinstance
(
arrs
,
six
.
string_types
):
arrs
=
[
arrs
]
print
(
'
Loading from files
'
,
arrs
)
arrs
=
[
np
.
loadtxt
(
a
)
for
a
in
arrs
]
res
=
np
.
sum
(
arrs
,
axis
=
0
)
print
(
'
result
'
,
res
)
np
.
savetxt
(
out
,
res
)
inputs
=
[
np
.
random
.
randint
(
1
,
10
,
(
3
,
3
))
for
i
in
range
(
4
)]
infiles
=
[
'
input{}.txt
'
.
format
(
i
)
for
i
in
range
(
len
(
inputs
))]
exp
=
np
.
sum
(
inputs
,
axis
=
0
)
with
tempdir
.
tempdir
():
for
ifile
,
idata
in
zip
(
infiles
,
inputs
):
np
.
savetxt
(
ifile
,
idata
)
func
(
inputs
,
'
result.txt
'
)
assert
np
.
all
(
np
.
loadtxt
(
'
result.txt
'
)
==
exp
)
assert
np
.
all
(
func
(
inputs
,
wutils
.
LOAD
)[
'
out
'
]
==
exp
)
func
(
inputs
[
0
],
'
result.txt
'
)
assert
np
.
all
(
np
.
loadtxt
(
'
result.txt
'
)
==
inputs
[
0
])
assert
np
.
all
(
func
(
inputs
[
0
],
wutils
.
LOAD
)[
'
out
'
]
==
inputs
[
0
])
func
(
infiles
,
'
result.txt
'
)
assert
np
.
all
(
np
.
loadtxt
(
'
result.txt
'
)
==
exp
)
assert
np
.
all
(
func
(
infiles
,
wutils
.
LOAD
)[
'
out
'
]
==
exp
)
func
(
infiles
[
0
],
'
result.txt
'
)
assert
np
.
all
(
np
.
loadtxt
(
'
result.txt
'
)
==
inputs
[
0
])
assert
np
.
all
(
func
(
infiles
[
0
],
wutils
.
LOAD
)[
'
out
'
]
==
inputs
[
0
])
def
test_fileOrThing_outprefix
():
@wutils.fileOrImage
(
'
img
'
,
outprefix
=
'
output_base
'
)
def
basefunc
(
img
,
output_base
):
...
...
@@ -352,7 +401,7 @@ def test_fileOrImage_outprefix():
cleardir
(
td
,
'
myout*
'
)
def
test_fileOr
Image
_outprefix_differentTypes
():
def
test_fileOr
Thing
_outprefix_differentTypes
():
@wutils.fileOrImage
(
'
img
'
,
outprefix
=
'
outpref
'
)
def
func
(
img
,
outpref
):
...
...
@@ -392,7 +441,7 @@ def test_fileOrImage_outprefix_differentTypes():
cleardir
(
td
,
'
myout*
'
)
def
test_fileOr
Image
_outprefix_directory
():
def
test_fileOr
Thing
_outprefix_directory
():
import
logging
logging
.
basicConfig
()
...
...
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