def should_add_coord_to_array(
        self,
        name: Hashable,
        var: Variable,
        dims: set[Hashable],
    ) -> bool:
        """Define whether or not an index coordinate variable should be added to
        a new DataArray.

        This method is called repeatedly for each Variable associated with this
        index when creating a new DataArray (via its constructor or from a
        Dataset) or updating an existing one. The variables associated with this
        index are the ones passed to :py:meth:`Index.from_variables` and/or
        returned by :py:meth:`Index.create_variables`.

        By default returns ``True`` if the dimensions of the coordinate variable
        are a subset of the array dimensions and ``False`` otherwise (DataArray
        model). This default behavior may be overridden in Index subclasses to
        bypass strict conformance with the DataArray model. This is useful for
        example to include the (n+1)-dimensional cell boundary coordinate
        associated with an interval index.

        Returning ``False`` will either:

        - raise a :py:class:`CoordinateValidationError` when passing the
          coordinate directly to a new or an existing DataArray, e.g., via
          ``DataArray.__init__()`` or ``DataArray.assign_coords()``

        - drop the coordinate (and therefore drop the index) when a new
          DataArray is constructed by indexing a Dataset

        Parameters
        ----------
        name : Hashable
            Name of a coordinate variable associated to this index.
        var : Variable
            Coordinate variable object.
        dims: tuple
            Dimensions of the new DataArray object being created.

        """
        return all(d in dims for d in var.dims)
Define whether or not an index coordinate variable should be added to
        a new DataArray.

        This method is called repeatedly for each Variable associated with this
        index when creating a new DataArray (via its constructor or from a
        Dataset) or updating an existing one. The variables associated with this
        index are the ones passed to :py:meth:`Index.from_variables` and/or
        returned by :py:meth:`Index.create_variables`.

        By default returns ``True`` if the dimensions of the coordinate variable
        are a subset of the array dimensions and ``False`` otherwise (DataArray
        model). This default behavior may be overridden in Index subclasses to
        bypass strict conformance with the DataArray model. This is useful for
        example to include the (n+1)-dimensional cell boundary coordinate
        associated with an interval index.

        Returning ``False`` will either:

        - raise a :py:class:`CoordinateValidationError` when passing the
          coordinate directly to a new or an existing DataArray, e.g., via
          ``DataArray.__init__()`` or ``DataArray.assign_coords()``

        - drop the coordinate (and therefore drop the index) when a new
          DataArray is constructed by indexing a Dataset

        Parameters
        ----------
        name : Hashable
            Name of a coordinate variable associated to this index.
        var : Variable
            Coordinate variable object.
        dims: tuple
            Dimensions of the new DataArray object being created.

        
xarray/core/indexes.py