hail-is / hail

Cloud-native genomic dataframes and batch computing
https://hail.is
MIT License
984 stars 246 forks source link

[query] hl.nd.array has confusing behavior when given a Python array of Hail NDArrayExpression #13780

Open danking opened 1 year ago

danking commented 1 year ago

What happened?

This does not do I expected:

In [10]: hl.nd.array([hl.array([[[0,1],[2,3]],[[4,5],[6,7]]]), hl.array([[[0,1],[2,3]],[[4,5],[6,7]]])])
Out[10]: <NDArrayExpression of type ndarray<array<array<array<int32>>>, 1>>

This does what I expected:

In [11]: hl.nd.array(hl.array([hl.array([[[0,1],[2,3]],[[4,5],[6,7]]]), hl.array([[[0,1],[2,3]],[[4,5],[6,7]]])]))
Out[11]: <NDArrayNumericExpression of type ndarray<int32, 4>>

In particular, it seems that hl.nd.array flattens recursive lists, or recursive hl.array but it does not flatten a list of hl.array.

Version

0.2.124

Relevant log output

No response

danking commented 1 year ago

Reported here: https://hail.zulipchat.com/#narrow/stream/123010-Hail-Query-0.2E2-support/topic/Element.20Wise.20Sums