Add array input support for the thor functor `F.VALUE_OR`
Following the discussion in #385 (comment 6119025), I tested to add the following line to the example example-tupling-mc-reconstructible-reconstructed.py
:
import Functors as F
vars_rted['TEST[TRACK_INDX]'] = F.VALUE_OR([1.]) @ mcrted_all.get_info( F.CHI2 @ F.TRACK )
which breaks the example because std::vector<double>
can not be initialised directly with std::vector<float>
.
As a cross-check, the old way to setup invalid values for array output still works:
import Functors as F
vars_rted['TEST[TRACK_INDX]'] = F.VALUE_OR(1.) @ mcrted_all.get_info( F.CHI2 @ F.TRACK )
because std::vector<double>
can be initialized with float
.
A summary of our discussion:
@jzhuo propose to use std::vector<double>( float_array.begin(), float_array.end() )
to initialize std::vector<double>
with an float array
@graven think the implicit conversion may be problematic since std::vector<double>( int_array.begin(), int_array.end() )
should not be silently ignored because it should never happen.
@amathad I think maybe we can introduce np.array
to distinguish the float
and double
types so std::vector<double>
can only be initialised with std::vector<double>
and not std::vector<float>