xarray/core/variable.py
def chunk(self, chunks=None, name=None, lock=False):
        """Coerce this array's data into a dask arrays with the given chunks.

        If this variable is a non-dask array, it will be converted to dask
        array. If it's a dask array, it will be rechunked to the given chunk
        sizes.

        If neither chunks is not provided for one or more dimensions, chunk
        sizes along that dimension will not be updated; non-dask arrays will be
        converted into dask arrays with a single block.

        Parameters
        ----------
        chunks : int, tuple or dict, optional
            Chunk sizes along each dimension, e.g., ``5``, ``(5, 5)`` or
            ``{'x': 5, 'y': 5}``.
        name : str, optional
            Used to generate the name for this array in the internal dask
            graph. Does not need not be unique.
        lock : optional
            Passed on to :py:func:`dask.array.from_array`, if the array is not
            already as dask array.

        Returns
        -------
        chunked : xarray.Variable
        """
        import dask
        import dask.array as da

        if utils.is_dict_like(chunks):
            chunks = {self.get_axis_num(dim): chunk for dim, chunk in chunks.items()}

        if chunks is None:
            chunks = self.chunks or self.shape

        data = self._data
        if is_duck_dask_array(data):
            data = data.rechunk(chunks)
        else:
            if isinstance(data, indexing.ExplicitlyIndexed):
                # Unambiguously handle array storage backends (like NetCDF4 and h5py)
                # that can't handle general array indexing. For example, in netCDF4 you
                # can do "outer" indexing along two dimensions independent, which works
                # differently from how NumPy handles it.
                # da.from_array works by using lazy indexing with a tuple of slices.
                # Using OuterIndexer is a pragmatic choice: dask does not yet handle
                # different indexing types in an explicit way:
                # https://github.com/dask/dask/issues/2883
                data = indexing.ImplicitToExplicitIndexingAdapter(
                    data, indexing.OuterIndexer
                )
                if LooseVersion(dask.__version__) < "2.0.0":
                    kwargs = {}
                else:
                    # All of our lazily loaded backend array classes should use NumPy
                    # array operations.
                    kwargs = {"meta": np.ndarray}
            else:
                kwargs = {}

            if utils.is_dict_like(chunks):
                chunks = tuple(chunks.get(n, s) for n, s in enumerate(self.shape))

            data = da.from_array(data, chunks, name=name, lock=lock, **kwargs)

        return type(self)(self.dims, data, self._attrs, self._encoding, fastpath=True)
Coerce this array's data into a dask arrays with the given chunks.

        If this variable is a non-dask array, it will be converted to dask
        array. If it's a dask array, it will be rechunked to the given chunk
        sizes.

        If neither chunks is not provided for one or more dimensions, chunk
        sizes along that dimension will not be updated; non-dask arrays will be
        converted into dask arrays with a single block.

        Parameters
        ----------
        chunks : int, tuple or dict, optional
            Chunk sizes along each dimension, e.g., ``5``, ``(5, 5)`` or
            ``{'x': 5, 'y': 5}``.
        name : str, optional
            Used to generate the name for this array in the internal dask
            graph. Does not need not be unique.
        lock : optional
            Passed on to :py:func:`dask.array.from_array`, if the array is not
            already as dask array.

        Returns
        -------
        chunked : xarray.Variable
        
Coerce this array's data into a dask arrays with the given chunks.
If this variable is a non-dask array, it will be converted to dask
array. If it's a dask array, it will be rechunked to the given chunk
sizes.

If neither chunks is not provided for one or more dimensions, chunk
sizes along that dimension will not be updated; non-dask arrays will be
converted into dask arrays with a single block.

Parameters



Returns


Coerce this array ' s data into a dask arrays with the given chunks . If this variable is a non - dask array it will be converted to dask array . If it ' s a dask array it will be rechunked to the given chunk sizes . If neither chunks is not provided for one or more dimensions chunk sizes along that dimension will not be updated ; non - dask arrays will be converted into dask arrays with a single block . Parameters Returns
def chunk(self, chunks=None, name=None, lock=False):
        import dask
        import dask.array as da
        if utils.is_dict_like(chunks):
            chunks = {self.get_axis_num(dim): chunk for dim, chunk in chunks.items()}
        if chunks is None:
            chunks = self.chunks or self.shape
        data = self._data
        if is_duck_dask_array(data):
            data = data.rechunk(chunks)
        else:
            if isinstance(data, indexing.ExplicitlyIndexed):
                data = indexing.ImplicitToExplicitIndexingAdapter(
                    data, indexing.OuterIndexer
                )
                if LooseVersion(dask.__version__) < "2.0.0":
                    kwargs = {}
                else:
                    kwargs = {"meta": np.ndarray}
            else:
                kwargs = {}
            if utils.is_dict_like(chunks):
                chunks = tuple(chunks.get(n, s) for n, s in enumerate(self.shape))
            data = da.from_array(data, chunks, name=name, lock=lock, **kwargs)
        return type(self)(self.dims, data, self._attrs, self._encoding, fastpath=True)
def chunk ( self , chunks = None , name = None , lock = False ) : import dask import dask . array as da if utils . is_dict_like ( chunks ) : chunks = { self . get_axis_num ( dim ) : chunk for dim , chunk in chunks . items ( ) } if chunks is None : chunks = self . chunks or self . shape data = self . _data if is_duck_dask_array ( data ) : data = data . rechunk ( chunks ) else : if isinstance ( data , indexing . ExplicitlyIndexed ) : data = indexing . ImplicitToExplicitIndexingAdapter ( data , indexing . OuterIndexer ) if LooseVersion ( dask . __version__ ) < "2.0.0" : kwargs = { } else : kwargs = { "meta" : np . ndarray } else : kwargs = { } if utils . is_dict_like ( chunks ) : chunks = tuple ( chunks . get ( n , s ) for n , s in enumerate ( self . shape ) ) data = da . from_array ( data , chunks , name = name , lock = lock , ** kwargs ) return type ( self ) ( self . dims , data , self . _attrs , self . _encoding , fastpath = True )
Coerce this array's data into a dask arrays with the given chunks.
Coerce this array ' s data into a dask arrays with the given chunks .
"""Coerce this array's data into a dask arrays with the given chunks.

        If this variable is a non-dask array, it will be converted to dask
        array. If it's a dask array, it will be rechunked to the given chunk
        sizes.

        If neither chunks is not provided for one or more dimensions, chunk
        sizes along that dimension will not be updated; non-dask arrays will be
        converted into dask arrays with a single block.

        Parameters
        ----------
        chunks : int, tuple or dict, optional
            Chunk sizes along each dimension, e.g., ``5``, ``(5, 5)`` or
            ``{'x': 5, 'y': 5}``.
        name : str, optional
            Used to generate the name for this array in the internal dask
            graph. Does not need not be unique.
        lock : optional
            Passed on to :py:func:`dask.array.from_array`, if the array is not
            already as dask array.

        Returns
        -------
        chunked : xarray.Variable
        """ # Unambiguously handle array storage backends (like NetCDF4 and h5py) # that can't handle general array indexing. For example, in netCDF4 you # can do "outer" indexing along two dimensions independent, which works # differently from how NumPy handles it. # da.from_array works by using lazy indexing with a tuple of slices. # Using OuterIndexer is a pragmatic choice: dask does not yet handle # different indexing types in an explicit way: # https://github.com/dask/dask/issues/2883 # All of our lazily loaded backend array classes should use NumPy # array operations.
self
chunks
name
lock