-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
36f06f6
commit 74594d9
Showing
6 changed files
with
165 additions
and
166 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
46 changes: 46 additions & 0 deletions
46
src/snowflake/snowpark/modin/plugin/extensions/base_extensions.py
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,46 @@ | ||
# | ||
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved. | ||
# | ||
|
||
""" | ||
File containing BasePandasDataset APIs defined in Snowpark pandas but not the Modin API layer. | ||
""" | ||
|
||
from snowflake.snowpark.modin.plugin._internal.telemetry import ( | ||
snowpark_pandas_telemetry_method_decorator, | ||
) | ||
|
||
from .base_overrides import register_base_override | ||
|
||
|
||
@register_base_override("__array_function__") | ||
@snowpark_pandas_telemetry_method_decorator | ||
def __array_function__(self, func: callable, types: tuple, args: tuple, kwargs: dict): | ||
""" | ||
Apply the `func` to the `BasePandasDataset`. | ||
Parameters | ||
---------- | ||
func : np.func | ||
The NumPy func to apply. | ||
types : tuple | ||
The types of the args. | ||
args : tuple | ||
The args to the func. | ||
kwargs : dict | ||
Additional keyword arguments. | ||
Returns | ||
------- | ||
BasePandasDataset | ||
The result of the ufunc applied to the `BasePandasDataset`. | ||
""" | ||
from snowflake.snowpark.modin.plugin.utils.numpy_to_pandas import ( | ||
numpy_to_pandas_func_map, | ||
) | ||
|
||
if func.__name__ in numpy_to_pandas_func_map: | ||
return numpy_to_pandas_func_map[func.__name__](*args, **kwargs) | ||
else: | ||
# per NEP18 we raise NotImplementedError so that numpy can intercept | ||
return NotImplemented # pragma: no cover |
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.