cfdm.chunksize¶
- class cfdm.chunksize(*arg)[source]¶
Bases:
ConstantAccess
Set the default chunksize used by dask arrays.
If called without any arguments then the existing chunksize is returned.
Note
Setting the chunk size will also change the dask global configuration value
'array.chunk-size'
. If chunksize is used in context manager then the dask configuration value is only altered within that context. Setting the chunk size directly from the dask configuration API will affect subsequent data creation, but will not change the value of chunksize.- Parameters:
- arg: number or str or Constant, optional
The chunksize in bytes. Any size accepted by dask.utils.parse_bytes is accepted, for instance
100
,'100'
,'1e6'
,'100 MB'
,'100M'
,'5kB'
,'5.4 kB'
,'1kiB'
,'1e6 kB'
, and'MB'
are all valid sizes.Note that if arg is a float, or a string that implies a non-integral amount of bytes, then the integer part (rounded down) will be used.
- Parameter example:
A chunksize of 2 MiB may be specified as
'2097152'
or'2 MiB'
- Parameter example:
Chunksizes of
'2678.9'
and'2.6789 KB'
are both equivalent to2678
.
- Returns:
- Constant
The value prior to the change, or the current value if no new value was specified.
Examples
>>> print(cfdm.chunksize()) 134217728 >>> old = cfdm.chunksize(1000000) >>> print(cfdm.chunksize(old)) 1000000 >>> print(cfdm.chunksize()) 134217728 >>> with cfdm.chunksize(314159): ... print(cfdm.chunksize()) ... 314159 >>> print(cfdm.chunksize()) 134217728
Return a Constant instance during class creation.
Methods
Initialize self. |