-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: remove string casting from ak.to_layout
#2098
Conversation
Codecov Report
Additional details and impacted files
|
Just adding support for bytestrings into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, so if to_layout
is passed a string (or bytestring) and allow_other=True
, ak_to_layout.py line 122 will return the string (or bytestring) as-is.
It's telling that no tests depended on this. That helpsto justify calling it a bug-fix.
It's good to merge!
Technically a couple of tests did implicitly — requiring that ufuncs support bare strings. I think the solution is actually closer to what we want to happen now, using |
@jpivarski before this makes it into a release ..., after our discussion about strings decaying to character arrays, do we want to revert this and replace it with a character-array codepath? |
I've lost track of what this refers to. What are you saying would be the consequences of cutting a release with this in it? |
This PR does two things:
We then spoke about single strings simply decaying to I think we still need the Making this release would mean that users could start relying on Footnotes
|
Perhaps it should not be used so loosely; functions that call it with The reimplementation to make this return an array of characters ("decay") would be pretty easy: >>> ak.to_layout(["hello"])[0]
<NumpyArray dtype='uint8' len='5'>
<parameter name='__array__'>'char'</parameter>
[104 101 108 108 111]
</NumpyArray> Since the old bug ( So yes, it would be good to update |
As per #2070, this PR changes
ak.to_layout("string")
to return the string (ifallow_other=True
).To support the primary use case of the old behaviour, a new
__cast__
behavior has been added for [byte]strings so that ufunc operations can accept Python strings.Changes
is_non_string_like_sequence
, renameis_non_string_like_iterable
helperto_layout
__cast__
support to string-likesis_non_string_like_iterable
withis_non_string_like_sequence
where appropriate