Skip to content

Getting size of a given dimension #1654

Answered by jpivarski
grst asked this question in Q&A
Aug 31, 2022 · 2 comments · 10 replies
Discussion options

You must be logged in to vote

As usual, @agoose77 beat me to an answer again! (Sarcasm: I don't mind!)

I was writing an answer that uses the new ak.transform (PR #1610), which I think was inspired, or at least got bumped up in priority by your problem. (It fulfills an old issue #516.) The goal of this interface was to provide a public API for the function we use internally to define functions like these, which would streamline the process of absorbing it into the Awkward codebase, once we have a good idea of what the general API should look like.

Here's what I came up with, and most of the complication is dealing with the fact that union types introduce branches.

def dim_len(array, axis):
    if axis < 0:   # negative…

Replies: 2 comments 10 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
10 replies
@ivirshup
Comment options

@agoose77
Comment options

@jpivarski
Comment options

@grst
Comment options

@jpivarski
Comment options

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