Skip to content

Assigning to DeviceNDArray with Ellipsis fails #5170

Open

Description

@jakirkham

Reporting a bug

In [1]: import numba.cuda                                                       

In [2]: a = numba.cuda.device_array((10,))                                      

In [3]: a[...] = 1                                                              
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-4f8eed6187d7> in <module>
----> 1 a[...] = 1

/datasets/jkirkham/miniconda/envs/rapids13dev/lib/python3.7/site-packages/numba/cuda/cudadrv/devices.py in _require_cuda_context(*args, **kws)
    223     def _require_cuda_context(*args, **kws):
    224         with _runtime.ensure_context():
--> 225             return fn(*args, **kws)
    226 
    227     return _require_cuda_context

/datasets/jkirkham/miniconda/envs/rapids13dev/lib/python3.7/site-packages/numba/cuda/cudadrv/devicearray.py in __setitem__(self, key, value)
    528     @devices.require_context
    529     def __setitem__(self, key, value):
--> 530         return self._do_setitem(key, value)
    531 
    532     def setitem(self, key, value, stream=0):

/datasets/jkirkham/miniconda/envs/rapids13dev/lib/python3.7/site-packages/numba/cuda/cudadrv/devicearray.py in _do_setitem(self, key, value, stream)
    541         # (1) prepare LHS
    542 
--> 543         arr = self._dummy.__getitem__(key)
    544         newdata = self.gpu_data.view(*arr.extent)
    545 

/datasets/jkirkham/miniconda/envs/rapids13dev/lib/python3.7/site-packages/numba/dummyarray.py in __getitem__(self, item)
    217             item.append(slice(None, None))
    218 
--> 219         dims = [dim.__getitem__(it) for dim, it in zip(self.dims, item)]
    220         newshape = [d.size for d in dims if not d.single]
    221 

/datasets/jkirkham/miniconda/envs/rapids13dev/lib/python3.7/site-packages/numba/dummyarray.py in <listcomp>(.0)
    217             item.append(slice(None, None))
    218 
--> 219         dims = [dim.__getitem__(it) for dim, it in zip(self.dims, item)]
    220         newshape = [d.size for d in dims if not d.single]
    221 

/datasets/jkirkham/miniconda/envs/rapids13dev/lib/python3.7/site-packages/numba/dummyarray.py in __getitem__(self, item)
     70             return ret
     71         else:
---> 72             sliced = self[item:item + 1]
     73             return Dim(
     74                 start=sliced.start,

TypeError: unsupported operand type(s) for +: 'ellipsis' and 'int'

Activity

  1. esc commented on Jan 31, 2020

    @esc
    Member

    @jakirkham thanks for reporting this, I can reproduce it locally (on a remote GPU machine). I am not sure if this should be labelled as a bug or as a feature. Do the docs at http://numba.pydata.org/numba-doc/latest/cuda/cudapysupported.html don't make any mention of the term 'ellipsis'.

  2. jakirkham commented on Jan 31, 2020

    @jakirkham
    ContributorAuthor

    FWIW a[:] = 1 is a viable alternative. Note the behavior of NumPy would be to allow a[...] = 1.

  3. stuartarchibald commented on Feb 3, 2020

    @stuartarchibald
    Contributor

    Looks like numba.dummyarray.DummyArray needs updating so that Dim takes an ellipse.

  4. coderay3000 commented on Aug 16, 2026

    @coderay3000
    Contributor

    Hi @stuartarchibald @gmarkall , I 'd like to work on this issue . Could you please assign it to me ?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    CUDACUDA related issue/PRbuggood first issueA good issue for a first time contributor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions