Skip to content

Conversation

seberg
Copy link
Member

@seberg seberg commented Feb 13, 2022

When the delimiter is None and we are splitting on whitespace,
a final empty field is always ignored to match the behaviour
of pythons split: " 1 ".split().

Closes gh-21052


Opted for a slightly different variant of cleaning this up in hindsight. There is a small thing that the "skip leading whitespace" may need some thought if we were to make it public. But I think using the special "delimiter is whitspace" state here, helps with ensuring that things won't go weird.

This includes my "move to cpp" commit, I assume that will be merged so I don't need to worry about it here.

f"1 2{ws}30\n\n{ws}\n"
f"4 5 60{ws}\n {ws} \n"
f"7 8 {ws} 90\n # comment\n"
f"3 2 1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about adding a regular ' ' space to the tests too?

Copy link
Member Author

@seberg seberg Feb 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, added it to the templating parametrization.

When the delimiter is None and we are splitting on whitespace,
a final empty field is always ignored to match the behaviour
of pythons split: `" 1 ".split()`.

Closes numpygh-21052
@mattip
Copy link
Member

mattip commented Feb 14, 2022

Build error with breathe not related to this PR, probably related to a new breathe version v4.33.0 and this bugfix for that release in v4.33.1

@mattip mattip merged commit 5eab643 into numpy:main Feb 14, 2022
@mattip
Copy link
Member

mattip commented Feb 14, 2022

Thanks @seberg

@seberg seberg deleted the fixup-no-delimiter branch February 14, 2022 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: loadtxt raises an issue on file that used to work
2 participants