-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
ENH: allow single input argument in numpy.broadcast #6905
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
ENH: allow single input argument in numpy.broadcast #6905
Conversation
This change requires some tests to validate that it works. Also, there are three functions:
doing almost the exact same thing, and this change brings them slightly apart, which is not a good thing. Probably the right thing to do is to refactor the code so that there is a single implementation of the multi-iterator constructor that gets called by the others. But at the very least, the change should be made on all three. |
Where would such a test go? Would it be sufficient to just always use
I can easily do the least and adapt those three functions. Tests are also relevant here, I guess. |
I just found the dedicated |
Single-arg broadcast has a test now. I did not find a nice way to modify the existing list and get the desired result, so I added a few extra lines. |
I took the easy route and just changed numbers and error messages three times. The "proper" code refactoring goes beyond my knowledge of the C part. Question: are there dedicated tests for the |
@@ -2207,11 +2207,19 @@ def test_broadcast_in_args(self): | |||
for a, ia in zip(arrs, mit.iters): | |||
assert_(a is ia.base) | |||
|
|||
# gh-6899 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this deserves its own test method, test_broacast_single_arg
or something along that line.
☔ The latest upstream changes (presumably #6900) made this pull request unmergeable. Please resolve the merge conflicts. |
7e6a365
to
ec4d0b8
Compare
ec4d0b8
to
361c0d5
Compare
Rebased and streamlined the commits. Any further action necessary? |
One last request: I think this is worthy of a mention in the release notes. |
Sure, under which heading? Changes? |
Looking ok? |
ENH: allow single input argument in numpy.broadcast
Thanks Holger, in it goes. |
My pleasure! |
Follows on from numpygh-6905 which reduced the limit from 2 to 1. Let's go all the way to zero. Just as for `broadcast(broadcast(a), b)` is interpreted as `broadcast(a, b)` , this change interprets `broadcast(broadcast(), a)` as `broadcast(a)`.
Fixes #6899. The documentation does not mention any restriction, so I guess there is no need to adapt it?