-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Failing interpolation test #5174
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
Does this make any sense? A float block with array of items with int dtype?
I'm in |
items are the 'index'...so that is right |
@cpcloud where do you see this failing? I can't repro on 64 or 32-bit |
spoke too soon! |
@TomAugspurger that test just needs to have the expected be |
So are you saying to change expected to |
@TomAugspurger you may also want to put some more creative logic in there for inference. Since we know that we are going to only float/int coming in, you could always infer the ints so that you will get ints if possible and the floats will stay floats. |
@TomAugspurger the result IS downcast (to int64), its the expected that is float64 |
Not for me: In [5]: result = sq.interpolate(method='quadratic')
In [6]: result
Out[6]:
1 1
2 4
3 9
4 16
dtype: float64 Can you clear this up for me? I think this is where things aren't going the same way. ipdb> !b
FloatBlock: 4 dtype: float64
ipdb> !b.values
array([ 1., 4., 9., 16.])
ipdb> !b.downcast(downcast)[0].values # should be ints?
array([ 1., 4., 9., 16.])
ipdb> downcast
'infer' That's in I'll dig a bit deeper. |
umm... in ipdb> result
array([ 1., 4., 9., 16.])
ipdb> result.astype(dtype)
array([ 1, 4, 8, 16])
ipdb> dtype
dtype('int64')
ipdb> but back at in the interpreter: In [10]: a.astype(np.int64)
Out[10]: array([ 1, 4, 9, 16])
In [11]: a = np.array([1., 4., 9., 16.])
In [12]: a.astype(np.int64)
Out[12]: array([ 1, 4, 9, 16]) |
This is a precision issue
thus this array is NOT equal to array([1,4,9,16]) thus should not be downcasted (though you can make a case that it close 'enough') to be....
should we round when trying to downcast to int? |
I think I should just do |
Fair enough. And users can override that with |
Or were you saying |
yes...they can specify |
see #5177 I think that should do it |
@TomAugspurger see if you think you need tests with |
jsut did on v0.12.0-993-gda89834
|
@yarikoptic can you show ci/print_versions? |
|
I've seen this consistently on OSX for the last week and a half as well. |
what kind of machine is this/linux kernel? |
@jtratner can you see what this does?
maybe need to put an argument there |
yes, won't have access until tonight. On Mon, Oct 28, 2013 at 11:58 AM, jreback [email protected] wrote:
|
In [1]: np.allclose(np.array([9.0005]),np.array([9.]))
Out[1]: False
In [2]: np.allclose(np.array([9.00005]),np.array([9.]))
Out[2]: True But I haven't sorted out my failing scipy tests due to precision errors, so I'm not sure how reliable my results are. |
@TomAugspurger are you showing this failure as well? |
Yep. The way I had it written originally (with expected as a float) passed on my system. Should I change expected to a float and set infer=False for this test? |
can you step thru and see why its not coercing? (it does on my system and on travis), put a break in |
I think that's what I posted up here When it tried to downcast the result' the 9 got flipped to an 8. Let me know if you were asking for something different. |
@TomAugspurger ahh...I c ....that is very odd....why would numpy flip the 9 float to an 8...(and only on mac)... I guess let's just change the test, e.g. |
@yarikoptic the fix @TomAugspurger put in should fix this problem....pls let us know and of course any other issues |
are you sure it's not a broader downcasting problem? and if it's a numpy |
see toms example from above I think it's a numpy bug (maybe only on Mac/Linux that's similar) it's the astype which fails on precision (I think) |
I saw that, just wasn't clear whether the repr sometimes rounds values or |
Also, the error itself seems confusing, given that it's not reproducible in |
I think it's 8.99999995 or something is getting astyped to 8 maybe I should round to like 5 decimal places first then astype |
So astype just floors it? |
prob I will something that can test with |
I wasn't sure what to title this issue. You're right that it's probably a numpy -Tom On Oct 28, 2013, at 16:48, "jreback" <[email protected]mailto:[email protected]> wrote: prob I will something that can test with — |
@jreback yep, you're right about the issue, so rounding would resolve it. In [25]: arr = np.array([8.5, 8.6, 8.7, 8.8, 8.9999999999995])
In [26]: arr
Out[26]: array([ 8.5, 8.6, 8.7, 8.8, 9. ])
In [27]: arr.astype(int)
Out[27]: array([8, 8, 8, 8, 8]) |
yep it's an easy fix ;I think I had it at one point),but took it out as I assumed astype did round and not floor |
The text was updated successfully, but these errors were encountered: