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
28191a4d
Commit
28191a4d
authored
8 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
ImageWrapper test adjustment
parent
e0d897b5
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_imagewrapper.py
+30
-17
30 additions, 17 deletions
tests/test_imagewrapper.py
with
30 additions
and
17 deletions
tests/test_imagewrapper.py
+
30
−
17
View file @
28191a4d
...
...
@@ -759,15 +759,10 @@ def test_ImageWrapper_write_in_overlap(niters, seed):
sliceshape
=
sliceshape
[:
-
1
]
break
# Expected wrapper coverage after the write
# The write will invalidate the current
# known data range and coverage, so the
# expected coverage after the write will
# be the area covered by the write slice
nullCov
=
np
.
zeros
(
cov
.
shape
)
nullCov
[:]
=
np
.
nan
expCov
=
imagewrap
.
adjustCoverage
(
nullCov
[...,
0
],
slices
)
# Expected wrapper coverage after the
# write is the union of the original
# coverage and the write slice.
expCov
=
imagewrap
.
adjustCoverage
(
cov
[...,
0
],
slices
)
for
_
in
range
(
10
):
...
...
@@ -784,23 +779,41 @@ def test_ImageWrapper_write_in_overlap(niters, seed):
newData
=
np
.
linspace
(
rlo
,
rhi
,
np
.
prod
(
sliceshape
))
newData
=
newData
.
reshape
(
sliceshape
)
print
(
'
New data shape: {}
'
.
format
(
newData
))
print
(
'
Old range: {} - {}
'
.
format
(
*
wrapper
.
dataRange
))
print
(
'
Old coverage: {}
'
.
format
(
cov
[...,
0
]))
print
(
'
Slice: {}
'
.
format
(
sliceobjs
[:
-
1
]))
print
(
'
Expected coverage: {}
'
.
format
(
expCov
))
print
(
'
Old range: {} - {}
'
.
format
(
*
wrapper
.
dataRange
))
print
(
'
New data range: {} - {}
'
.
format
(
newData
.
min
(),
newData
.
max
()))
# We figure out the expected data
# range by creating a copy of the
# data, and doing the same write
expData
=
np
.
copy
(
data
[...,
0
])
expData
[
sliceobjs
[:
-
1
]]
=
newData
# Then calcultaing the min/max
# on this copy
expCovSlice
=
[
slice
(
int
(
lo
),
int
(
hi
))
for
lo
,
hi
in
expCov
.
T
]
expLo
=
expData
[
expCovSlice
].
min
()
expHi
=
expData
[
expCovSlice
].
max
()
wrapper
[
tuple
(
sliceobjs
)]
=
newData
newCov
=
wrapper
.
coverage
(
0
)
newLo
,
newHi
=
wrapper
.
dataRange
print
(
'
Expected range: {} - {}
'
.
format
(
rlo
,
rhi
))
print
(
'
New range: {} - {}
'
.
format
(
newLo
,
newHi
))
print
(
'
Data min/max: {} - {}
'
.
format
(
img
.
get_data
()[
tuple
(
sliceobjs
)].
min
(),
img
.
get_data
()[
tuple
(
sliceobjs
)].
max
()))
print
(
'
Expected range: {} - {}
'
.
format
(
expLo
,
expHi
))
print
(
'
New range: {} - {}
'
.
format
(
newLo
,
newHi
))
print
(
'
Slice min/max: {} - {}
'
.
format
(
img
.
get_data
()[
tuple
(
sliceobjs
)].
min
(),
img
.
get_data
()[
tuple
(
sliceobjs
)].
max
()))
print
(
'
Data min/max: {} - {}
'
.
format
(
img
.
get_data
().
min
(),
img
.
get_data
().
max
()))
assert
np
.
all
(
newCov
==
expCov
)
assert
np
.
isclose
(
newLo
,
rl
o
)
assert
np
.
isclose
(
newHi
,
rh
i
)
assert
np
.
isclose
(
newLo
,
expL
o
)
assert
np
.
isclose
(
newHi
,
expH
i
)
def
test_ImageWrapper_write_different_volume
(
niters
,
seed
):
...
...
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