Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: polyfit([0],[0],1) crashes #29249

Open
@fstecker

Description

@fstecker

Describe the issue:

When I give polyfit a list of all zeros as the first argument, it crashes the kernel in a jupyter notebook. As a standalone script (code example below) I get the following output:

/usr/lib/python3.13/site-packages/numpy/lib/_polynomial_impl.py:674: RuntimeWarning: invalid value encountered in divide
  lhs /= scale
 ** On entry to DLASCL parameter number  4 had an illegal value

This is numpy 2.3.0, python 3.13 on Arch Linux. Also tested on a mac with numpy 1.26.4, there it throws an (expected) LinAlgError: SVD did not converge in Linear Least Squares instead.

Maybe this is related to #25982, but it's different in a few ways: it doesn't require degree 0, it leads to a crash, and I believe #25982 is already fixed in my version.

Reproduce the code example:

import numpy as np
np.polyfit([0],[0],1)

Error message:

/usr/lib/python3.13/site-packages/numpy/lib/_polynomial_impl.py:674: RuntimeWarning: invalid value encountered in divide
  lhs /= scale
 ** On entry to DLASCL parameter number  4 had an illegal value

Python and NumPy Versions:

python 3.13, numpy 2.3.0

Runtime Environment:

[{'numpy_version': '2.3.0',
'python': '3.13.3 (main, Apr 9 2025, 07:44:25) [GCC 14.2.1 20250207]',
'uname': uname_result(system='Linux', node='pig', release='6.15.2-arch1-1', version='#1 SMP PREEMPT_DYNAMIC Tue, 10 Jun 2025
21:32:33 +0000', machine='x86_64')},
{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2',
'AVX512F',
'AVX512CD',
'AVX512_SKX',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL'],
'not_found': ['AVX512_SPR']}},
{'filepath': '/usr/lib/libgomp.so.1.0.0',
'internal_api': 'openmp',
'num_threads': 32,
'prefix': 'libgomp',
'user_api': 'openmp',
'version': None}]

Context for the issue:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions