Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
model_server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Christopher Randolph Rhodes
model_server
Commits
5f245c68
Commit
5f245c68
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Tests that use random arrays now call a single function to ensure integer type
parent
a951fd00
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!16
Completed (de)serialization of RoiSet
,
!5
Resolve "ilastik models do not validate dimensionality of input data"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_accessors.py
+13
-9
13 additions, 9 deletions
tests/test_accessors.py
with
13 additions
and
9 deletions
tests/test_accessors.py
+
13
−
9
View file @
5f245c68
...
...
@@ -7,6 +7,9 @@ from model_server.base.accessors import PatchStack, make_patch_stack_from_file,
from
model_server.conf.testing
import
czifile
,
output_path
,
monopngfile
,
rgbpngfile
,
tifffile
,
monozstackmask
from
model_server.base.accessors
import
CziImageFileAccessor
,
DataShapeError
,
generate_file_accessor
,
InMemoryDataAccessor
,
PngFileAccessor
,
write_accessor_data_to_file
,
TifSingleSeriesFileAccessor
def
_random_int
(
*
args
):
return
np
.
random
.
randint
(
0
,
2
**
8
,
size
=
args
,
dtype
=
'
uint8
'
)
class
TestCziImageFileAccess
(
unittest
.
TestCase
):
def
setUp
(
self
)
->
None
:
...
...
@@ -40,7 +43,7 @@ class TestCziImageFileAccess(unittest.TestCase):
nc
=
4
nz
=
11
c
=
3
cf
=
InMemoryDataAccessor
(
np
.
random
.
rand
(
h
,
w
,
nc
,
nz
))
cf
=
InMemoryDataAccessor
(
_
random
_int
(
h
,
w
,
nc
,
nz
))
sc
=
cf
.
get_one_channel_data
(
c
)
self
.
assertEqual
(
sc
.
shape
,
(
h
,
w
,
1
,
nz
))
...
...
@@ -70,7 +73,7 @@ class TestCziImageFileAccess(unittest.TestCase):
def
test_conform_data_shorter_than_xycz
(
self
):
h
=
256
w
=
512
data
=
np
.
random
.
rand
(
h
,
w
,
1
)
data
=
_
random
_int
(
h
,
w
,
1
)
acc
=
InMemoryDataAccessor
(
data
)
self
.
assertEqual
(
InMemoryDataAccessor
.
conform_data
(
data
).
shape
,
...
...
@@ -82,7 +85,7 @@ class TestCziImageFileAccess(unittest.TestCase):
)
def
test_conform_data_longer_than_xycz
(
self
):
data
=
np
.
random
.
rand
(
256
,
512
,
12
,
8
,
3
)
data
=
_
random
_int
(
256
,
512
,
12
,
8
,
3
)
with
self
.
assertRaises
(
DataShapeError
):
acc
=
InMemoryDataAccessor
(
data
)
...
...
@@ -93,7 +96,7 @@ class TestCziImageFileAccess(unittest.TestCase):
c
=
3
nz
=
10
yxcz
=
(
2
**
8
*
np
.
random
.
rand
(
h
,
w
,
c
,
nz
)
).
astype
(
'
uint8
'
)
yxcz
=
_
random
_int
(
h
,
w
,
c
,
nz
)
acc
=
InMemoryDataAccessor
(
yxcz
)
fp
=
output_path
/
f
'
rand3d.tif
'
self
.
assertTrue
(
...
...
@@ -138,7 +141,7 @@ class TestPatchStackAccessor(unittest.TestCase):
w
=
256
h
=
512
n
=
4
acc
=
PatchStack
(
np
.
random
.
rand
(
n
,
h
,
w
,
1
,
1
))
acc
=
PatchStack
(
_
random
_int
(
n
,
h
,
w
,
1
,
1
))
self
.
assertEqual
(
acc
.
count
,
n
)
self
.
assertEqual
(
acc
.
hw
,
(
h
,
w
))
self
.
assertEqual
(
acc
.
pyxcz
.
shape
,
(
n
,
h
,
w
,
1
,
1
))
...
...
@@ -147,7 +150,7 @@ class TestPatchStackAccessor(unittest.TestCase):
w
=
256
h
=
512
n
=
4
acc
=
PatchStack
([
np
.
random
.
rand
(
h
,
w
,
1
,
1
)
for
_
in
range
(
0
,
n
)])
acc
=
PatchStack
([
_
random
_int
(
h
,
w
,
1
,
1
)
for
_
in
range
(
0
,
n
)])
self
.
assertEqual
(
acc
.
count
,
n
)
self
.
assertEqual
(
acc
.
hw
,
(
h
,
w
))
self
.
assertEqual
(
acc
.
pyxcz
.
shape
,
(
n
,
h
,
w
,
1
,
1
))
...
...
@@ -176,8 +179,8 @@ class TestPatchStackAccessor(unittest.TestCase):
nz
=
5
n
=
4
patches
=
[
np
.
random
.
rand
(
h
,
w
,
c
,
nz
)
for
_
in
range
(
0
,
n
)]
patches
.
append
(
np
.
random
.
rand
(
h
,
2
*
w
,
c
,
nz
))
patches
=
[
_
random
_int
(
h
,
w
,
c
,
nz
)
for
_
in
range
(
0
,
n
)]
patches
.
append
(
_
random
_int
(
h
,
2
*
w
,
c
,
nz
))
acc
=
PatchStack
(
patches
)
self
.
assertEqual
(
acc
.
count
,
n
+
1
)
self
.
assertEqual
(
acc
.
hw
,
(
h
,
2
*
w
))
...
...
@@ -191,7 +194,8 @@ class TestPatchStackAccessor(unittest.TestCase):
n
=
4
nz
=
15
nc
=
2
acc
=
PatchStack
(
np
.
random
.
rand
(
n
,
h
,
w
,
nc
,
nz
))
acc
=
PatchStack
(
_
random
_int
(
n
,
h
,
w
,
nc
,
nz
))
self
.
assertEqual
(
acc
.
count
,
n
)
self
.
assertEqual
(
acc
.
pczyx
.
shape
,
(
n
,
nc
,
nz
,
h
,
w
))
self
.
assertEqual
(
acc
.
hw
,
(
h
,
w
))
return
acc
\ No newline at end of file
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