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

Tuples containing bools do not work with numba.typed.List or numba.typed.Dict #4520

Closed
2 tasks done
alanhdu opened this issue Sep 5, 2019 · 1 comment
Closed
2 tasks done
Labels
Milestone

Comments

@alanhdu
Copy link
Contributor

alanhdu commented Sep 5, 2019

On the latest release (v0.35.1) on Python 3.7, the following:

import numba
numba.typed.List.empty_list(numba.typeof(("hello", True)))

fails with:

Stack Trace
TypingError                               Traceback (most recent call last)
<ipython-input-45-d29ae2daf2f2> in <module>
----> 1 l = numba.typed.List.empty_list(numba.typeof((0.0, "hello", True)))

/opt/anaconda/envs/test/lib/python3.7/site-packages/numba/typed/typedlist.py in empty_list(cls, item_type)
    149         of the list .
    150         """
--> 151         return cls(lsttype=ListType(item_type))
    152 
    153     def __init__(self, **kwargs):

/opt/anaconda/envs/test/lib/python3.7/site-packages/numba/typed/typedlist.py in __init__(self, **kwargs)
    164         """
    165         if kwargs:
--> 166             self._list_type, self._opaque = self._parse_arg(**kwargs)
    167         else:
    168             self._list_type = None

/opt/anaconda/envs/test/lib/python3.7/site-packages/numba/typed/typedlist.py in _parse_arg(self, lsttype, meminfo)
    175             opaque = meminfo
    176         else:
--> 177             opaque = _make_list(lsttype.item_type)
    178         return lsttype, opaque
    179 

/opt/anaconda/envs/test/lib/python3.7/site-packages/numba/dispatcher.py in _compile_for_args(self, *args, **kws)
    374                 e.patch_message(msg)
    375 
--> 376             error_rewrite(e, 'typing')
    377         except errors.UnsupportedError as e:
    378             # Something unsupported is present in the user code, add help info

/opt/anaconda/envs/test/lib/python3.7/site-packages/numba/dispatcher.py in error_rewrite(e, issue_type)
    341                 raise e
    342             else:
--> 343                 reraise(type(e), e, None)
    344 
    345         argtypes = []

/opt/anaconda/envs/test/lib/python3.7/site-packages/numba/six.py in reraise(tp, value, tb)
    656             value = tp()
    657         if value.__traceback__ is not tb:
--> 658             raise value.with_traceback(tb)
    659         raise value
    660 


TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function(<function new_list at 0x7f29d63d4510>) with argument(s) of type(s): (typeref[(unicode_type, bool)])
 * parameterized
In definition 0:
    LoweringError: Failed in nopython mode pipeline (step: nopython mode backend)
expecting {{i8*, i64, i32, i32, i64, i8*, i8*}, i1} but got {{i8*, i64, i32, i32, i64, i8*, i8*}, i8}

File "../../opt/anaconda/envs/test/lib/python3.7/site-packages/numba/listobject.py", line 347:
    def imp(item):
        <source elided>
        lp = _list_new(itemty)
        _list_set_method_table(lp, itemty)
        ^

[1] During: lowering "$0.7 = call $0.4(lp, $0.6, func=$0.4, args=[Var(lp, /opt/anaconda/envs/test/lib/python3.7/site-packages/numba/listobject.py (346)), Var($0.6, /opt/anaconda/envs/test/lib/python3.7/site-packages/numba/listobject.py (347))], kws=(), vararg=None)" at /opt/anaconda/envs/test/lib/python3.7/site-packages/numba/listobject.py (347)
    raised from /opt/anaconda/envs/test/lib/python3.7/site-packages/numba/six.py:659
In definition 1:
    LoweringError: Failed in nopython mode pipeline (step: nopython mode backend)
expecting {{i8*, i64, i32, i32, i64, i8*, i8*}, i1} but got {{i8*, i64, i32, i32, i64, i8*, i8*}, i8}

File "../../opt/anaconda/envs/test/lib/python3.7/site-packages/numba/listobject.py", line 347:
    def imp(item):
        <source elided>
        lp = _list_new(itemty)
        _list_set_method_table(lp, itemty)
        ^

[1] During: lowering "$0.7 = call $0.4(lp, $0.6, func=$0.4, args=[Var(lp, /opt/anaconda/envs/test/lib/python3.7/site-packages/numba/listobject.py (346)), Var($0.6, /opt/anaconda/envs/test/lib/python3.7/site-packages/numba/listobject.py (347))], kws=(), vararg=None)" at /opt/anaconda/envs/test/lib/python3.7/site-packages/numba/listobject.py (347)
    raised from /opt/anaconda/envs/test/lib/python3.7/site-packages/numba/six.py:659
This error is usually caused by passing an argument of a type that is unsupported by the named function.
[1] During: resolving callee type: Function(<function new_list at 0x7f29d63d4510>)
[2] During: typing of call at /opt/anaconda/envs/test/lib/python3.7/site-packages/numba/typed/typedlist.py (29)

It looks like using a tuple of (int32, bool) works fine, however.

Reporting a bug

@sklam
Copy link
Member

sklam commented Sep 5, 2019

Yes, I am confirm that this is a bug.

expecting {{i8*, i64, i32, i32, i64, i8*, i8*}, i1} but got {{i8*, i64, i32, i32, i64, i8*, i8*}, i8}

It's missing a conversion to addressable representation

@sklam sklam added the bug label Sep 5, 2019
@sklam sklam added this to the Numba 0.46 RC milestone Sep 9, 2019
sklam added a commit to sklam/numba that referenced this issue Sep 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants