8000 ENH: Add aliases for common scalar unions by BvB93 · Pull Request #17096 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: Add aliases for common scalar unions #17096

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

Closed
wants to merge 8 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ENH: Be more specific about _ScalarLike and _VoidLike
  • Loading branch information
Bas van Beek committed Aug 18, 2020
commit fff6734772090f96961d1eab2045f68fa3e468c1
19 changes: 14 additions & 5 deletions numpy/typing/_scalars.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union
from typing import Union, Tuple, Any
from datetime import datetime, timedelta

import numpy as np
Expand All @@ -16,9 +16,18 @@
_BytesLike = Union[bytes, np.bytes_]
_CharacterLike = Union[str, bytes, np.character]

# _VoidLike is technically not a scalar, but it's close enough
_VoidLike = Union[tuple, np.void]

_VoidLikeNested = Any # TODO: wait for support for recursive types
_ScalarLike = Union[
datetime, timedelta, int, float, complex, str, bytes, tuple, np.generic
datetime,
timedelta,
int,
float,
complex,
str,
bytes,
Tuple[_VoidLikeNested, ...],
np.generic,
]

# _VoidLike is technically not a scalar, but it's close enough
_VoidLike = Union[Tuple[_ScalarLike, ...], np.void]
0