question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nested reflected list fails to type with inner lists of differing types.

See original GitHub issue

The code below works:

import numpy as np
import numba as nb

@nb.njit()
def func():
    inp_arr = np.array([2, 3j], dtype =nb.complex128)
    return

func()

but if you make it a multidimensional array, such as in the code below, the code breaks:

import numpy as np
import numba as nb

@nb.njit()
def func():
    inp_arr = np.array([[1, 0],
                        [2, 3j]], dtype =nb.complex128)
    return

func()

This gives me the error:

Traceback (most recent call last):

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\spyder_kernels\py3compat.py", line 356, in compat_exec
    exec(code, globals, locals)

  File "c:\users\micha\onedrive\documenten\uni shit\thesis\pythonforthesis\untitled0.py", line 10, in <module>
    func()

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\dispatcher.py", line 487, in _compile_for_args
    raise e

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\dispatcher.py", line 420, in _compile_for_args
    return_val = self.compile(tuple(argtypes))

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\dispatcher.py", line 965, in compile
    cres = self._compiler.compile(args, return_type)

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\dispatcher.py", line 125, in compile
    status, retval = self._compile_cached(args, return_type)

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\dispatcher.py", line 139, in _compile_cached
    retval = self._compile_core(args, return_type)

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\dispatcher.py", line 152, in _compile_core
    cres = compiler.compile_extra(self.targetdescr.typing_context,

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\compiler.py", line 693, in compile_extra
    return pipeline.compile_extra(func)

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\compiler.py", line 429, in compile_extra
    return self._compile_bytecode()

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\compiler.py", line 497, in _compile_bytecode
    return self._compile_core()

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\compiler.py", line 476, in _compile_core
    raise e

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\compiler.py", line 463, in _compile_core
    pm.run(self.state)

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\compiler_machinery.py", line 353, in run
    raise patched_exception

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\compiler_machinery.py", line 341, in run
    self._runPass(idx, pass_inst, state)

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\compiler_lock.py", line 35, in _acquire_compile_lock
    return func(*args, **kwargs)

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\compiler_machinery.py", line 296, in _runPass
    mutated |= check(pss.run_pass, internal_state)

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\compiler_machinery.py", line 269, in check
    mangled = func(compiler_state)

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\typed_passes.py", line 394, in run_pass
    lower.lower()

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\lowering.py", line 196, in lower
    self.lower_normal_function(self.fndesc)

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\lowering.py", line 250, in lower_normal_function
    entry_block_tail = self.lower_function_body()

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\lowering.py", line 279, in lower_function_body
    self.lower_block(block)

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\lowering.py", line 293, in lower_block
    self.lower_inst(inst)

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\lowering.py", line 438, in lower_inst
    val = self.lower_assign(ty, inst)

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\lowering.py", line 624, in lower_assign
    return self.lower_expr(ty, value)

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\lowering.py", line 1319, in lower_expr
    castvals = [self.context.cast(self.builder, val, fromty,

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\lowering.py", line 1319, in <listcomp>
    castvals = [self.context.cast(self.builder, val, fromty,

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\core\base.py", line 713, in cast
    return impl(self, builder, fromty, toty, val)

  File "C:\Users\Micha\Downloads\Laptop-Python\ANACONDA\lib\site-packages\numba\cpython\listobj.py", line 1131, in list_to_list
    assert fromty.dtype == toty.dtype

AssertionError: Failed in nopython mode pipeline (step: native lowering)

Issue Analytics

  • State:open
  • Created 9 months ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
esccommented, Dec 13, 2022

Comment from the dev meeting: probably a better error message is worthwhile.

0reactions
esccommented, Dec 8, 2022

@Rafnus since this concerns the reflected list which is deprecated, I think this is a bug, but it is unlikely that anyone will fix this.

See also: https://numba.readthedocs.io/en/stable/reference/pysupported.html#list

Read more comments on GitHub >

github_iconTop Results From Across the Web

List of lists changes reflected across sublists unexpectedly
Creates a list that references the internal [1,1,1,1] 3 times - not three copies of the inner list, so any time you modify...
Read more >
11. Lists — How to Think Like a Computer Scientist
A list within another list is said to be nested. Finally, a list with no elements is called an empty list, and is...
Read more >
Built-in Types — Python 3.11.1 documentation
This table lists the sequence operations sorted in ascending priority. In the table, s and t are sequences of the same type, n,...
Read more >
Tutorial: Querying nested data with Amazon Redshift Spectrum
Amazon Redshift Spectrum supports querying nested data in Parquet, ORC, JSON, and Ion file formats. Redshift Spectrum accesses the data using external tables....
Read more >
Nested Lists and Nested Loops
We've seen that we can have lists where the elements are different types. If the elements of a list are themselves type list,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found