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

ndarray.flat does not support setitem #3120

Open
stuartarchibald opened this issue Jul 17, 2018 · 0 comments
Open

ndarray.flat does not support setitem #3120

stuartarchibald opened this issue Jul 17, 2018 · 0 comments
Labels
bug - ice Bugs: internal compiler error numpy
Projects

Comments

@stuartarchibald
Copy link
Contributor

Following on from #3117, setitem on flat does not work.

from numba import njit
import numpy as np
@njit
def flat(X, d):
    N = X.shape[0]
    X.flat[:N**2:N+1] = d

d = 10
X = np.ones((5, 5))
flat(X, d)

gives:

$ python foo2.py 
Traceback (most recent call last):
  File "<path>/numba/errors.py", line 595, in new_error_context
    yield
  File "<path>/numba/lowering.py", line 254, in lower_block
    self.lower_inst(inst)
  File "<path>/numba/lowering.py", line 358, in lower_inst
    return self.lower_setitem(inst.target, inst.index, inst.value, signature)
  File "<path>/numba/lowering.py", line 416, in lower_setitem
    impl = self.context.get_function('setitem', signature)
  File "<path>/numba/targets/base.py", line 537, in get_function
    return self.get_function(fn, sig, _firstcall=False)
  File "<path>/numba/targets/base.py", line 539, in get_function
    raise NotImplementedError("No definition for lowering %s%s" % (key, sig))
NotImplementedError: No definition for lowering setitem(array.flat(array(float64, 2d, C)), slice<a:b:c>, array.flat(array(float64, 2d, C))) -> none

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "foo2.py", line 10, in <module>
    flat(X, d)
  File "<path>/numba/dispatcher.py", line 368, in _compile_for_args
    raise e
  File "<path>/numba/dispatcher.py", line 325, in _compile_for_args
    return self.compile(tuple(argtypes))
  File "<path>/numba/dispatcher.py", line 653, in compile
    cres = self._compiler.compile(args, return_type)
  File "<path>/numba/dispatcher.py", line 83, in compile
    pipeline_class=self.pipeline_class)
  File "<path>/numba/compiler.py", line 881, in compile_extra
    return pipeline.compile_extra(func)
  File "<path>/numba/compiler.py", line 368, in compile_extra
    return self._compile_bytecode()
  File "<path>/numba/compiler.py", line 812, in _compile_bytecode
    return self._compile_core()
  File "<path>/numba/compiler.py", line 799, in _compile_core
    res = pm.run(self.status)
  File "<path>/numba/compiler.py", line 254, in run
    raise patched_exception
  File "<path>/numba/compiler.py", line 246, in run
    stage()
  File "<path>/numba/compiler.py", line 679, in stage_nopython_backend
    self._backend(lowerfn, objectmode=False)
  File "<path>/numba/compiler.py", line 629, in _backend
    lowered = lowerfn()
  File "<path>/numba/compiler.py", line 616, in backend_nopython_mode
    self.flags)
  File "<path>/numba/compiler.py", line 1000, in native_lowering_stage
    lower.lower()
  File "<path>/numba/lowering.py", line 173, in lower
    self.lower_normal_function(self.fndesc)
  File "<path>/numba/lowering.py", line 214, in lower_normal_function
    entry_block_tail = self.lower_function_body()
  File "<path>/numba/lowering.py", line 239, in lower_function_body
    self.lower_block(block)
  File "<path>/numba/lowering.py", line 254, in lower_block
    self.lower_inst(inst)
  File "<env>/lib/python3.6/contextlib.py", line 99, in __exit__
    self.gen.throw(type, value, traceback)
  File "<path>/numba/errors.py", line 603, in new_error_context
    six.reraise(type(newerr), newerr, tb)
  File "<path>/numba/six.py", line 658, in reraise
    raise value.with_traceback(tb)
  File "<path>/numba/errors.py", line 595, in new_error_context
    yield
  File "<path>/numba/lowering.py", line 254, in lower_block
    self.lower_inst(inst)
  File "<path>/numba/lowering.py", line 358, in lower_inst
    return self.lower_setitem(inst.target, inst.index, inst.value, signature)
  File "<path>/numba/lowering.py", line 416, in lower_setitem
    impl = self.context.get_function('setitem', signature)
  File "<path>/numba/targets/base.py", line 537, in get_function
    return self.get_function(fn, sig, _firstcall=False)
  File "<path>/numba/targets/base.py", line 539, in get_function
    raise NotImplementedError("No definition for lowering %s%s" % (key, sig))
numba.errors.LoweringError: Failed at nopython (nopython mode backend)
No definition for lowering setitem(array.flat(array(float64, 2d, C)), slice<a:b:c>, array.flat(array(float64, 2d, C))) -> none

File "foo2.py", line 6:
def flat(X, d):
    <source elided>
    N = X.shape[0]
    X.flat[:N**2:N+1] = d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug - ice Bugs: internal compiler error numpy
Projects
Bugs
Cause Understood
Development

No branches or pull requests

2 participants