Skip to content

BUG: Large distances between start and stop in np.linspace() result in non-finite values #21585

@honno

Description

@honno

Describe the issue:

I'm guessing some internal logic causes this issue, like in #20226. Given it's such an edge case this is probably not worth fixing, just thought I'd write an issue for prosperity's sake.

Reproduce the code example:

>>> np.linspace(-9.9792015476736e+291, 1.7976931348623157e+308, 1)
RuntimeWarning: overflow encountered in double_scalars
  delta = stop - start
RuntimeWarning: invalid value encountered in multiply
  y = y * delta
array([nan])  # expected -9.9792015476736e+291
>>> np.linspace(-9.9792015476736e+291, 1.7976931348623157e+308, 5)
... same warnings ...
array([ nan, inf, inf, inf, 1.79769313e+308] )  # expected finite values in-between

NumPy/Python version information:

1.23.0.dev0+1084.g5ab08cfa8 3.8.12 (default, Mar 13 2022, 19:12:08)
[GCC 9.4.0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    00 - Bug57 - Close?Issues which may be closable unless discussion continued

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions