8000 MAINT: Simplify if statement by k-kapp · Pull Request #9168 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

MAINT: Simplify if statement #9168

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

Merged
merged 1 commit into from
May 27, 2017

Conversation

k-kapp
Copy link
Contributor
@k-kapp k-kapp commented May 24, 2017

isinstance(obj, ndarray) will return False if (obj is None) in any case,
so no need to check whether (obj is not None) before it. All tests
pass on my build (the most recent one at the time of making this PR).
However, this might have been done for backward compatibility (CI tests all pass, though).

isinstance(obj, ndarray) will return False if (obj is None) in any case,
so no need to check whether (obj is not None) before it. All tests
pass on my build (the most recent one at the time making this PR).
However, this might have been done for backward compatibility. Will see
how the CI tests do.
@mhvk
Copy link
Contributor
mhvk commented May 24, 2017

In general, one has to be a bit careful, since the obj is not None test is substantially faster than isinstance(obj, np.ndarray), but there what follows is more than enough to make that negligible.

p.s. Might it be an idea to go through the file a bit more to look for more clean-up?

@k-kapp
Copy link
Contributor Author
k-kapp commented May 24, 2017

Ah, I see. No problem - if I find anything else, just add it to this PR?

@mhvk
Copy link
Contributor
mhvk commented May 24, 2017

Yes, indeed. But don't worry if you don't find more or don't really have time --little improvements are welcome too. (But even just getting that particular file to conform to PEP8 a bit better would be nice... it always looks squiggly red in my emacs window.)

@k-kapp
Copy link
Contributor Author
k-kapp commented May 24, 2017

Ok, sure. I don't really look for these things explicitly, but I just notice things every now and then as I read through the source code and try to familiarize myself with it more. I normally submit the PRs immediately, otherwise I might forget!

A761

@charris charris merged commit c556b42 into numpy:master May 27, 2017
@charris
Copy link
Member
charris commented May 27, 2017

Thanks @k-kapp .

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

Successfully merging this pull request may close these issues.

3 participants
0