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.

`cupy.ndarray` cannot be compared with ellipsis

See original GitHub issue

Not sure if it’s due to #4198. The __richcmp__ method does not handle trivial comparison with Python objects correctly:

>>> np.empty(3) == ...
array([False, False, False])
>>>
>>> cp.empty(3) == ...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "cupy/_core/core.pyx", line 1094, in cupy._core.core.ndarray.__richcmp__
    return numpy.equal(self, other)
TypeError: operand type(s) all returned NotImplemented from __array_ufunc__(<ufunc 'equal'>, '__call__', array([0., 0., 0.]), Ellipsis): 'ndarray', 'ellipsis'

It seems NumPy internally calls PyObject_RichCompare to handle this. Perhaps before delegating to numpy.equal() (and friends) we should handle this edge case first?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
toslunarcommented, Sep 8, 2021

#1989 discusses comparison with None.

0reactions
takagicommented, Dec 17, 2021

As @toslunar mentioned in https://github.com/cupy/cupy/issues/5715#issuecomment-985991356, I think NumPy’s current code works without any problem. But, yes, your diff would be exactly what we want to do there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

`__eq__` to does not handle common non-ndarray types
A TypeError is raised when comparing ndarrays with unsupported dtypes for comparison ... cupy.ndarray cannot be compared with ellipsis #5715.
Read more >
cupy.ndarray
CuPy is an implementation of NumPy-compatible multi-dimensional array on CUDA. CuPy consists of cupy. ndarray, the core multi-dimensional ...
Read more >
Differences between CuPy and NumPy
Data type of CuPy arrays cannot be non-numeric like strings or objects. See Overview for details. Universal Functions only work with CuPy array...
Read more >
PDF - CuPy Documentation
CuPy is an implementation of NumPy-compatible multi-dimensional array on CUDA. CuPy consists of cupy. ndarray, the core multi-dimensional ...
Read more >
v9.1.0 PDF - CuPy Documentation
Data type of CuPy arrays cannot be non-numeric like strings or objects. ... a1 (cupy.ndarray) – Input array to compare.
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