anndata.settings#

anndata.settings = Settings(remove_unused_categories=True, check_uniqueness=True, copy_on_write_X=True, allow_write_nullable_strings=None, zarr_write_format=3, use_sparse_array_on_read=False, min_rows_for_chunked_h5_copy=1000, disallow_forward_slash_in_h5ad=True, write_csr_csc_indices_with_min_possible_dtype=False, auto_shard_zarr_v3=True, restrict_index_types=True)[source]#

Allows users to customize settings for the anndata package.

Settings here will generally be for advanced use-cases and should be used with caution.

For setting an option use override() (local) or set the attributes directly (global) i.e., anndata.settings.my_setting = foo. For assignment by environment variable, use the variable name in all caps with ANNDATA_ as the prefix before import of anndata.

The following options are available:

settings.remove_unused_categories: bool = True[source]#

Whether or not to remove unused categories with Categorical.

settings.check_uniqueness: bool = True[source]#

Whether or not to check uniqueness of the obs indices on __init__ of AnnData.

settings.copy_on_write_X: bool = True[source]#

Whether to copy-on-write X. Currently my_adata_view[subset].X = value will write back to the original AnnData object at the subset location. X is the only element where this behavior is implemented though.

settings.allow_write_nullable_strings: bool | None = None[source]#

Whether or not to allow writing of pd.arrays.[Arrow]StringArray. When set to None, it will be inferred from pd.options.future.infer_string. When set to False explicitly, we will try writing string arrays in the old, non-nullable format.

settings.zarr_write_format: Literal[2, 3] = 3[source]#

Which version of zarr to write to when anndata must internally open a write-able zarr group.

settings.use_sparse_array_on_read: bool = False[source]#

Whether or not to use scipy.sparse.sparray as the default class when reading in data

settings.min_rows_for_chunked_h5_copy: int = 1000[source]#

Minimum number of rows at a time to copy when writing out an H5 Dataset to a new location

settings.disallow_forward_slash_in_h5ad: bool = True[source]#

Whether or not to disallow the / character in keys for h5ad files

settings.write_csr_csc_indices_with_min_possible_dtype: bool = False[source]#

Write a csr or csc matrix with the minimum possible data type for indices, always unsigned integer.

settings.auto_shard_zarr_v3: bool | None = True[source]#

Whether or not to use zarr’s auto computation of sharding for v3. For v2 this setting will be ignored. The setting will apply to all calls to anndata’s writing mechanism (write_zarr / write_elem) and will not override any user-defined kwargs for shards.

settings.restrict_index_types: bool = True[source]#

Whether to force coercion to a string index upon declaration of the AnnData object or setting obs/var. “Setting this to False will e.g. also allow MultiIndex indexes upon declaration/setting. “Only integer indices i.e., those caught by pandas.api.types.is_integer_dtype() will always be converted to strings.