Skip to content

newint changes behavior of int on numpy.string_ conversion #196

Open
@ssolari

Description

@ssolari

newint blows up code that works with 'int' in python 2 on numpy strings. python 3 int works as expected. When both python 2 and python 3 int do the same thing, newint should probably maintain the default expected behavior.

Python 2.7.11 |Anaconda 2.5.0 (x86_64)| (default, Dec  6 2015, 18:57:58) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import numpy as np
>>> from builtins import int as newint
>>> int(np.string_('1'))
1
>>> newint(np.string_('1'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "~/anaconda/envs/py27/lib/python2.7/site-packages/future/types/newint.py", line 57, in __new__
    val = x.__int__()
TypeError: don't know how to convert scalar number to int

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions