-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
ENH: Solves #5407: Implement and test writable view for the diagonal function #5409
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
Conversation
The travis build succeeded, but running |
@maniteja123 it does. Did you do a full rebuild of numpy before running the test suite? That would explain it. Do |
@rgommers Thanks for reminding, my bad that I forgot you mentioned that the package needs to be rebuild to see the changes in the compiled code. I have rebuilt it and the test suite succeeded. |
The commit message should probably begin
Then expand on the details in the explanatory section after a blank line. Include |
Also, make a note in |
Oh, sorry I unnecessarily committed before asking for any more changes to be done. I will add it now. |
No problem. |
Is this fine ? |
I think you mean |
I guess it's too late for this, but what about a
|
@argriffing It was made not writable in 1.9 to smoke out such uses. Konrad has a point, but I'm not sure Python 3 is the best example of an alternative approach :) Numpy is, I think, settling in, radical changes are fewer than they have been. The question that concerns me at this point is how to make a transition to a better version, for once numpy settles, it will be outdated, yet its penetration will make transition to something better difficult. I've been toying with the idea of picking a 'stable' release and making larger changes thereafter. The question is, what should those changes be? I'm still keeping an eye on dynd and would like to help it into the larger world if that is possible. If you have any suggestions for moving numpy along I'd like to hear them. Speaking of which, would you like commit rights? Adding a |
The way this will happen is that Continuum will use its $millions to develop and promote pandas as a middleware shim between numpy and its users, and to simultaneously develop dynd as you suggest. Soon Pandas will support dynd, numpy, and dynd-premium, if it does not do this already. Eventually numpy will be deprecated and only dynd and dynd-premium will be used instead, and no former user of numpy will even notice. |
Well, I'm not sure if you are joking or not :) There is a ton of scientific code out there that doesn't use pandas. Konrad Hinson, for instance, has a lot of c code accessing the numpy api. I think we need something more straight forward here. Although changing imports is going to be a problem. It would be nice if something like
would do the trick. |
just asking out of curiosity, if I compare my issue5407 branch with numpy master branch |
@maniteja123 Not sure what you mean. Did you pull/merge anything into your branch or fork from something other than master? Note that if you make a new branch while in a branch other than master and don't explicitly base the new branch on master, it will be based on the branch you were in. You can fix that by |
I think there are strong arguments favoring
|
I had created from the master only and also rebased it in the start. I was referring to https://github.com/numpy/numpy/pull/5409/commits . I couldn't get how the first commit has come into this PR. |
BTW, what is the future of It is currently documented to return a copy:
but actually returns a read-only view
|
We could easily put off this change to a later release as well, if we want I am very strongly in favor of making changes like this on a
|
@abalkin The documentation suggests that the |
@maniteja123 Probably this means you have merged master into your branch. @abalkin Hmm, maybe |
@charris I did pick and squash by |
I could just find only this function with a common prefix and moreover the function |
@maniteja123, when you post links to specific lines, please use tags such as v1.9.1rc1 or commit hash values such as 261de3f in the URLs. Otherwise your links will become invalid soon. For example, the following two links to PyArray_NewFromDescr_int are stable: |
@abalkin Thanks for the heads up, I was just using the master branch to browse through the code. I just wanted to show the use of |
Coming to making a |
I think this is the commit that changed the return from a copy to a view, fd6cfd6, you can see there how it used to be implemented, |
@jaimefrio Oh, great. I get it now. So, it was initially returning a writable copy till 1.9, readable view in 1.9 and now a writable view in 1.10. But does adding a |
@charris You were saying that the result should be writable if the input array is writable. But if the flag is changeable, isn't this a risky operation ? |
You are currently only modifying the C API. Once you are finished with it, if a new argument is added, you also need to update the Python API. You will need to add the new You will also have to modify the signature and docstring of the And there are probably Lots of teeny details to take care of, and I may be forgetting something. That's what you get for messing with the API! :-) |
Is it really worth bothering adding a new C API function that just does (At the Python level, the argument is even more starkly against adding a On Fri, Jan 2, 2015 at 7:59 PM, Jaime notifications@github.com wrote:
Nathaniel J. Smith |
@jaimefrio Thanks. But if the signature is changed, updating the Python API means
Hope I got it right now :) |
@charris, I know there has been a lot of discussion on the mailing list, as well as here. I just wanted to inquire if there is a consensus reached. |
My preference at this point would be to revert the previous changes so that |
I also think the view should be ro if the array is. |
6973d5b
to
ad238c1
Compare
Sorry, I was trying to make the branch on par with master, and did Just to clarify,
|
I think doing |
@maniteja123 Could you open a new PR? |
@charris I will do it tonight, a little work now. Also, please do tell me if there is anything else to do than starting a new PR. |
Ah, sorry didn't see the needs decision label and 1.1.0 release milestone. Will start a new PR ASAP. |
Just a small doubt. If I need to open a new PR, there should be some changes committed in the branch. Right now, numpy/master and maniteja123/issue5407 are even and since this still needs a decision, what should I do ? |
This looks like it was marked as a 1.10 blocker, and was accidentally closed. |
Implements task raised in issue #5407.
The
ndarray.diagonal
method currently returns a view, but it is not writeable. It is documented to return a writeable view in 1.10.Correspondingly, the
writable
flag is set toTrue
and the assert statement and the test function are changed accordingly.