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
12e07e81
Commit
12e07e81
authored
5 months ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: Test saveLabelFile with classification probabilities
parent
8be19316
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
fsl/tests/test_fixlabels.py
+28
-5
28 additions, 5 deletions
fsl/tests/test_fixlabels.py
with
28 additions
and
5 deletions
fsl/tests/test_fixlabels.py
+
28
−
5
View file @
12e07e81
...
...
@@ -435,13 +435,8 @@ def test_loadLabelFile_probabilities():
assert
lists_equal
(
gotprobs
,
expprobs
)
def
test_saveLabelFile
():
labels
=
[[
'
Label1
'
,
'
Label2
'
,
'
Label3
'
],
[
'
Signal
'
],
[
'
Noise
'
],
...
...
@@ -493,3 +488,31 @@ def test_saveLabelFile():
fixlabels
.
saveLabelFile
(
labels
,
fname
,
signalLabels
=
sigLabels
)
with
open
(
fname
,
'
rt
'
)
as
f
:
assert
f
.
read
().
strip
()
==
exp
def
test_saveLabelFile_probabilities
():
labels
=
[[
'
Label1
'
,
'
Label2
'
,
'
Label3
'
],
[
'
Signal
'
],
[
'
Noise
'
],
[
'
Label1
'
],
[
'
Unknown
'
]]
probs
=
[
0.1
,
0.2
,
0.3
,
0.4
,
0.5
]
expected
=
tw
.
dedent
(
"""
1, Label1, Label2, Label3, True, 0.100000
2, Signal, False, 0.200000
3, Noise, True, 0.300000
4, Label1, True, 0.400000
5, Unknown, False, 0.500000
[1, 3, 4]
"""
).
strip
()
with
tests
.
testdir
()
as
testdir
:
fname
=
op
.
join
(
testdir
,
'
fname.txt
'
)
exp
=
'
.
\n
{}
'
.
format
(
expected
)
fixlabels
.
saveLabelFile
(
labels
,
fname
,
probabilities
=
probs
)
with
open
(
fname
,
'
rt
'
)
as
f
:
got
=
f
.
read
().
strip
()
assert
got
==
exp
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