-
-
Notifications
You must be signed in to change notification settings - Fork 19.5k
TYP: stubs for reshape, ops, ops_dispatch, hashing #40455
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
Changes from 3 commits
b42cfbc
28cf04a
cc974bb
a68cd8a
a2ab5ab
82fbef9
6db2ea3
22d4cf6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import numpy as np | ||
|
|
||
| def hash_object_array( | ||
| arr: np.ndarray, # np.ndarray[object] | ||
| key: str, | ||
| encoding: str = "utf8", | ||
| ) -> np.ndarray: ... # np.ndarray[np.uint64] | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,43 @@ | ||||||
| from typing import ( | ||||||
| Any, | ||||||
| Callable, | ||||||
| ) | ||||||
|
|
||||||
| import numpy as np | ||||||
|
|
||||||
| binop = Callable[[Any, Any], Any] | ||||||
| bool_op = Callable[[Any, Any], bool] | ||||||
|
||||||
|
|
||||||
|
|
||||||
| def scalar_compare( | ||||||
| values: np.ndarray, # object[:] | ||||||
| val: object, | ||||||
| op: bool_op, # {operator.eq, operator.ne, ...} | ||||||
| ) -> np.ndarray: ... # np.ndarray[bool] | ||||||
|
|
||||||
| def vec_compare( | ||||||
| left: np.ndarray, # np.ndarray[object] | ||||||
| right: np.ndarray, # np.ndarray[object] | ||||||
| op: bool_op, # {operator.eq, operator.ne, ...} | ||||||
| ) -> np.ndarray: ... # np.ndarray[bool] | ||||||
|
|
||||||
|
|
||||||
| def scalar_binop( | ||||||
| values: np.ndarray, # object[:] | ||||||
| val: object, | ||||||
| op: binop, # binary operator | ||||||
| ) -> np.ndarray: ... | ||||||
|
|
||||||
|
|
||||||
| def vec_binop( | ||||||
| left: np.ndarray, # object[:] | ||||||
| right: np.ndarray, # object[:] | ||||||
| op: binop, # binary operator | ||||||
| ) -> np.ndarray: ... | ||||||
|
|
||||||
|
|
||||||
| def maybe_convert_bool( | ||||||
| arr: np.ndarray, # np.ndarray[object] | ||||||
| true_values=None, | ||||||
|
||||||
| true_values=None, | |
| true_values=..., |
Outdated
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.
| false_values=None | |
| false_values=... |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import numpy as np | ||
|
|
||
| REVERSED_NAMES: dict[str, str] | ||
| UFUNC_ALIASES: dict[str, str] | ||
| DISPATCHED_UFUNCS: set[str] | ||
|
||
|
|
||
| def maybe_dispatch_ufunc_to_dunder_op( | ||
| self, ufunc: np.ufunc, method: str, *inputs, **kwargs | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe type self, since function is not a method
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will take some tracking down, since it is called via arraylike.array_ufunc, which doesnt type self |
||
| ): ... | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import numpy as np | ||
|
|
||
| def unstack( | ||
| values: np.ndarray, # reshape_t[:, :] | ||
| mask: np.ndarray, # const uint8_t[:] | ||
| stride: int, | ||
| length: int, | ||
| width: int, | ||
| new_values: np.ndarray, # reshape_t[:, :] | ||
| new_mask: np.ndarray, # uint8_t[:, :] | ||
| ) -> None: ... | ||
|
|
||
|
|
||
| def explode( | ||
| values: np.ndarray, # np.ndarray[object] | ||
| ) -> tuple[ | ||
| np.ndarray, # np.ndarray[object] | ||
| np.ndarray, # np.ndarray[np.int64] | ||
| ]: ... |
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.