Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
KM3BUU
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
simulation
KM3BUU
Commits
07d27e4d
Commit
07d27e4d
authored
4 years ago
by
Johannes Schumann
Browse files
Options
Downloads
Patches
Plain Diff
Updated tests
parent
18c8ef2e
No related branches found
No related tags found
No related merge requests found
Pipeline
#15226
passed
4 years ago
Stage: test
Stage: coverage
Stage: doc
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
km3buu/tests/test_ctrl.py
+14
-8
14 additions, 8 deletions
km3buu/tests/test_ctrl.py
km3buu/tests/test_output.py
+8
-0
8 additions, 0 deletions
km3buu/tests/test_output.py
with
22 additions
and
8 deletions
km3buu/tests/test_ctrl.py
+
14
−
8
View file @
07d27e4d
...
...
@@ -10,26 +10,32 @@ __maintainer__ = "Johannes Schumann"
__email__
=
"
jschumann@km3net.de
"
__status__
=
"
Development
"
import
csv
import
unittest
import
numpy
as
np
from
km3buu.jobcard
import
*
from
km3buu.ctrl
import
run_jobcard
from
tempfile
import
TemporaryDirectory
from
tempfile
import
TemporaryDirectory
,
NamedTemporaryFile
from
os
import
listdir
from
os.path
import
abspath
,
join
,
dirname
from
thepipe.logger
import
get_logger
from
km3net_testdata
import
data_path
JOBCARD_FOLDER
=
abspath
(
join
(
dirname
(
__file__
),
"
../../jobcards
"
))
# class TestCTRLmisc(unittest.TestCase):
# def test_invalid_jobcard(self):
TESTDATA_DIR
=
data_path
(
"
gibuu
"
)
class
TestCTRLbyJobcardFile
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
filename
=
join
(
JOBCARD_FOLDER
,
"
examples/example
.job
"
)
self
.
filename
=
join
(
TESTDATA_DIR
,
"
km3net_testdata
.job
"
)
self
.
output_dir
=
TemporaryDirectory
()
self
.
retval
=
run_jobcard
(
self
.
filename
,
self
.
output_dir
.
name
)
self
.
flux_file
=
NamedTemporaryFile
(
suffix
=
'
.dat
'
)
with
open
(
self
.
flux_file
.
name
,
'
w
'
)
as
f
:
ene
=
np
.
linspace
(
0.1
,
20
,
100
)
writer
=
csv
.
writer
(
f
,
delimiter
=
'
'
)
writer
.
writerows
(
zip
(
ene
,
np
.
power
(
ene
,
-
1
)))
self
.
retval
=
run_jobcard
(
self
.
filename
,
self
.
output_dir
.
name
,
fluxfile
=
self
.
flux_file
.
name
)
log
=
get_logger
(
"
ctrl.py
"
)
log
.
setLevel
(
"
INFO
"
)
...
...
@@ -38,7 +44,7 @@ class TestCTRLbyJobcardFile(unittest.TestCase):
def
test_output_files_existing
(
self
):
files
=
listdir
(
self
.
output_dir
.
name
)
assert
"
FinalEvents.da
t
"
in
files
assert
"
EventOutput.Pert.00000001.roo
t
"
in
files
class
TestCTRLbyJobcardObject
(
unittest
.
TestCase
):
...
...
This diff is collapsed.
Click to expand it.
km3buu/tests/test_output.py
+
8
−
0
View file @
07d27e4d
...
...
@@ -36,3 +36,11 @@ class TestGiBUUOutput(unittest.TestCase):
def
test_attr
(
self
):
assert
hasattr
(
self
.
output
,
"
df
"
)
def
test_mean_xsec
(
self
):
df
=
self
.
output
.
df
df
=
df
.
groupby
(
level
=
0
).
head
(
1
)
df
=
df
[(
df
.
lepIn_E
>
0.7
)
&
(
df
.
lepIn_E
<
1.0
)]
xsec
=
np
.
sum
(
df
.
xsec
/
df
.
lepIn_E
)
n_evts
=
self
.
output
.
flux_interpolation
.
integral
(
0.7
,
1.0
)
/
0.02
self
.
assertAlmostEqual
(
xsec
/
n_evts
,
0.8
,
places
=
2
)
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