-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
np.insert fails with float32, float64 input #378
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
Comments
This should fix the problems with numpy.insert(), where the input values were not checked for all scalar types and where values did not get inserted properly, but got duplicated by default.
This should fix the problems with numpy.insert(), where the input values were not checked for all scalar types and where values did not get inserted properly, but got duplicated by default.
Reworking insert for Issue #452 I have come to a point where I think that some clarification is necessary to decide what insert is supposed to do exactly. And since it is related to this issue and I its not quite fixed, I will hijack this here. This is basically how things work(ed) (ignoring repetition):
Note that this quite a big change for handleing of scalars, because of broadcasting! For example:
Now numpy 1.7 has an added extra. If
This is inconsistent in itself, because add one axis to
Now the way to make the 1.7 behavior consistent you can use
In a way I think that 1. has less surprises for the users ( Btw: option 1 would mean that (I think, too long staring at this):
|
To update I personally now think that option 2. from above is the only correct aproach (for consistency with Suggestion for 1.7?Its not my decision, but personally I would suggest reverting all changes in If you think that multiple insertion with a scalar should be allowed and introduced in 1.7, then it would be fine to to replace:
with:
which restores compatbility with 1.6. |
Hmm, yeah, I concur that #452 is (much) more consistent in handling the different use cases of insert. I hadn't considered the broadcasting behaviour, as well as the multidimensional slicing behaviour when implementing 8460514.. This also shows the necessity of comprehensive test cases to define function behaviour and act as safeguard against regressions; it is sometimes difficult to grok the full extent some change can have on a function. |
I think the multiple insertion feature should stay, however, because it has some nice use cases, imo. |
@87 yes the lack of tests really created this problem... My PR implements multiple insertion for both The deal is, 1.7 is about to be released and to my understanding my PR is too extensive a change (even if reworked on the booleans and disregarding delete) to include into it. And I would prefere to remove the new feature for the moment over introducing a regression which would have to be reverted again in the next release and for which implications in the wild are difficult to estimate. Though the fix I gave above seems minimal enough, so I guess that would likely be best. But it is in any case for the core devs to decide. |
This should be fixed with no remaining regressions after my last PR linked above, which is in 1.7. (and covered by tests). This means that maybe master still has a regression here, my reasoning back then was that I thought master will probably get a larger rewrite through my other PR at some point sooner or later in any case. |
Ok, I just want to make sure there's enough information here so that we can
|
yup exactly, 1.7. is fine with gh-2697 and 1.8. as of now lacks this. |
gh-452 merged, so closing this. |
(Though @seberg -- your last comment on this issue raised the negative indices question -- did that get resolved?) |
@njsmith, yes. There are now warnings for these cases (for delete anyway, for insert I think they just work, but previously they never did anything that made sense). So if I did everything as intended, there should be no real changes yet, just warnings. |
awesome On Thu, Apr 11, 2013 at 9:59 PM, seberg notifications@github.com wrote:
|
feat: Add vca[ge|le|gt|lt][q]_[f64|f32]
Namely
returns
because
insert
has aisinstance
that does not check for float32, float64, but only forint
,long
,integer
:Changing it to
seems only an half-assed solution though.
EDIT: forgot to mention that I'm using
numpy-1.8.0.dev_f2f0ac0_20120725-py2.7-macosx-10.8-x86_64.egg
.EDIT2: Probably a better solution for the
isinstance
part would be the followingThe text was updated successfully, but these errors were encountered: