Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SVLT
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
ALMF
SVLT
Commits
68b683fc
Commit
68b683fc
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
MonoPatchStackFromFile now contains file accessor as an object
parent
33f83235
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
extensions/chaeo/accessors.py
+11
-2
11 additions, 2 deletions
extensions/chaeo/accessors.py
extensions/chaeo/tests/test_accessors.py
+18
-2
18 additions, 2 deletions
extensions/chaeo/tests/test_accessors.py
with
29 additions
and
4 deletions
extensions/chaeo/accessors.py
+
11
−
2
View file @
68b683fc
from
pathlib
import
Path
import
numpy
as
np
from
model_server.accessors
import
generate_file_accessor
,
InMemoryDataAccessor
class
MonoPatchStack
(
InMemoryDataAccessor
):
...
...
@@ -48,11 +51,17 @@ class MonoPatchStack(InMemoryDataAccessor):
class
MonoPatchStackFromFile
(
MonoPatchStack
):
def
__init__
(
self
,
fpath
):
super
().
__init__
(
generate_file_accessor
(
fpath
).
data
[:,
:,
0
,
:])
if
not
Path
(
fpath
).
exists
():
raise
FileNotFoundError
(
f
'
Could not find
{
fpath
}
'
)
self
.
file_acc
=
generate_file_accessor
(
fpath
)
super
().
__init__
(
self
.
file_acc
.
data
[:,
:,
0
,
:])
class
Error
(
Exception
):
pass
class
InvalidDataForPatchStackError
(
Error
):
pass
\ No newline at end of file
pass
class
FileNotFoundError
(
Error
):
pass
This diff is collapsed.
Click to expand it.
extensions/chaeo/tests/test_accessors.py
+
18
−
2
View file @
68b683fc
...
...
@@ -2,7 +2,8 @@ import unittest
import
numpy
as
np
from
extensions.chaeo.accessors
import
MonoPatchStack
from
conf.testing
import
monozstackmask
from
extensions.chaeo.accessors
import
MonoPatchStack
,
MonoPatchStackFromFile
...
...
@@ -26,4 +27,19 @@ class TestCziImageFileAccess(unittest.TestCase):
acc
=
MonoPatchStack
([
np
.
random
.
rand
(
h
,
w
)
for
_
in
range
(
0
,
4
)])
self
.
assertEqual
(
acc
.
count
,
n
)
self
.
assertEqual
(
acc
.
hw
,
(
h
,
w
))
self
.
assertEqual
(
acc
.
make_tczyx
().
shape
,
(
n
,
1
,
1
,
h
,
w
))
\ No newline at end of file
self
.
assertEqual
(
acc
.
make_tczyx
().
shape
,
(
n
,
1
,
1
,
h
,
w
))
def
test_make_patch_stack_from_file
(
self
):
h
=
monozstackmask
[
'
h
'
]
w
=
monozstackmask
[
'
w
'
]
c
=
monozstackmask
[
'
c
'
]
n
=
monozstackmask
[
'
z
'
]
acc
=
MonoPatchStackFromFile
(
monozstackmask
[
'
path
'
])
self
.
assertEqual
(
acc
.
hw
,
(
h
,
w
))
self
.
assertEqual
(
acc
.
count
,
n
)
self
.
assertEqual
(
acc
.
make_tczyx
().
shape
,
(
n
,
c
,
1
,
h
,
w
))
def
test_raises_filenotfound
(
self
):
from
extensions.chaeo.accessors
import
FileNotFoundError
with
self
.
assertRaises
(
FileNotFoundError
):
acc
=
MonoPatchStackFromFile
(
'
c:/fake/file/name.tif
'
)
\ 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