Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OrcaSong
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Machine Learning
OrcaSong
Commits
608ac19b
Commit
608ac19b
authored
3 years ago
by
Stefan Reck
Browse files
Options
Downloads
Patches
Plain Diff
add tests
parent
eba0a084
No related branches found
No related tags found
1 merge request
!20
Parser
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/orcasong_example.toml
+4
-1
4 additions, 1 deletion
examples/orcasong_example.toml
orcasong/from_toml.py
+8
-7
8 additions, 7 deletions
orcasong/from_toml.py
tests/test_from_toml.py
+36
-0
36 additions, 0 deletions
tests/test_from_toml.py
with
48 additions
and
8 deletions
examples/orcasong_
neturino_mc
.toml
→
examples/orcasong_
example
.toml
+
4
−
1
View file @
608ac19b
# the mode to run orcasong in; either 'graph' or 'image'
# the mode to run orcasong in; either 'graph' or 'image'
mode
=
"graph"
mode
=
"graph"
# arguments for
running orcasong (see
FileGraph or FileBinner
in
orcasong.core)
.
# arguments for FileGraph or FileBinner
(see
orcasong.core)
max_n_hits
=
2000
max_n_hits
=
2000
time_window
=
[
-100
,
5000
]
time_window
=
[
-100
,
5000
]
# can also give the arguments of orcasong.core.BaseProcessor,
# which are shared between modes
chunksize
=
16
# built-in extractor function to use
# built-in extractor function to use
extractor
=
"neutrino_mc"
extractor
=
"neutrino_mc"
...
...
This diff is collapsed.
Click to expand it.
orcasong/from_toml.py
+
8
−
7
View file @
608ac19b
import
os
import
toml
import
toml
import
orcasong.core
import
orcasong.core
import
orcasong.extractors
as
extractors
import
orcasong.extractors
as
extractors
...
@@ -31,15 +30,17 @@ def add_parser_run(subparsers):
...
@@ -31,15 +30,17 @@ def add_parser_run(subparsers):
def
run_orcasong
(
infile
,
toml_file
,
detx_file
=
None
,
outfile
=
None
):
def
run_orcasong
(
infile
,
toml_file
,
detx_file
=
None
,
outfile
=
None
):
if
outfile
is
None
:
setup_processor
(
infile
,
toml_file
,
detx_file
).
run
(
out
file
=
f
"
{
os
.
path
.
splitext
(
os
.
path
.
basename
(
infile
))[
0
]
}
_dl.h5
"
in
file
=
infile
,
outfile
=
outfile
)
def
setup_processor
(
infile
,
toml_file
,
detx_file
=
None
):
cfg
=
toml
.
load
(
toml_file
)
cfg
=
toml
.
load
(
toml_file
)
processor
=
_get_verbose
(
cfg
[
"
mode
"
]
,
MODES
)
processor
=
_get_verbose
(
cfg
.
pop
(
"
mode
"
)
,
MODES
)
if
"
detx_file
"
in
cfg
:
if
"
detx_file
"
in
cfg
:
if
detx_file
is
not
None
:
if
detx_file
is
not
None
:
raise
ValueError
(
"
detx_file passed to
functio
n AND defined in toml
"
)
raise
ValueError
(
"
detx_file passed to
ru
n AND defined in toml
"
)
detx_file
=
cfg
.
pop
(
"
detx_file
"
)
detx_file
=
cfg
.
pop
(
"
detx_file
"
)
if
"
extractor
"
in
cfg
:
if
"
extractor
"
in
cfg
:
...
@@ -48,11 +49,11 @@ def run_orcasong(infile, toml_file, detx_file=None, outfile=None):
...
@@ -48,11 +49,11 @@ def run_orcasong(infile, toml_file, detx_file=None, outfile=None):
else
:
else
:
extractor
=
None
extractor
=
None
processor
(
return
processor
(
det_file
=
detx_file
,
det_file
=
detx_file
,
extractor
=
extractor
,
extractor
=
extractor
,
**
cfg
,
**
cfg
,
)
.
run
(
infile
=
infile
,
outfile
=
outfile
)
)
def
_get_verbose
(
key
,
d
):
def
_get_verbose
(
key
,
d
):
...
...
This diff is collapsed.
Click to expand it.
tests/test_from_toml.py
0 → 100644
+
36
−
0
View file @
608ac19b
from
unittest
import
TestCase
import
os
import
orcasong
import
orcasong.from_toml
as
from_toml
EXAMPLES
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
orcasong
.
__file__
)),
"
examples
"
)
def
test_extr
(
infile
):
return
infile
+
"
_extr
"
orcasong
.
from_toml
.
EXTRACTORS
[
"
neutrino_mc
"
]
=
test_extr
class
TestSetupProcessorExampleConfig
(
TestCase
):
def
setUp
(
self
):
self
.
processor
=
from_toml
.
setup_processor
(
infile
=
"
test_in
"
,
toml_file
=
os
.
path
.
join
(
EXAMPLES
,
"
orcasong_example.toml
"
),
detx_file
=
"
test_det
"
,
)
def
test_time_window
(
self
):
self
.
assertEqual
(
self
.
processor
.
time_window
,
[
-
100
,
5000
])
def
test_max_n_hits
(
self
):
self
.
assertEqual
(
self
.
processor
.
max_n_hits
,
2000
)
def
test_chunksize
(
self
):
self
.
assertEqual
(
self
.
processor
.
chunksize
,
16
)
def
test_extractor_is_dummy_extractor
(
self
):
self
.
assertEqual
(
self
.
processor
.
extractor
,
"
test_in_extr
"
)
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