-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Typeinterval part2 #46098
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
Merged
Merged
Typeinterval part2 #46098
Changes from 17 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
9e57d6d
fix column_arrays for array manager
Dr-Irv 2abbc57
merge with upstream/main
Dr-Irv 99158b1
Merge remote-tracking branch 'upstream/main'
Dr-Irv 0f4130d
Merge remote-tracking branch 'upstream/main'
Dr-Irv 24ecfe2
Merge remote-tracking branch 'upstream/main'
Dr-Irv 64f00d5
Merge remote-tracking branch 'upstream/main'
Dr-Irv 1ee6e00
Merge remote-tracking branch 'upstream/main'
Dr-Irv 34dc181
fix up typing to eventually support Interval typing
Dr-Irv a547800
fix imports in core/tools/datetimes.py
Dr-Irv 3a3bfea
fix time in odfreader
Dr-Irv 5edf5c9
pandas/core/arrays/masked.py
Dr-Irv 7c4cd5c
use cast instead of new code in odfreader
Dr-Irv 649ef07
fix odfreader
Dr-Irv 1c1ba2c
interval pyi
Dr-Irv 35c2af0
use cast in odfreader
Dr-Irv 9769356
use cast in odfreader
Dr-Irv 607b367
fixes for mid, length to mixin, change use of protocol
Dr-Irv f9f0820
misc cleanup from twoertwein
Dr-Irv 52f376f
remove generic from IntervalTree
Dr-Irv 40be56f
Merge remote-tracking branch 'upstream/main' into typeinterval_part1
Dr-Irv 4fcf523
clean up based on comments. simplify python_parser changes. Introduc…
Dr-Irv 3b68c6a
Merge branch 'typeinterval_part1' into typeinterval_part2
Dr-Irv d6de171
Merge remote-tracking branch 'upstream/main' into typeinterval_part2
Dr-Irv 9e11b8c
Feedback from twoertwein
Dr-Irv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,179 @@ | ||
from __future__ import annotations | ||
|
||
from typing import ( | ||
Any, | ||
Generic, | ||
Literal, | ||
Tuple, | ||
TypeVar, | ||
Union, | ||
overload, | ||
) | ||
|
||
import numpy as np | ||
import numpy.typing as npt | ||
|
||
from pandas._typing import ( | ||
Timedelta, | ||
Timestamp, | ||
) | ||
|
||
VALID_CLOSED: frozenset[str] | ||
|
||
_OrderableScalarT = TypeVar("_OrderableScalarT", int, float) | ||
_OrderableTimesT = TypeVar("_OrderableTimesT", Timestamp, Timedelta) | ||
_OrderableT = TypeVar("_OrderableT", int, float, Timestamp, Timedelta) | ||
|
||
class _LengthDescriptor: | ||
@overload | ||
def __get__(self, instance: Interval[float], owner: Any) -> float: ... | ||
@overload | ||
def __get__(self, instance: Interval[int], owner: Any) -> int: ... | ||
@overload | ||
def __get__( | ||
self, instance: Interval[_OrderableTimesT], owner: Any | ||
) -> Timedelta: ... | ||
@overload | ||
def __get__( | ||
self, instance: IntervalTree[_OrderableT], owner: Any | ||
) -> _OrderableT: ... | ||
|
||
class _MidDescriptor: | ||
@overload | ||
def __get__(self, instance: Interval[_OrderableScalarT], owner: Any) -> float: ... | ||
@overload | ||
def __get__( | ||
self, instance: Interval[_OrderableTimesT], owner: Any | ||
) -> _OrderableTimesT: ... | ||
@overload | ||
def __get__( | ||
self, instance: IntervalTree[_OrderableT], owner: Any | ||
) -> _OrderableT: ... | ||
|
||
class IntervalMixin: | ||
@property | ||
def closed_left(self) -> bool: ... | ||
@property | ||
def closed_right(self) -> bool: ... | ||
@property | ||
def open_left(self) -> bool: ... | ||
@property | ||
def open_right(self) -> bool: ... | ||
mid: _MidDescriptor | ||
length: _LengthDescriptor | ||
@property | ||
def is_empty(self) -> bool: ... | ||
def _check_closed_matches(self, other: IntervalMixin, name: str = ...) -> None: ... | ||
|
||
class Interval(IntervalMixin, Generic[_OrderableT]): | ||
@property | ||
def left(self: Interval[_OrderableT]) -> _OrderableT: ... | ||
@property | ||
def right(self: Interval[_OrderableT]) -> _OrderableT: ... | ||
@property | ||
def closed(self) -> Literal["left", "right", "both", "neither"]: ... | ||
Dr-Irv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def __init__( | ||
self, | ||
left: _OrderableT, | ||
right: _OrderableT, | ||
closed: Literal["left", "right", "both", "neither"] = ..., | ||
): ... | ||
def __hash__(self) -> int: ... | ||
@overload | ||
def __contains__(self: Interval[_OrderableTimesT], _OrderableTimesT) -> bool: ... | ||
@overload | ||
def __contains__( | ||
self: Interval[_OrderableScalarT], key: Union[int, float] | ||
) -> bool: ... | ||
def __repr__(self) -> str: ... | ||
def __str__(self) -> str: ... | ||
@overload | ||
def __add__( | ||
self: Interval[_OrderableTimesT], y: Timedelta | ||
) -> Interval[_OrderableTimesT]: ... | ||
@overload | ||
def __add__(self: Interval[int], y: int) -> Interval[int]: ... | ||
Dr-Irv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@overload | ||
def __add__(self: Interval[int], y: float) -> Interval[float]: ... | ||
@overload | ||
def __add__(self: Interval[float], y: Union[int, float]) -> Interval[float]: ... | ||
@overload | ||
def __radd__( | ||
self: Interval[_OrderableTimesT], y: Timedelta | ||
) -> Interval[_OrderableTimesT]: ... | ||
@overload | ||
def __radd__(self: Interval[int], y: int) -> Interval[int]: ... | ||
@overload | ||
def __radd__(self: Interval[int], y: float) -> Interval[float]: ... | ||
@overload | ||
def __radd__(self: Interval[float], y: Union[int, float]) -> Interval[float]: ... | ||
@overload | ||
def __sub__( | ||
self: Interval[_OrderableTimesT], y: Timedelta | ||
) -> Interval[_OrderableTimesT]: ... | ||
@overload | ||
def __sub__(self: Interval[int], y: int) -> Interval[int]: ... | ||
@overload | ||
def __sub__(self: Interval[int], y: float) -> Interval[float]: ... | ||
@overload | ||
def __sub__(self: Interval[float], y: Union[int, float]) -> Interval[float]: ... | ||
@overload | ||
def __rsub__( | ||
self: Interval[_OrderableTimesT], y: Timedelta | ||
) -> Interval[_OrderableTimesT]: ... | ||
@overload | ||
def __rsub__(self: Interval[int], y: int) -> Interval[int]: ... | ||
@overload | ||
def __rsub__(self: Interval[int], y: float) -> Interval[float]: ... | ||
@overload | ||
def __rsub__(self: Interval[float], y: Union[int, float]) -> Interval[float]: ... | ||
@overload | ||
def __mul__(self: Interval[int], y: int) -> Interval[int]: ... | ||
@overload | ||
def __mul__(self: Interval[int], y: float) -> Interval[float]: ... | ||
@overload | ||
def __mul__(self: Interval[float], y: Union[int, float]) -> Interval[float]: ... | ||
@overload | ||
def __rmul__(self: Interval[int], y: int) -> Interval[int]: ... | ||
@overload | ||
def __rmul__(self: Interval[int], y: float) -> Interval[float]: ... | ||
@overload | ||
def __rmul__(self: Interval[float], y: Union[int, float]) -> Interval[float]: ... | ||
@overload | ||
def __truediv__(self: Interval[int], y: int) -> Interval[int]: ... | ||
@overload | ||
def __truediv__(self: Interval[int], y: float) -> Interval[float]: ... | ||
@overload | ||
def __truediv__(self: Interval[float], y: Union[int, float]) -> Interval[float]: ... | ||
@overload | ||
def __floordiv__(self: Interval[int], y: int) -> Interval[int]: ... | ||
@overload | ||
def __floordiv__(self: Interval[int], y: float) -> Interval[float]: ... | ||
@overload | ||
def __floordiv__( | ||
self: Interval[float], y: Union[int, float] | ||
) -> Interval[float]: ... | ||
def overlaps(self: Interval[_OrderableT], other: Interval[_OrderableT]) -> bool: ... | ||
|
||
def intervals_to_interval_bounds( | ||
intervals: np.ndarray, validate_closed: bool = ... | ||
) -> Tuple[np.ndarray, np.ndarray, str]: ... | ||
Dr-Irv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
class IntervalTree(IntervalMixin, Generic[_OrderableT]): | ||
Dr-Irv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def __init__( | ||
self, | ||
left: np.ndarray, | ||
twoertwein marked this conversation as resolved.
Show resolved
Hide resolved
|
||
right: np.ndarray, | ||
closed: Literal["left", "right", "both", "neither"] = ..., | ||
leaf_size: int = ..., | ||
): ... | ||
Dr-Irv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def get_indexer(self, target) -> npt.NDArray[np.intp]: ... | ||
def get_indexer_non_unique( | ||
self, target | ||
) -> Tuple[npt.NDArray[np.intp], npt.NDArray[np.intp]]: ... | ||
Dr-Irv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
_na_count: int | ||
@property | ||
def is_overlapping(self) -> bool: ... | ||
Dr-Irv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@property | ||
def is_monotonic_increasing(self) -> bool: ... | ||
def clear_mapping(self) -> None: ... |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.