B
    zd                 @   s0   d Z ddlmZmZ ddlZG dd deZdS )zBase class for Markov chains.    )ABCabstractmethodNc               @   s  e Zd ZdZdZedd Zejdd Zdd Zee	dd	 Z
ee	d
d Zee	dd Zee	dd Zee	dd Zee	dd Zee	dd Zee	dd Zee	dd Zee	dd Zee	dd Zee	dd Zee	d d! Zee	d"d# Ze	d$d% Ze	d&d' Zee	d(d) Zee	d*d+ Zee	d,d- Zee	d.d/ Ze	d0d1 Ze	d2d3 Zd4S )5	BaseChaina  Abstract base class for Markov chains.

    Provides standard functions for Chain and ParallelTemperedChain.

    Attributes
    ----------
    parameters
    iteration
    lastclear
    scratchlen
    positions
    stats
    acceptance
    blobs
    start_position
    stats0
    blob0
    current_position
    current_stats
    current_blob
    bit_generator
    random_state
    state
    hasblobs
    chain_id : int
        Integer identifying the chain. Default is 0.
    r   c             C   s   | j S )z,The sampled parameters, as a tuple.
        )_parameters)self r   ]/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/epsie/chain/base.py
parameters4   s    zBaseChain.parametersc             C   s    t |tjr|g}t|| _dS )z!Stores the parameters as a tuple.N)
isinstancesixstring_typestupler   )r   r	   r   r   r   r	   :   s    c             C   s   | j | j S )N)	iteration	lastclear)r   r   r   r   __len__A   s    zBaseChain.__len__c             C   s   dS )z Whether the model returns blobs.Nr   )r   r   r   r   hasblobsD   s    zBaseChain.hasblobsc             C   s   dS )z/The number of times the chain has been stepped.Nr   )r   r   r   r   r   J   s    zBaseChain.iterationc             C   s   dS )zMReturns the iteration of the last time the chain memory was cleared.
        Nr   )r   r   r   r   r   P   s    zBaseChain.lastclearc             C   s   dS )z%The length of the scratch space used.Nr   )r   r   r   r   
scratchlenW   s    zBaseChain.scratchlenc             C   s   dS )z6Dictionary mapping parameters to their start position.Nr   )r   r   r   r   start_position]   s    zBaseChain.start_positionc             C   s   dS )zADictionary of the log likelihood and prior at the start position.Nr   )r   r   r   r   stats0c   s    zBaseChain.stats0c             C   s   dS )z2Dictionary of the blob data at the start position.Nr   )r   r   r   r   blob0i   s    zBaseChain.blob0c             C   s   dS )z:The history of all of the positions, as a structred array.Nr   )r   r   r   r   	positionso   s    zBaseChain.positionsc             C   s   dS )z[The log likelihoods and log priors of the positions, as a structred
        array.
        Nr   )r   r   r   r   statsu   s    zBaseChain.statsc             C   s   dS )zeThe history of all of acceptance ratios and accepted booleans, as
        a structred array.
        Nr   )r   r   r   r   
acceptance}   s    zBaseChain.acceptancec             C   s   dS )zThe history of all of the blob data, as a structred array.

        If the model does not return blobs, this is just ``None``.
        Nr   )r   r   r   r   blobs   s    zBaseChain.blobsc             C   s   dS )z0Dictionary of the current position of the chain.Nr   )r   r   r   r   current_position   s    zBaseChain.current_positionc             C   s   dS )z\Dictionary giving the log likelihood and log prior of the current
        position.
        Nr   )r   r   r   r   current_stats   s    zBaseChain.current_statsc             C   s   dS )zDictionary of the blob data of the current position.

        If the model does not return blobs, just returns ``None``.
        Nr   )r   r   r   r   current_blob   s    zBaseChain.current_blobc             C   s   dS )zeClears memory of the current chain, and sets start position to the
        current position.
        Nr   )r   r   r   r   clear   s    zBaseChain.clearc             C   s   dS )z5Returns all of the chain data at the requested index.Nr   )r   indexr   r   r   __getitem__   s    zBaseChain.__getitem__c             C   s   dS )z$The random bit generator being used.Nr   )r   r   r   r   bit_generator   s    zBaseChain.bit_generatorc             C   s   dS )z$Returns the random number generator.Nr   )r   r   r   r   random_generator   s    zBaseChain.random_generatorc             C   s   dS )z.The current state of the random bit generator.Nr   )r   r   r   r   random_state   s    zBaseChain.random_statec             C   s   dS )zReturns the current state of the chain.

        The state consists of everything needed such that setting a chain's
        state using another's state will result in identical results.
        Nr   )r   r   r   r   state   s    zBaseChain.statec             C   s   dS )a@  Sets the state of the chain using the given dict.

        .. warning::
           Running this will clear the chain's current memory, and replace its
           current position with what is saved in the state.

        Parameters
        ----------
        state : dict
            Dictionary of state values.
        Nr   )r   r#   r   r   r   	set_state   s    zBaseChain.set_statec             C   s   dS )z#Evolves the chain by a single step.Nr   )r   r   r   r   step   s    zBaseChain.stepN) __name__
__module____qualname____doc__Zchain_idpropertyr	   setterr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r   r   r   r   r      sZ   	r   )r)   abcr   r   r   r   r   r   r   r   <module>   s   