-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
More annotations in Dataset #3112
Merged
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5506eff
Let mypy discover xarray typing hints
crusaderky a537fbb
Docs tweak
crusaderky 3b13dcb
More annotations in Dataset
crusaderky 6851c2f
Merge remote-tracking branch 'upstream/master' into annotations
crusaderky 29abedf
Fix Python 3.5-specific check for OrderedDict
crusaderky 44cfb8e
typing in merge
crusaderky b119ddc
Merge remote-tracking branch 'upstream/master' into annotations
crusaderky 9f71e0c
broadcast_like typing tweaks
crusaderky 829f5ff
Changed redundant x: Optional[MyType] = None to x: MyType = None
crusaderky 298f88b
flake8
crusaderky 52114a9
Merge remote-tracking branch 'upstream/master' into annotations
crusaderky b0b6edc
Merge remote-tracking branch 'upstream/master' into annotations
crusaderky e0036e7
Merge remote-tracking branch 'upstream/master' into annotations
7a36ff5
What's New
crusaderky 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 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
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 |
---|---|---|
|
@@ -3,7 +3,16 @@ | |
import warnings | ||
from collections import OrderedDict, defaultdict | ||
from contextlib import suppress | ||
from typing import Any, Mapping, Optional, Tuple | ||
from typing import ( | ||
Any, | ||
Dict, | ||
Hashable, | ||
Mapping, | ||
Optional, | ||
Tuple, | ||
Union, | ||
TYPE_CHECKING, | ||
) | ||
|
||
import numpy as np | ||
import pandas as pd | ||
|
@@ -13,6 +22,10 @@ | |
from .utils import is_dict_like, is_full_slice | ||
from .variable import IndexVariable, Variable | ||
|
||
if TYPE_CHECKING: | ||
from .dataarray import DataArray | ||
from .dataset import Dataset | ||
|
||
|
||
def _get_joiner(join): | ||
if join == 'outer': | ||
|
@@ -169,8 +182,8 @@ def deep_align(objects, join='inner', copy=True, indexes=None, | |
|
||
This function is not public API. | ||
""" | ||
from .dataarray import DataArray | ||
from .dataset import Dataset | ||
from .dataarray import DataArray # noqa: F811 | ||
from .dataset import Dataset # noqa: F811 | ||
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. This is a workaround to a flake8 limitation https://gitlab.com/pycqa/flake8/issues/553 |
||
|
||
if indexes is None: | ||
indexes = {} | ||
|
@@ -222,7 +235,10 @@ def is_alignable(obj): | |
return out | ||
|
||
|
||
def reindex_like_indexers(target, other): | ||
def reindex_like_indexers( | ||
target: Union['DataArray', 'Dataset'], | ||
other: Union['DataArray', 'Dataset'], | ||
) -> Dict[Hashable, pd.Index]: | ||
"""Extract indexers to align target with other. | ||
|
||
Not public API. | ||
|
@@ -236,7 +252,8 @@ def reindex_like_indexers(target, other): | |
|
||
Returns | ||
------- | ||
Dict[Any, pandas.Index] providing indexes for reindex keyword arguments. | ||
Dict[Hashable, pandas.Index] providing indexes for reindex keyword | ||
arguments. | ||
|
||
Raises | ||
------ | ||
|
@@ -310,7 +327,7 @@ def reindex_variables( | |
new_indexes : OrderedDict | ||
Dict of indexes associated with the reindexed variables. | ||
""" | ||
from .dataarray import DataArray | ||
from .dataarray import DataArray # noqa: F811 | ||
|
||
# create variables for the new dataset | ||
reindexed = OrderedDict() # type: OrderedDict[Any, Variable] | ||
|
@@ -407,8 +424,8 @@ def _get_broadcast_dims_map_common_coords(args, exclude): | |
|
||
def _broadcast_helper(arg, exclude, dims_map, common_coords): | ||
|
||
from .dataarray import DataArray | ||
from .dataset import Dataset | ||
from .dataarray import DataArray # noqa: F811 | ||
from .dataset import Dataset # noqa: F811 | ||
|
||
def _set_dims(var): | ||
# Add excluded dims to a copy of dims_map | ||
|
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.
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.
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.
Let's move this up to 0.12.4?
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.
Done