KEMBAR78
linspace does not properly handle denormal values · Issue #5437 · numpy/numpy · GitHub
Skip to content

linspace does not properly handle denormal values #5437

@njsmith

Description

@njsmith

This is pretty low priority since AFAIK no user has actually run into this, but, since it was pointed out on python-ideas:

In [4]: np.linspace(0, 2e-323, 10)
Out[4]: 
array([  0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
         0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
         0.00000000e+000,   0.00000000e+000,   0.00000000e+000,
         1.97626258e-323])

The problem is that linspace does step = (stop - start) / (samples - 1), and here that becomes

In [5]: (2e-323 - 0) / 9
Out[5]: 0.0

The correct output would be something like [0, 0, 5e-324, 5e-324, ...].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions