Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in the find_index functon #107

Open
fat-crocodile opened this issue Jul 19, 2022 · 1 comment
Open

Error in the find_index functon #107

fat-crocodile opened this issue Jul 19, 2022 · 1 comment

Comments

@fat-crocodile
Copy link

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)
@rougier
Copy link
Owner

rougier commented Aug 8, 2022

Sorry for late reply. You mean your fix solve the problem ? Could you make a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants