-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Inconsistent integer conversion from strings (Trac #736) #1334
Comments
@stefanv wrote on 2008-04-12 Upon closing this ticket, please activate the test disabled in r5026. |
@charris wrote on 2008-04-13 There is more to this problem:
The ones that return arrays go though numpy routines that call PyNumber_Long on the string. I suspect int32 is a subtype of the python int so that it returns a number. We also have
In other words, we have an inconsistent mess on our hands. I think we need to decide what the behavior for all these functions should be, along with floats and complex, when presented with strings. And what to do when the strings are out of range. These problems arise in the setitem functions in arraytypes.inc.src and, I suspect, in the array function itself which treats the astype method and dtype keyword differently when strings are passed in. |
@charris wrote on 2008-04-13 I've fixed the conversions so that all integers convert strings. All except int32 also have the to many items problem.
The root of this seems to lie in the array creation function. |
@charris wrote on 2008-04-13 Travis, I think you are the best person to finish off this bug. |
@huard wrote on 2008-04-16 Replying to [comment:3 charris]:
But
Is it possible you added strict type checking ? |
@charris wrote on 2008-04-16 The routine effectively calls PyNumber_Long where it used to call PyInt_AsLong. My guess is that PyNumber_Long doesn't recognize timeseries.Date as a long. Is timeseries.Date a subtype of long/int? What does long(timeseries.Date) do? I suspect adding a long method will fix the problem. |
@charris wrote on 2008-04-16 Here's the problem in timeseries/src/c_dates.c
Note the missing conversion to long. Should be easy to fix. Who needs to be notified? |
@huard wrote on 2008-04-16 I notified Pierre G.M. this morning and he just made the change. Everything seems to work now. Thanks. |
@charris wrote on 2008-04-25 Fixed in r5080. The original example looks like it came from a 64 bit OS where the <i8 was the same as the python int, which always worked. |
Original ticket http://projects.scipy.org/numpy/ticket/736 on 2008-04-12 by @stefanv, assigned to @teoliphant.
Pauli Virtanen noticed the following behaviour (mentioned as part of #1317 discussion):
vs.
I believe this is related to the following inconsistent integer-from-string conversions:
The text was updated successfully, but these errors were encountered: