Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pyfeeds
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
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
pyfeeds
Commits
fe82a4ac
Commit
fe82a4ac
authored
1 year ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: Basic unit tests for evalImage/evalVectorImage
parent
6db33eae
No related branches found
No related tags found
1 merge request
!36
MNT: Make vector field comparison routine programmatically accessible
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pyfeeds/tests/__init__.py
+7
-0
7 additions, 0 deletions
pyfeeds/tests/__init__.py
pyfeeds/tests/test_evaluate.py
+41
-0
41 additions, 0 deletions
pyfeeds/tests/test_evaluate.py
with
48 additions
and
0 deletions
pyfeeds/tests/__init__.py
+
7
−
0
View file @
fe82a4ac
...
...
@@ -113,6 +113,13 @@ def maketest(filename, returnCode=0, inputs=None, outputs=None, stdout=None):
def
makepyfeeds
(
**
kwargs
):
# simplest way of creating a dummy pyfeeds object
if
len
(
kwargs
)
==
0
:
kwargs
[
'
command
'
]
=
'
compare
'
kwargs
[
'
inputDir
'
]
=
os
.
getcwd
()
kwargs
[
'
benchmarkDir
'
]
=
os
.
getcwd
()
args
=
argparse
.
Namespace
(
**
kwargs
)
cfg
=
argparse
.
Namespace
()
return
main
.
Pyfeeds
(
args
,
cfg
)
This diff is collapsed.
Click to expand it.
pyfeeds/tests/test_evaluate.py
+
41
−
0
View file @
fe82a4ac
...
...
@@ -8,6 +8,9 @@
import
os
import
os.path
as
op
import
numpy
as
np
import
nibabel
as
nib
from
.
import
tempdir
,
makepaths
,
maketest
,
makepyfeeds
,
CaptureStdout
from
pyfeeds
import
testing
,
evaluate
...
...
@@ -57,3 +60,41 @@ def test_evaluateTestAgainstBenchmark():
assert
len
(
lines
)
==
3
for
l
in
lines
[
1
:]:
assert
'
PASS
'
in
l
def
test_evalVectorImage
():
vecarr1
=
-
1
+
2
*
np
.
random
.
random
((
10
,
10
,
10
,
3
))
vecarr2
=
-
1
+
2
*
np
.
random
.
random
((
10
,
10
,
10
,
3
))
with
tempdir
():
pyf
=
makepyfeeds
()
fname1
=
'
image1.nii.gz
'
fname2
=
'
image2.nii.gz
'
nib
.
Nifti1Image
(
vecarr1
,
np
.
eye
(
4
)).
to_filename
(
fname1
)
nib
.
Nifti1Image
(
vecarr2
,
np
.
eye
(
4
)).
to_filename
(
fname2
)
assert
evaluate
.
evalVectorImage
(
pyf
,
fname1
,
fname1
)
==
0
assert
evaluate
.
evalVectorImage
(
pyf
,
fname2
,
fname2
)
==
0
assert
evaluate
.
evalVectorImage
(
pyf
,
fname1
,
fname2
)
!=
0
def
test_evalImage
():
arr1
=
-
1
+
2
*
np
.
random
.
random
((
10
,
10
,
10
,
10
))
arr2
=
-
1
+
2
*
np
.
random
.
random
((
10
,
10
,
10
,
10
))
with
tempdir
():
pyf
=
makepyfeeds
()
fname1
=
'
image1.nii.gz
'
fname2
=
'
image2.nii.gz
'
nib
.
Nifti1Image
(
arr1
,
np
.
eye
(
4
)).
to_filename
(
fname1
)
nib
.
Nifti1Image
(
arr2
,
np
.
eye
(
4
)).
to_filename
(
fname2
)
assert
evaluate
.
evalImage
(
pyf
,
fname1
,
fname1
)
==
0
assert
evaluate
.
evalImage
(
pyf
,
fname2
,
fname2
)
==
0
assert
evaluate
.
evalImage
(
pyf
,
fname1
,
fname2
)
!=
0
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