Skip to content

Broadcasting lists with different structures #2118

Answered by agoose77
Durman asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @Durman,

To start with, I commend you on going the distance in trying to figure this out. We consider our Content classes to be advanced features that most users of the library should never need to know about. You were pretty close with your first attempt!

The first difference here is that NumPy performs right broadcasting:

>>> np.broadcast_shapes(
...     (4, 3, 7,),
...           (7,)
... )
(4, 3, 7)

which aligns elements "to the right".

Awkward supports this broadcasting for entirely-regular (NumPy-like) arrays

>>> ak.from_numpy(np.zeros((4, 3, 7))) + ak.Array([1, 2, 3, 4, 5, 6, 7])
<Array [[[1, 2, 3, 4, 5, 6, 7], ..., [1, ...]], ...] type='4 * 3 * 7 * float64'>

But for any broadcas…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Durman
Comment options

@agoose77
Comment options

Answer selected by Durman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants