czbenchmarks.cli.resolve_reference ================================== .. py:module:: czbenchmarks.cli.resolve_reference Attributes ---------- .. autoapisummary:: czbenchmarks.cli.resolve_reference.ANNDATA_REF_PREFIX Classes ------- .. autoapisummary:: czbenchmarks.cli.resolve_reference.AnnDataReference Functions --------- .. autoapisummary:: czbenchmarks.cli.resolve_reference.is_anndata_reference czbenchmarks.cli.resolve_reference.resolve_value_recursively czbenchmarks.cli.resolve_reference.resolve_task_parameters Module Contents --------------- .. py:data:: ANNDATA_REF_PREFIX :value: '@' .. py:class:: AnnDataReference(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` DataRef represents a structured reference to a specific slot or field within an AnnData object. References are denoted by a leading '@' and can point to various AnnData attributes: - '@X' → adata.X (main data matrix) - '@obs' → adata.obs (entire observations DataFrame) - '@obs:cell_type' → adata.obs["cell_type"] (specific column in obs) - '@obsm:X_pca' → adata.obsm["X_pca"] (specific key in obsm) - '@layers:counts' → adata.layers["counts"] (specific layer) - '@var:gene_symbols' → adata.var["gene_symbols"] (specific column in var) - '@varm:some_key' → adata.varm["some_key"] (specific key in varm) - '@uns:some_key' → adata.uns["some_key"] (specific key in uns) .. attribute:: space The AnnData attribute to reference ('X', 'obs', 'obsm', 'var', 'varm', 'layers', 'uns'). :type: str .. attribute:: key The key or column name within the specified space, if applicable. :type: Optional[str] .. method:: parse(value str) -> DataRef: Parse a string reference (e.g., '@obs:cell_type') into a DataRef instance. .. method:: resolve(adata AnnData) -> Any: Resolve the reference against a given AnnData object, returning the referenced data. :raises ValueError: If the reference format is invalid or unsupported. :raises KeyError: If the specified key does not exist in the referenced AnnData attribute. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:attribute:: space :type: str .. py:attribute:: key :type: Optional[str] :value: None .. py:method:: parse(ref_string: str) -> AnnDataReference :staticmethod: .. py:method:: resolve(anndata: anndata.AnnData) -> Any .. py:function:: is_anndata_reference(value: Any) -> bool .. py:function:: resolve_value_recursively(value: Any, anndata: anndata.AnnData) -> Any .. py:function:: resolve_task_parameters(task_params: dict[str, Any], anndata: anndata.AnnData) -> dict[str, Any]