SiLab-Bonn / pixel_clusterizer

A fast, generic, and easy to use clusterizer to cluster hits of a pixel matrix in Python.
MIT License
3 stars 0 forks source link

Wrong data type #8

Closed cbespin closed 7 years ago

cbespin commented 7 years ago

assigned_hit_array is boolean after init, but treated as an integer array in _cluster_hits.

laborleben commented 7 years ago

I don't think this is an issue. In C, a scalar is treated as follows:

6.3.1.2 Boolean type When any scalar value is converted to _Bool, the result is 0 if the value compares equal to 0; otherwise, the result is 1.

So 0 is equal to (==) false, 1 is equal to true and any number that is not false (0) evaluates to true.

C++ and Python have the same behavior.

0==False  # true
1==True  # true
2==True  # false
DavidLP commented 7 years ago

It is c after a numba type check and conversion and this is not defined anywhere. Even if this is not an issue now, it makes the code less read able.