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

Method match

xarray/core/datatree.py:1742–1786  ·  view source on GitHub ↗

Return nodes with paths matching pattern. Uses unix glob-like syntax for pattern-matching. Parameters ---------- pattern: str A pattern to match each node path against. Returns ------- DataTree See Also

(self, pattern: str)

Source from the content-addressed store, hash-verified

1740 return self.filter(non_empty_cond)
1741
1742 def match(self, pattern: str) -> DataTree:
1743 """
1744 Return nodes with paths matching pattern.
1745
1746 Uses unix glob-like syntax for pattern-matching.
1747
1748 Parameters
1749 ----------
1750 pattern: str
1751 A pattern to match each node path against.
1752
1753 Returns
1754 -------
1755 DataTree
1756
1757 See Also
1758 --------
1759 filter
1760 pipe
1761 map_over_datasets
1762
1763 Examples
1764 --------
1765 >>> dt = DataTree.from_dict(
1766 ... {
1767 ... "/a/A": None,
1768 ... "/a/B": None,
1769 ... "/b/A": None,
1770 ... "/b/B": None,
1771 ... }
1772 ... )
1773 >>> dt.match("*/B")
1774 <xarray.DataTree>
1775 Group: /
1776 ├── Group: /a
1777 │ └── Group: /a/B
1778 └── Group: /b
1779 └── Group: /b/B
1780 """
1781 matching_nodes = {
1782 path: node.dataset
1783 for path, node in self.subtree_with_keys
1784 if NodePath(node.path).match(pattern)
1785 }
1786 return DataTree.from_dict(matching_nodes, name=self.name)
1787
1788 @overload
1789 def map_over_datasets(

Callers 8

_ensure_padded_yearFunction · 0.45
parse_iso8601_likeFunction · 0.45
to_offsetFunction · 0.45
test_matchFunction · 0.45
test_empty_str_methodsFunction · 0.45
test_matchMethod · 0.45

Calls 2

NodePathClass · 0.90
from_dictMethod · 0.45

Tested by 4

test_matchFunction · 0.36
test_empty_str_methodsFunction · 0.36
test_matchMethod · 0.36