Skip to content

Commit

Permalink
PERF-#0000: call 'to_numpy' in main process
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoly Myachev <[email protected]>
  • Loading branch information
anmyachev committed Nov 7, 2023
1 parent 90ec679 commit d4f9a50
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
15 changes: 5 additions & 10 deletions modin/core/execution/ray/generic/partitioning/partition_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,9 @@ def to_numpy(cls, partitions, **kwargs):
NumPy array
"""
parts = RayWrapper.materialize(
[
obj.apply(lambda df, **kwargs: df.to_numpy(**kwargs)).list_of_blocks[0]
for row in partitions
for obj in row
]
[obj.list_of_blocks[0] for row in partitions for obj in row]
)
n = partitions.shape[1]
parts = [parts[i * n : (i + 1) * n] for i in list(range(partitions.shape[0]))]

arr = np.block(parts)
return arr
parts = [part.to_numpy() for part in parts]
rows, cols = partitions.shape
parts = [parts[i * cols : (i + 1) * cols] for i in range(rows)]
return np.block(parts)
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,9 @@ def to_numpy(cls, partitions, **kwargs):
NumPy array
"""
parts = UnidistWrapper.materialize(
[
obj.apply(lambda df, **kwargs: df.to_numpy(**kwargs)).list_of_blocks[0]
for row in partitions
for obj in row
]
[obj.list_of_blocks[0] for row in partitions for obj in row]
)
parts = [part.to_numpy() for part in parts]

Check warning on line 46 in modin/core/execution/unidist/generic/partitioning/partition_manager.py

View check run for this annotation

Codecov / codecov/patch

modin/core/execution/unidist/generic/partitioning/partition_manager.py#L46

Added line #L46 was not covered by tests
rows, cols = partitions.shape
parts = [parts[i * cols : (i + 1) * cols] for i in range(rows)]
return np.block(parts)

0 comments on commit d4f9a50

Please sign in to comment.