Skip to content
Snippets Groups Projects
Commit e4a0496d authored by Tamas Gal's avatar Tamas Gal :speech_balloon:
Browse files

Merge branch 'make-bit-checker-numba-compatible' into 'master'

Make bit checker numba compatible

See merge request !66
parents 4b8448f0 88371693
No related branches found
No related tags found
1 merge request!66Make bit checker numba compatible
Pipeline #23220 passed
Unreleased changes
------------------
* The ``km3io.tools.is_bit_set()`` and all the related trigger mask checkers
(``is_3dmuon()``...) are now compatible with Numba
Version 0
---------
......
......@@ -493,15 +493,16 @@ def usr(objects, field):
return objects.usr[:, idx]
@nb.vectorize(("boolean(int64, int64)", "boolean(uint64, int64)"), nopython=True)
def is_bit_set(value, bit_position):
"""Returns true if a bit at the given position is 1.
value: int or array(int)
value: int or array([u]int64)
The value to check, can be a single value or an array of values.
bit_position: int
0 for the first position, 1 for the second etc.
"""
return (np.array(value) & (1 << bit_position)).astype(bool)
return bool(value & (1 << bit_position))
def is_3dshower(trigger_mask):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment