MCPcopy Index your code
hub / github.com/pydata/xarray / _ipython_key_completions_

Method _ipython_key_completions_

xarray/core/datatree.py:832–859  ·  view source on GitHub ↗

Provide method for the key-autocompletions in IPython. See https://ipython.readthedocs.io/en/stable/config/integrating.html#tab-completion For the details.

(self)

Source from the content-addressed store, hash-verified

830 yield self.children
831
832 def _ipython_key_completions_(self) -> list[str]:
833 """Provide method for the key-autocompletions in IPython.
834 See https://ipython.readthedocs.io/en/stable/config/integrating.html#tab-completion
835 For the details.
836 """
837
838 # TODO allow auto-completing relative string paths, e.g. `dt['path/to/../ <tab> node'`
839 # Would require changes to ipython's autocompleter, see https://github.com/ipython/ipython/issues/12420
840 # Instead for now we only list direct paths to all node in subtree explicitly
841
842 items_on_this_node = self._item_sources
843 paths_to_all_nodes_in_subtree = {
844 path: node
845 for path, node in self.subtree_with_keys
846 if path != "." # exclude the root node
847 }
848
849 all_item_sources = itertools.chain(
850 items_on_this_node, [paths_to_all_nodes_in_subtree]
851 )
852
853 items = {
854 item
855 for source in all_item_sources
856 for item in source
857 if isinstance(item, str)
858 }
859 return list(items)
860
861 def __contains__(self, key: object) -> bool:
862 """The 'in' operator will return true or false depending on whether

Calls

no outgoing calls