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.

`min`, `max` and `square` don't accept complex arrays

See original GitHub issue

Numpy has a (somewhat strange) policy of ordering according to real part first, and then breaking ties according to the imaginary part. CuPy currently raises the following error:

>>> a = cupy.array([1j, 2, 3])
>>> cupy.min(a)
TypeError                                 Traceback (most recent call last)
[...]/cupy/core/fusion.py in __call__(self, *args, **kwargs)
    819             return self._numpy_op(*args, **kwargs)
    820         else:
--> 821             return self._cupy_op(*args, **kwargs)
    822 
    823 

[...]/cupy/statistics/order.py in amin(a, axis, out, keepdims, dtype)
     30     """
     31     # TODO(okuta): check type
---> 32     return a.min(axis=axis, dtype=dtype, out=out, keepdims=keepdims)
     33 
     34 

[...]/cupy/core/core.pyx in cupy.core.core.ndarray.min()

[...]/cupy/core/core.pyx in cupy.core.core.ndarray.min()

[...]/cupy/core/reduction.pxi in cupy.core.core.simple_reduction_function.__call__()

[...]/cupy/core/elementwise.pxi in cupy.core.core._guess_routine()

TypeError: Wrong type ((<class 'numpy.complex128'>,)) of arguments for cupy_min

I don’t know if you want to follow Numpy here, but I guess a more specific error message would be a good thing in that case.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
leofangcommented, Mar 19, 2021

@kmaehashi this is fixed.

1reaction
okutacommented, Mar 3, 2019

We implemented some ufunc for complex (#1281).

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Why do we initially set min and max to the first value in ...
Setting min to 0 initially means that it will never change if all the values are > 0. Similarly for max if all...
Read more >
Chapter 4. NumPy Basics: Arrays and Vectorized Computation
Here are some of the things it provides: ndarray , a fast and space-efficient multidimensional array providing vectorized arithmetic operations and ...
Read more >
Computation on Arrays: Broadcasting | Python Data Science ...
Broadcasting is simply a set of rules for applying binary ufuncs (e.g., addition, subtraction, multiplication, etc.) on arrays of different sizes.
Read more >
Look Ma, No For-Loops: Array Programming With NumPy
Extending the logic from the pure-Python example, you can find the difference between each price and a running minimum (element-wise), and then take...
Read more >
Guidelines and examples of array formulas - Microsoft Support
You can use array formulas to perform complex tasks, such as: Quickly create sample datasets. Count the number of characters contained in a...
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