
    phy                     J    S r SSKrSSKJr  SSKJr  SS jrS rS r	S	 r
S
 rg)z2
Functions for converting the timescale of a TPM.
    N)
csc_matrix   )convertc                 T    [         R                  " U S:  5      U R                  -  U:  $ )Nr   )npsumsize)matrix	thresholds     I/home/james-whalen/.local/lib/python3.13/site-packages/pyphi/timescale.pysparser      s#    66&1*+i77    c                 <    [        U 5      nX!-  R                  5       $ N)r   toarray)tpm
time_scale
sparse_tpms      r   sparse_timer      s    CJ$--//r   c                 @    [         R                  R                  X5      $ r   r   linalgmatrix_power)r   r   s     r   
dense_timer      s    99!!#22r   c                     [         R                  " U 5      n[        U 5      (       a  [        X!5      n O[	        X!5      n [         R
                  " U 5      $ )zIterate a TPM by the specified number of time steps.

Args:
    tpm (np.ndarray): A state-by-node tpm.
    time_scale (int): The number of steps to run the tpm.

Returns:
    np.ndarray
)r   state_by_node2state_by_stater   r   r   state_by_state2state_by_node)r   r   sbs_tpms      r   run_tpmr      sB     2237Gc{{'.-//44r   c                 R    [         R                  R                  X5      n SX S:  '   U $ )zIterate a connectivity matrix the specified number of steps.

Args:
    cm (np.ndarray): A connectivity matrix.
    time_scale (int): The number of steps to run.

Returns:
    np.ndarray: The connectivity matrix at the new timescale.
r   r   )cmr   s     r   run_cmr"   .   s(     
			/BBAvJIr   )g?)__doc__numpyr   scipy.sparser    r   r   r   r   r   r"    r   r   <module>r(      s.   
  # 80
35$r   