Skip to content

Use the same code to handle all negative axis arguments #8583

Closed

Description

@eric-wieser

Right now we throw a whole bunch of subtly different error messages for this.

Something like

class AxisError(IndexError): pass

def resolve_axis(axis, ndim):
    if not (-ndim <= axis < axis):
        raise AxisError('axis {0} out of bounds [-{1}, {1})'.format(axis, nd))
    if axis < 0:
        axis += ndim
    return axis

But this would preferably be done C-side, to ensure those cases also give the same message

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions