scikit-hep / awkward-0.x

Manipulate arrays of complex data structures as easily as Numpy.
BSD 3-Clause "New" or "Revised" License
215 stars 39 forks source link

Fix unexpected dtype change in JaggedArray._concatenate_axis1 #248

Closed bfis closed 4 years ago

bfis commented 4 years ago

JaggedArray._concatenate_axis1 performs an unexpected dtype change, e.g. two JaggedArrays with np.float32 dtype will result in one JaggedArray with dtype np.float64.

This is caused by the built-in sum(x) function which does behave like reduce(lambda a, b: a + b, x, int(0)) i.e. with an explicit initializer=0 for reduce.

Using numpy.sum is not an option either since it has special dtype determination rules regarding integers.

I've also added a corresponding test.

jpivarski commented 4 years ago

Okay, thanks! I'll merge it now and deploy a new release soon.