ENH: Provide functions to convert the axes of object arrays to and from lists #15091
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #14478.
This pull request implements functionalities asked for in #14478.
I decided to implement the function converting arrays to arrays of lists in a way that allows choosing the axis to convert, as if we always converted the last (or next-to-last, depending how we look at it) axis, then those functions wouldn't be inverses of eachother; for example, converting
array([list([[1, 2], [3, 4]])])
with array_of_lists_to_array results in
array([[[1, 2], [3, 4]]])
but converting the last axis of the above array into lists would yield
array([[list([1, 2]), list([3, 4])]])
which is different to what we started with.
I would greatly appreciate opinions on the above change and regarding the names of the functions and their placement in the project structure (currently placed in lib/shape_base.py).