|
46 | 46 | from .common import AbstractArray, DataWithCoords
|
47 | 47 | from .coordinates import (
|
48 | 48 | DataArrayCoordinates,
|
49 |
| - LevelCoordinatesSource, |
50 | 49 | assert_coordinate_consistent,
|
51 | 50 | remap_label_indexers,
|
52 | 51 | )
|
|
56 | 55 | from .indexing import is_fancy_indexer
|
57 | 56 | from .merge import PANDAS_TYPES, MergeError, _extract_indexes_from_coords
|
58 | 57 | from .options import OPTIONS, _get_keep_attrs
|
59 |
| -from .utils import Default, ReprObject, _default, either_dict_or_kwargs |
| 58 | +from .utils import ( |
| 59 | + Default, |
| 60 | + HybridMappingProxy, |
| 61 | + ReprObject, |
| 62 | + _default, |
| 63 | + either_dict_or_kwargs, |
| 64 | +) |
60 | 65 | from .variable import (
|
61 | 66 | IndexVariable,
|
62 | 67 | Variable,
|
@@ -721,18 +726,20 @@ def __delitem__(self, key: Any) -> None:
|
721 | 726 | del self.coords[key]
|
722 | 727 |
|
723 | 728 | @property
|
724 |
| - def _attr_sources(self) -> List[Mapping[Hashable, Any]]: |
725 |
| - """List of places to look-up items for attribute-style access""" |
726 |
| - return self._item_sources + [self.attrs] |
| 729 | + def _attr_sources(self) -> Iterable[Mapping[Hashable, Any]]: |
| 730 | + """Places to look-up items for attribute-style access""" |
| 731 | + yield from self._item_sources |
| 732 | + yield self.attrs |
727 | 733 |
|
728 | 734 | @property
|
729 |
| - def _item_sources(self) -> List[Mapping[Hashable, Any]]: |
730 |
| - """List of places to look-up items for key-completion""" |
731 |
| - return [ |
732 |
| - self.coords, |
733 |
| - {d: self.coords[d] for d in self.dims}, |
734 |
| - LevelCoordinatesSource(self), |
735 |
| - ] |
| 735 | + def _item_sources(self) -> Iterable[Mapping[Hashable, Any]]: |
| 736 | + """Places to look-up items for key-completion""" |
| 737 | + yield HybridMappingProxy(keys=self._coords, mapping=self.coords) |
| 738 | + |
| 739 | + # virtual coordinates |
| 740 | + # uses empty dict -- everything here can already be found in self.coords. |
| 741 | + yield HybridMappingProxy(keys=self.dims, mapping={}) |
| 742 | + yield HybridMappingProxy(keys=self._level_coords, mapping={}) |
736 | 743 |
|
737 | 744 | def __contains__(self, key: Any) -> bool:
|
738 | 745 | return key in self.data
|
|
0 commit comments