Skip to content

Error in the find_index functon #107

Description

@fat-crocodile

Hi!

Z = base[6:2:-1, 5::-1]
find_index(base, Z)

produces an exception

TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'

The problem is here, in line 43

if step is not None and stop is not None:
if step < 0:
start, stop = stop, start - 1
else:
start, stop = start, stop + 1

We've checked that stop is not None, but step is less than zero and we didn't check start, BOOM!

I suggest code like this:

        if step is not None:
            if step < 0:
                start, stop = stop, start
            if stop is not None:
                stop += np.sign(step)

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions