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
1803a43d
Commit
1803a43d
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: Bitmap tests
parent
27ae5717
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
setup.cfg
+1
-0
1 addition, 0 deletions
setup.cfg
tests/test_bitmap.py
+63
-0
63 additions, 0 deletions
tests/test_bitmap.py
with
64 additions
and
0 deletions
setup.cfg
+
1
−
0
View file @
1803a43d
...
@@ -11,6 +11,7 @@ universal=1
...
@@ -11,6 +11,7 @@ universal=1
# - dicomtest: Requires dcm2niix
# - dicomtest: Requires dcm2niix
# - meshtest: Requires trimesh and rtree
# - meshtest: Requires trimesh and rtree
# - igziptest: Requires indexed_gzip
# - igziptest: Requires indexed_gzip
# - piltest: Requires Pillow
# - noroottest: Need to be executed as
# - noroottest: Need to be executed as
# non-root user (will fail
# non-root user (will fail
# otherwise)
# otherwise)
...
...
This diff is collapsed.
Click to expand it.
tests/test_bitmap.py
0 → 100644
+
63
−
0
View file @
1803a43d
#!/usr/bin/env python
#
# test_bitmap.py -
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
import
numpy
as
np
import
pytest
import
fsl.utils.tempdir
as
tempdir
import
fsl.data.bitmap
as
fslbmp
@pytest.mark.piltest
def
test_bitmap
():
from
PIL
import
Image
with
tempdir
.
tempdir
():
data
=
np
.
random
.
randint
(
0
,
255
,
(
100
,
200
,
4
),
dtype
=
np
.
uint8
)
img
=
Image
.
fromarray
(
data
,
mode
=
'
RGBA
'
)
img
.
save
(
'
image.png
'
)
bmp
=
fslbmp
.
Bitmap
(
'
image.png
'
)
assert
bmp
.
name
==
'
image.png
'
assert
bmp
.
dataSource
==
'
image.png
'
assert
bmp
.
shape
==
(
200
,
100
,
4
)
repr
(
bmp
)
hash
(
bmp
)
assert
np
.
all
(
bmp
.
data
==
np
.
fliplr
(
data
.
transpose
(
1
,
0
,
2
)))
@pytest.mark.piltest
def
test_bitmap_asImage
():
from
PIL
import
Image
with
tempdir
.
tempdir
():
d3
=
np
.
random
.
randint
(
0
,
255
,
(
100
,
200
,
3
),
dtype
=
np
.
uint8
)
d4
=
np
.
random
.
randint
(
0
,
255
,
(
100
,
200
,
4
),
dtype
=
np
.
uint8
)
img3
=
Image
.
fromarray
(
d3
,
mode
=
'
RGB
'
)
img4
=
Image
.
fromarray
(
d4
,
mode
=
'
RGBA
'
)
img3
.
save
(
'
rgb.png
'
)
img4
.
save
(
'
rgba.png
'
)
bmp3
=
fslbmp
.
Bitmap
(
'
rgb.png
'
)
bmp4
=
fslbmp
.
Bitmap
(
'
rgba.png
'
)
i3
=
bmp3
.
asImage
()
i4
=
bmp4
.
asImage
()
assert
i3
.
shape
==
(
200
,
100
,
1
)
assert
i4
.
shape
==
(
200
,
100
,
1
)
assert
i3
.
nvals
==
3
assert
i4
.
nvals
==
4
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