-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AIR][Numpy] Add numpy narrow waist to
Preprocessor
and `BatchMappe…
…r` (#28418) Co-authored-by: Eric Liang <ekhliang@gmail.com> Co-authored-by: Clark Zinzow <clarkzinzow@gmail.com> Co-authored-by: Amog Kamsetty <amogkamsetty@yahoo.com>
- Loading branch information
1 parent
6b7eda1
commit 9c39a28
Showing
12 changed files
with
805 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
try: | ||
import pyarrow | ||
except ImportError: | ||
pyarrow = None | ||
|
||
|
||
def _is_column_extension_type(ca: "pyarrow.ChunkedArray") -> bool: | ||
"""Whether the provided Arrow Table column is an extension array, using an Arrow | ||
extension type. | ||
""" | ||
return isinstance(ca.type, pyarrow.ExtensionType) | ||
|
||
|
||
def _concatenate_extension_column(ca: "pyarrow.ChunkedArray") -> "pyarrow.Array": | ||
"""Concatenate chunks of an extension column into a contiguous array. | ||
This concatenation is required for creating copies and for .take() to work on | ||
extension arrays. | ||
See https://issues.apache.org/jira/browse/ARROW-16503. | ||
""" | ||
if not _is_column_extension_type(ca): | ||
raise ValueError("Chunked array isn't an extension array: {ca}") | ||
|
||
if ca.num_chunks == 0: | ||
# No-op for no-chunk chunked arrays, since there's nothing to concatenate. | ||
return ca | ||
|
||
chunk = ca.chunk(0) | ||
return type(chunk).from_storage( | ||
chunk.type, pyarrow.concat_arrays([c.storage for c in ca.chunks]) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.