Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
km3io
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
km3py
km3io
Commits
e6de27dc
Commit
e6de27dc
authored
5 years ago
by
Tamas Gal
Browse files
Options
Downloads
Patches
Plain Diff
Allow disabling numba jitted functions
parent
ba8a313d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitlab-ci.yml
+8
-0
8 additions, 0 deletions
.gitlab-ci.yml
km3io/daq.py
+22
-11
22 additions, 11 deletions
km3io/daq.py
tests/test_daq.py
+10
-0
10 additions, 0 deletions
tests/test_daq.py
with
40 additions
and
11 deletions
.gitlab-ci.yml
+
8
−
0
View file @
e6de27dc
...
...
@@ -62,6 +62,14 @@ test-py3.8:
-
make test
<<
:
*junit_definition
test-py3.8-no-numba
:
image
:
docker.km3net.de/base/python:3.8
stage
:
test
script
:
-
*virtualenv_definition
-
DISABLE_NUMBA=1 make test
<<
:
*junit_definition
code-style
:
image
:
docker.km3net.de/base/python:3.7
stage
:
test
...
...
This diff is collapsed.
Click to expand it.
km3io/daq.py
+
22
−
11
View file @
e6de27dc
import
os
import
uproot
import
numpy
as
np
import
numba
as
nb
if
os
.
getenv
(
"
DISABLE_NUMBA
"
):
print
(
"
Numba is disabled, DAQ helper functions will not work!
"
)
# A hack to to get the @vectorize, @guvectorize and nb.types silently pass.
def
dummy_decorator
(
*
args
,
**
kwargs
):
def
decorator
(
f
):
def
wrapper
(
*
args
,
**
kwargs
):
return
dummy_decorator
(
*
args
,
**
kwargs
)
return
wrapper
return
decorator
vectorize
=
dummy_decorator
guvectorize
=
dummy_decorator
int8
=
int16
=
int32
=
int64
=
dummy_decorator
else
:
from
numba
import
vectorize
,
guvectorize
,
int8
,
int16
,
int32
,
int64
TIMESLICE_FRAME_BASKET_CACHE_SIZE
=
523
*
1024
**
2
# [byte]
SUMMARYSLICE_FRAME_BASKET_CACHE_SIZE
=
523
*
1024
**
2
# [byte]
...
...
@@ -16,12 +32,7 @@ RATE_FACTOR = np.log(MAXIMAL_RATE_HZ / MINIMAL_RATE_HZ) / 255
CHANNEL_BITS_TEMPLATE
=
np
.
zeros
(
31
,
dtype
=
bool
)
@nb.vectorize
([
nb
.
int32
(
nb
.
int8
),
nb
.
int32
(
nb
.
int16
),
nb
.
int32
(
nb
.
int32
),
nb
.
int32
(
nb
.
int64
)
])
@vectorize
([
int32
(
int8
),
int32
(
int16
),
int32
(
int32
),
int32
(
int64
)])
def
get_rate
(
value
):
#pragma: no cover
"""
Return the rate in Hz from the short int value
"""
if
value
==
0
:
...
...
@@ -30,10 +41,10 @@ def get_rate(value): #pragma: no cover
return
MINIMAL_RATE_HZ
*
np
.
exp
(
value
*
RATE_FACTOR
)
@
nb.
guvectorize
(
"
void(i8, b1[:], b1[:])
"
,
"
(), (n) -> (n)
"
,
target
=
"
parallel
"
,
nopython
=
True
)
@guvectorize
(
"
void(i8, b1[:], b1[:])
"
,
"
(), (n) -> (n)
"
,
target
=
"
parallel
"
,
nopython
=
True
)
def
unpack_bits
(
value
,
bits_template
,
out
):
#pragma: no cover
"""
Return a boolean array for a value
'
s bit representation.
...
...
This diff is collapsed.
Click to expand it.
tests/test_daq.py
+
10
−
0
View file @
e6de27dc
...
...
@@ -175,6 +175,7 @@ class TestSummaryslices(unittest.TestCase):
def
test_rates
(
self
):
assert
3
==
len
(
self
.
ss
.
rates
)
@unittest.skipIf
(
os
.
getenv
(
"
DISABLE_NUMBA
"
),
reason
=
"
no numba
"
)
def
test_fifo
(
self
):
s
=
self
.
ss
.
slices
[
0
]
dct_fifo_stat
=
{
...
...
@@ -187,6 +188,7 @@ class TestSummaryslices(unittest.TestCase):
frame
=
s
[
s
.
dom_id
==
dom_id
]
assert
any
(
get_channel_flags
(
frame
.
fifo
[
0
]))
==
fifo_status
@unittest.skipIf
(
os
.
getenv
(
"
DISABLE_NUMBA
"
),
reason
=
"
no numba
"
)
def
test_has_udp_trailer
(
self
):
s
=
self
.
ss
.
slices
[
0
]
dct_udp_trailer
=
{
...
...
@@ -206,6 +208,7 @@ class TestSummaryslices(unittest.TestCase):
frame
=
s
[
s
.
dom_id
==
dom_id
]
assert
has_udp_trailer
(
frame
.
fifo
[
0
])
==
udp_trailer
@unittest.skipIf
(
os
.
getenv
(
"
DISABLE_NUMBA
"
),
reason
=
"
no numba
"
)
def
test_high_rate_veto
(
self
):
s
=
self
.
ss
.
slices
[
0
]
dct_high_rate_veto
=
{
...
...
@@ -246,6 +249,7 @@ class TestSummaryslices(unittest.TestCase):
frame
=
s
[
s
.
dom_id
==
dom_id
]
assert
any
(
get_channel_flags
(
frame
.
hrv
[
0
]))
==
high_rate_veto
@unittest.skipIf
(
os
.
getenv
(
"
DISABLE_NUMBA
"
),
reason
=
"
no numba
"
)
def
test_max_sequence_number
(
self
):
s
=
self
.
ss
.
slices
[
0
]
dct_seq_numbers
=
{
...
...
@@ -283,6 +287,7 @@ class TestSummaryslices(unittest.TestCase):
assert
get_udp_max_sequence_number
(
frame
.
dq_status
[
0
])
==
max_sequence_number
@unittest.skipIf
(
os
.
getenv
(
"
DISABLE_NUMBA
"
),
reason
=
"
no numba
"
)
def
test_number_udp_packets
(
self
):
s
=
self
.
ss
.
slices
[
0
]
dct_n_packets
=
{
...
...
@@ -312,6 +317,7 @@ class TestSummaryslices(unittest.TestCase):
frame
=
s
[
s
.
dom_id
==
dom_id
]
assert
get_number_udp_packets
(
frame
.
dq_status
[
0
])
==
n_udp_packets
@unittest.skipIf
(
os
.
getenv
(
"
DISABLE_NUMBA
"
),
reason
=
"
no numba
"
)
def
test_hrv_flags
(
self
):
s
=
self
.
ss
.
slices
[
0
]
dct_hrv_flags
=
{
...
...
@@ -347,6 +353,7 @@ class TestSummaryslices(unittest.TestCase):
for
a
,
b
in
zip
(
get_channel_flags
(
frame
.
hrv
[
0
]),
hrv_flags
)
])
@unittest.skipIf
(
os
.
getenv
(
"
DISABLE_NUMBA
"
),
reason
=
"
no numba
"
)
def
test_fifo_flags
(
self
):
s
=
self
.
ss
.
slices
[
0
]
dct_fifo_flags
=
{
...
...
@@ -399,14 +406,17 @@ class TestSummaryslices(unittest.TestCase):
class
TestGetRate
(
unittest
.
TestCase
):
@unittest.skipIf
(
os
.
getenv
(
"
DISABLE_NUMBA
"
),
reason
=
"
no numba
"
)
def
test_zero
(
self
):
assert
0
==
get_rate
(
0
)
@unittest.skipIf
(
os
.
getenv
(
"
DISABLE_NUMBA
"
),
reason
=
"
no numba
"
)
def
test_some_values
(
self
):
assert
2054
==
get_rate
(
1
)
assert
55987
==
get_rate
(
123
)
assert
1999999
==
get_rate
(
255
)
@unittest.skipIf
(
os
.
getenv
(
"
DISABLE_NUMBA
"
),
reason
=
"
no numba
"
)
def
test_vectorized_input
(
self
):
self
.
assertListEqual
([
2054
],
list
(
get_rate
([
1
])))
self
.
assertListEqual
([
2054
,
2111
,
2169
],
list
(
get_rate
([
1
,
2
,
3
])))
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