Skip to content
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

Feature request: Support str(<int>) and more generally str. #4705

Open
ghost opened this issue Oct 15, 2019 · 2 comments
Open

Feature request: Support str(<int>) and more generally str. #4705

ghost opened this issue Oct 15, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Oct 15, 2019

This is my python code:

import random
#         A B C D E F G H K J
myList = [0,1,2,3,4,5,6,7,8,9]

def scramble(aList):
  while True:
    randomlist = []
    newList = []
    length = len(aList)
    while length!=len(randomlist):
      rand = random.randint(0, length-1)
      if rand not in randomlist:
        randomlist.append(rand)
    for i in range(len(aList)):
      newList.append(aList[randomlist[i]])
    myList = newList
    GHF = (myList[6]*100 + myList[7]*10 +myList[5])
    JEF = (myList[9]*100 + myList[4]*10 +myList[5])
    AJF = (myList[0]*100 + myList[9]*10 +myList[5])
    JDE = (myList[9]*100 + myList[3]*10 +myList[4])*10
    FBD = (myList[5]*100 + myList[1]*10 +myList[3])*100
    add = (FBD+JDE+AJF)
    FCAKF= int(str(myList[5])+str(myList[2])+str(myList[0])+str(myList[8])+str(myList[5]))
    if (JEF*GHF)==FCAKF and len(str(JEF))==len(str(GHF))==3 and add==FCAKF:
      print('  ',GHF)
      print(' X',JEF)
      print('---------')
      print('  ',AJF)
      print(' ',JDE)
      print('',FBD)
      print('',FCAKF)
      break
scramble(myList)

====================================================================

This is the error:

Traceback (most recent call last):
  File "/Users/m3hdi/Documents/Python3/numba_test.py", line 38, in <module>
    scramble(myList)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numba/dispatcher.py", line 376, in _compile_for_args
    error_rewrite(e, 'typing')
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numba/dispatcher.py", line 343, in error_rewrite
    reraise(type(e), e, None)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numba/six.py", line 658, in reraise
    raise value.with_traceback(tb)
numba.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Untyped global name 'str': cannot determine Numba type of <class 'type'>

File "Documents/Python3/numba_puzzle.py", line 26:
def scramble(aList):
    <source elided>
    add = (FBD+JDE+AJF)
    FCAKF= int(str(myList[5])+str(myList[2])+str(myList[0])+str(myList[8])+str(myList[5]))
    ^

This is not usually a problem with Numba itself but instead often caused by
the use of unsupported features or an issue in resolving types.

To see Python/NumPy features supported by the latest release of Numba visit:
http://numba.pydata.org/numba-doc/latest/reference/pysupported.html
and
http://numba.pydata.org/numba-doc/latest/reference/numpysupported.html

For more information about typing errors and how to debug them visit:
http://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-doesn-t-compile

If you think your code should work with Numba, please report the error message
and traceback, along with a minimal reproducer at:
https://github.com/numba/numba/issues/new
@stuartarchibald
Copy link
Contributor

Thanks for the report.

RE formatting in GitHub issues, for future reference triple backticks are needed around a code block (with optional language syntax specified), for example: ```python <your code> ```. GitHub also has a basic guide to its markdown syntax available here.

@stuartarchibald stuartarchibald changed the title Numba gives a type error: numba.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend) Feature request: Support str(<int>) and more generally str. Oct 15, 2019
@stuartarchibald
Copy link
Contributor

I've updated the issue with markdown syntax and changed the title to reflect what the issue is. Essentially Numba does not yet have support for str() as a method on constructing strings from any type at all, labelling this as a feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant