Return all coordinates having the same index. Parameters ---------- key : hashable Index key. errors : {"raise", "ignore"}, default: "raise" If "raise", raises a ValueError if `key` is not in indexes. If "ignore", an empty tuple is
(
self, key: Hashable, errors: ErrorOptions = "raise"
)
| 1812 | return len(self._id_coord_names[self._coord_name_id[key]]) > 1 |
| 1813 | |
| 1814 | def get_all_coords( |
| 1815 | self, key: Hashable, errors: ErrorOptions = "raise" |
| 1816 | ) -> dict[Hashable, Variable]: |
| 1817 | """Return all coordinates having the same index. |
| 1818 | |
| 1819 | Parameters |
| 1820 | ---------- |
| 1821 | key : hashable |
| 1822 | Index key. |
| 1823 | errors : {"raise", "ignore"}, default: "raise" |
| 1824 | If "raise", raises a ValueError if `key` is not in indexes. |
| 1825 | If "ignore", an empty tuple is returned instead. |
| 1826 | |
| 1827 | Returns |
| 1828 | ------- |
| 1829 | coords : dict |
| 1830 | A dictionary of all coordinate variables having the same index. |
| 1831 | |
| 1832 | """ |
| 1833 | if errors not in ["raise", "ignore"]: |
| 1834 | raise ValueError('errors must be either "raise" or "ignore"') |
| 1835 | |
| 1836 | if key not in self._indexes: |
| 1837 | if errors == "raise": |
| 1838 | raise ValueError(f"no index found for {key!r} coordinate") |
| 1839 | else: |
| 1840 | return {} |
| 1841 | |
| 1842 | all_coord_names = self._id_coord_names[self._coord_name_id[key]] |
| 1843 | return {k: self._variables[k] for k in all_coord_names} |
| 1844 | |
| 1845 | def get_all_dims( |
| 1846 | self, key: Hashable, errors: ErrorOptions = "raise" |
no outgoing calls