Fastpath constructor for internal use. Returns an object with optionally with replaced attributes. Explicitly passed arguments are *not* copied when placed on the new dataset. It is up to the caller to ensure that they have the right type and are not used elsewhere.
(
self,
variables: dict[Hashable, Variable] | None = None,
coord_names: set[Hashable] | None = None,
dims: dict[Any, int] | None = None,
attrs: dict[Hashable, Any] | Default | None = _default,
indexes: dict[Hashable, Index] | None = None,
encoding: dict | Default | None = _default,
inplace: bool = False,
)
| 875 | return obj |
| 876 | |
| 877 | def _replace( |
| 878 | self, |
| 879 | variables: dict[Hashable, Variable] | None = None, |
| 880 | coord_names: set[Hashable] | None = None, |
| 881 | dims: dict[Any, int] | None = None, |
| 882 | attrs: dict[Hashable, Any] | Default | None = _default, |
| 883 | indexes: dict[Hashable, Index] | None = None, |
| 884 | encoding: dict | Default | None = _default, |
| 885 | inplace: bool = False, |
| 886 | ) -> Self: |
| 887 | """Fastpath constructor for internal use. |
| 888 | |
| 889 | Returns an object with optionally with replaced attributes. |
| 890 | |
| 891 | Explicitly passed arguments are *not* copied when placed on the new |
| 892 | dataset. It is up to the caller to ensure that they have the right type |
| 893 | and are not used elsewhere. |
| 894 | """ |
| 895 | if inplace: |
| 896 | if variables is not None: |
| 897 | self._variables = variables |
| 898 | if coord_names is not None: |
| 899 | self._coord_names = coord_names |
| 900 | if dims is not None: |
| 901 | self._dims = dims |
| 902 | if attrs is not _default: |
| 903 | self._attrs = attrs |
| 904 | if indexes is not None: |
| 905 | self._indexes = indexes |
| 906 | if encoding is not _default: |
| 907 | self._encoding = encoding |
| 908 | obj = self |
| 909 | else: |
| 910 | if variables is None: |
| 911 | variables = self._variables.copy() |
| 912 | if coord_names is None: |
| 913 | coord_names = self._coord_names.copy() |
| 914 | if dims is None: |
| 915 | dims = self._dims.copy() |
| 916 | if attrs is _default: |
| 917 | attrs = copy.copy(self._attrs) |
| 918 | if indexes is None: |
| 919 | indexes = self._indexes.copy() |
| 920 | if encoding is _default: |
| 921 | encoding = copy.copy(self._encoding) |
| 922 | obj = self._construct_direct( |
| 923 | variables, coord_names, dims, attrs, indexes, encoding |
| 924 | ) |
| 925 | return obj |
| 926 | |
| 927 | def _replace_with_new_dims( |
| 928 | self, |