Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
platy-browser-data
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
Container Registry
Model registry
Operate
Environments
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
Christian Tischer
platy-browser-data
Commits
c6e2d7fc
Commit
c6e2d7fc
authored
5 years ago
by
Constantin Pape
Browse files
Options
Downloads
Patches
Plain Diff
Implement test for genes table
parent
3682f1fe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Merge versioning and scripts into master
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/attributes/test_genes.py
+46
-1
46 additions, 1 deletion
test/attributes/test_genes.py
with
46 additions
and
1 deletion
test/attributes/test_genes.py
+
46
−
1
View file @
c6e2d7fc
import
unittest
import
sys
import
os
import
numpy
as
np
sys
.
path
.
append
(
'
../..
'
)
# TODO write unittest that checks new version of gene mapping against original
# check new version of gene mapping against original
class
TestGeneAttributes
(
unittest
.
TestCase
):
test_file
=
'
test_table.csv
'
def
tearDown
(
self
):
try
:
os
.
remove
(
self
.
test_file
)
except
OSError
:
pass
def
load_table
(
self
,
table_file
):
table
=
np
.
genfromtxt
(
table_file
,
delimiter
=
'
\t
'
,
skip_header
=
1
,
dtype
=
'
float32
'
)
return
table
def
test_genes
(
self
):
from
scripts.attributes.genes
import
write_genes_table
from
scripts.files
import
get_h5_path_from_xml
# load original genes table
original_table_file
=
'
../../data/0.0.0/tables/em-segmented-cells-labels/genes.csv
'
original_table
=
self
.
load_table
(
original_table_file
)
self
.
assertEqual
(
original_table
.
dtype
,
np
.
dtype
(
'
float32
'
))
labels
=
original_table
[:,
0
].
astype
(
'
uint64
'
)
# compute and load the genes table
segm_file
=
'
../../data/0.0.0/segmentations/em-segmented-cells-labels.h5
'
genes_file
=
'
../../data/0.0.0/misc/meds_all_genes.xml
'
genes_file
=
get_h5_path_from_xml
(
genes_file
)
table_file
=
self
.
test_file
print
(
"
Start computation ...
"
)
write_genes_table
(
segm_file
,
genes_file
,
table_file
,
labels
)
table
=
self
.
load_table
(
table_file
)
# make sure new and old table agree
self
.
assertEqual
(
table
.
shape
,
original_table
.
shape
)
self
.
assertTrue
(
np
.
allclose
(
table
,
original_table
))
if
__name__
==
'
__main__
'
:
unittest
.
main
()
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