Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

BUG: numpy.fromstring returns additional -1. not present in the string when it contains a trailing delimiter  #23350

Copy link
Copy link
Open
@maarten-vandenberg

Description

@maarten-vandenberg
Issue body actions

Describe the issue:

Hi,

we are using numpy.fromstring to read data from a string. Usually, the string we pass to fromstring does not contain a trailing delimiter (","). However, in a recent application it did: the data in the string was followed by a trailing delimiter and whitespace. We find that in that case fromstring returns an additional -1.0 in the resulting array.

import numpy as np

x = np.fromstring("0, ", sep=",")
print(x)
# array([ 0., -1.])

I would expect fromstring to simply return array([0.]). Hopefully you can help me find what is going on here (and if it's an actual bug), many thanks.

Reproduce the code example:

import numpy as np

x = np.fromstring("0, ", sep=",")
print(x)
# array([ 0., -1.])

Error message:

There is no error message

Runtime information:

sys.version:
3.11.0 | packaged by conda-forge | (main, Oct 25 2022, 06:12:32) [MSC v.1929 64 bit (AMD64)]
numpy.version:
1.24.2
numpy.show_runtime()
WARNING: threadpoolctl not found in system! Install it by pip install threadpoolctl. Once installed, try np.show_runtime again for more detailed build information
[{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2',
'AVX512F',
'AVX512CD',
'AVX512_SKX',
'AVX512_CLX'],
'not_found': ['AVX512_CNL', 'AVX512_ICL']}}]
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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.