[PATCH] plot_strings.py: Replace np.complex with complex

Collin Funk collin.funk1@gmail.com
Tue Oct 21 23:39:46 GMT 2025


"H.J. Lu" <hjl.tools@gmail.com> writes:

> Replace np.complex with complex to fix numpy error:
>
> AttributeError: module 'numpy' has no attribute 'complex'.
> `np.complex` was a deprecated alias for the builtin `complex`. To avoid this error in existing code, use `complex` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.complex128` here.
> The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
>     https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
>
> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> ---
>  benchtests/scripts/plot_strings.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/benchtests/scripts/plot_strings.py b/benchtests/scripts/plot_strings.py
> index 3d0c2c5343..67228048b5 100755
> --- a/benchtests/scripts/plot_strings.py
> +++ b/benchtests/scripts/plot_strings.py
> @@ -54,7 +54,7 @@ def gmean(numbers):
>      Return:
>          numpy array with geometric means of numbers along each column
>      """
> -    a = np.array(numbers, dtype=np.complex)
> +    a = np.array(numbers, dtype=complex)
>      means = a.prod(0) ** (1.0 / len(a))
>      return np.real(means)

Looks obvious to me.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>

Collin


More information about the Libc-alpha mailing list