U
    vIdd                     @  s   d dl mZ d dlmZ d dlmZmZ ddlmZ ddl	m
Z
 d dlmZmZmZ d dlmZmZ d	d
dddddgZddddddZei dddddddddZdS )    )annotations)MappingProxyType)CallableAny   )AnnCollection)	AnnLoader)	read_elem
write_elemIOSpec)StorageTypeGroupStorageTyper   r   r	   r
   read_dispatchedwrite_dispatchedr   r   zGCallable[[Callable[[StorageType], Any], str, StorageType, IOSpec], Any]r   )elemcallbackreturnc                 C  s&   ddl m}m} |||d}|| S )a  
    Read elem, calling the callback at each sub-element.

    Params
    ------
    elem
        Storage container (e.g. `h5py.Group`, `zarr.Group`). This must have anndata
        element specifications.
    callback
        Function to call at each anndata encoded element. See details below for
        signature.


    The callback has the following signature:

    * `read_func` (`Callable`): A callable which takes the encoded element and returns it's decoded value.
      This is the default decoding function, and what to call if you don't want to modify the decoding.
      It will call this callback again at the next element encoding it sees.
    * `key` (`str`): They absolute key of the element in the store. This will be an absolute key.
    * `elem` (`StorageType`): The encoded element.
    * `iospec` (`IOSpec`): The specification of the element. This is passed as a keyword argument.

    See Also
    --------

    :doc:`/tutorials/notebooks/{read,write}_dispatched`
    r   )Reader	_REGISTRYr   )anndata._io.specsr   r   r	   )r   r   r   r   reader r   V/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/anndata/experimental/__init__.pyr      s    dataset_kwargsr   strz[Callable[[Callable[[StorageType, str, Any], None], GroupStorageType, str, Any, dict], None]None)storekeyr   r   r   c                C  s2   ddl m}m} |||d}|j| |||d dS )a  
    Write elem to store, recusively calling callback at each sub-element.

    Params
    ------
    store
        Storage container to be written to.
    key
        Key to write element to. To write to the root group, use "/".
    elem
        The element to write. Probably an AnnData.
    callback
        Function called when writing each element. See below for signature.
    dataset_kwargs
        Keyword arguments to pass to the dataset creation function.


    The callback has the following signature:

    * `write_func` (`Callable`): A callable which takes the in memory element and writes it to the store.
      This is the default encoding function, and what to call if you don't want to change behaviour at this level.
    * `store` (`GroupStorageType`): The store to write to.
    * `key` (`str`): The key to write elem into store at. This will be an absolute key.
    * `elem` (`Any`): The element to write.
    * `dataset_kwargs` (`dict`): Keyword arguments to pass to the dataset creation function. This is passed as a keyword argument.
    * `iospec` (`IOSpec`): The specification of the element. This is passed as a keyword argument.


    See Also
    --------

    :doc:`/tutorials/notebooks/{read,write}_dispatched`
    r   )Writerr   r   r   N)r   r    r   r
   )r   r   r   r   r   r    r   writerr   r   r   r   =   s    ,N)
__future__r   typesr   typingr   r   Zmulti_filesr   Zpytorchr   r   r	   r
   r   Zanndata._typesr   r   __all__r   r   r   r   r   r   <module>   s"   /