# Path: cmepy/cme_matrix.py
# def compute_propensity(prop, states):
# def optimise_csr_matrix(csr_matrix):
# def non_neg_states(state_array):
# def gen_reaction_matrices(model,
#                           domain_enum,
#                           sink,
#                           validity_test,
#                           outflow=False):
# def create_diff_eqs(reaction_matrices, phi = None):
#     def sum_reaction_matrices(reaction_indices):
#     def diff_eqs(t, p):
# 
# Path: cmepy/domain.py
# def from_rect(shape, slices=None, origin=None):
# def from_iter(state_iter):
# def from_mapping(state_mapping):
# def to_iter(state_array):
# 
# Path: cmepy/ode_solver.py
# class Solver(object):
#     def __init__(self, dy_dt, y_0, t_0 = 0.0, ode_config_callback = None):
#     def set_packing(self, pack, unpack, transform_dy_dt=True):
#     def _initialise_ode(self):
#                 def packed_dy_dt(t, y):
#     def dy_dt(self):
#     def t(self):
#     def y(self):
#     def step(self, t):
# 
# Path: cmepy/other_solver.py
# class SolverOther(Solver):
#     def __init__(self, dy_dt, y_0, t_0 = 0.0, ode_config_callback = None, **args):
#     def exp_euler_step(self, t, y):
#     def heun_step(self, t, y):
#     def imp_euler_step(self, t, y):
#     def imp_two_step(self, t, y, **var):
#     def step(self, t, **var):
#             TOL = var['TOL']
#             TOL = 0.00001
# 
# Path: cmepy/state_enum.py
# def create(initial_states):
#     def __init__(self, initial_states):
#     def update_ordering(self):
#     def extend(self, sigma):
#     def reinitialise(self, initial_states):
#     def indices(self, states):
#     def contains(self, states):
#     def states(self, index):
#     def pack_distribution(self, p_sparse, p_dense=None):
#     def unpack_distribution(self, p_dense, p_sparse=None):
# class StateEnum(object):
# 
# Path: cmepy/model.py
# PROPENSITIES = 'propensities'
# TRANSITIONS = 'transitions'
# NAME = 'name'
# INITIAL_STATE = 'initial_state'
# SHAPE = 'shape'
# SPECIES_NAMES = 'species'
# SPECIES_COUNTS = 'species_counts'
# REACTION_NAMES = 'reactions'
# ENTRIES = frozenset([
#     PROPENSITIES,
#     TRANSITIONS,
#     NAME,
#     INITIAL_STATE,
#     SHAPE,
#     SPECIES_NAMES,
#     SPECIES_COUNTS,
#     REACTION_NAMES,
# ])
# class Model(dict):
#     def __init__(self, **entries):
#     def _ensure_shape_invariance(self, x):
#     def __getattribute__(self, attrname):
#     def validate(self):
# def create(**entries):
# def raise_error(error_type, descr, value, message):
# def must_be_within_range(value, descr=None, min_value=None, max_value=None):
# def must_have_length(value, descr=None, min_len=None, max_len=None):
# def must_be_callable(value, descr=None):
# def must_be_string_like(value, descr=None):
# def must_be_int_like(value, descr=None, min_value=None, max_value=None):
# def must_be_mapping(value, descr=None):
# def must_contain_item(value, descr, item):
# def validate_name(value):
# def validate_propensities(value):
# def validate_species_names(value):
# def validate_species_counts(value):
# def validate_transitions(value):
# def validate_initial_state(value):
# def validate_shape(value):
# def validate_model(m):


import numpy
from cmepy import cme_matrix, domain, ode_solver, other_solver, state_enum
from cmepy import model as mdl
        mapping of time dependent coefficient
            functions keyed by subsets of reaction indices, with respect to the
            ordering of reactions determined by the order of the propensity
            functions inside the model. The propensities of the reactions
            with indices included in each subset are multiplied by the time
            dependent coefficient function. By default, no time dependent
            coefficient functions are specified, that is, the CME has
            time-independent propensities.
        
        domain_states : (optional) array of states in the domain.
            By default, generate the rectangular lattice of states defined by
            the 'shape' entry of the model. A ValueError is raised if both
            domain_states and 'shape' are unspecified.
    """
    
    mdl.validate_model(model)

    if sink and outflow:
        raise ValueError('sink and outflow cannot be both True')
    
    if sink_0 is not None:
        if not sink:
            raise ValueError('sink_0 may not be specified if sink is False')
        sink_0 = float(sink_0)
    else:
        sink_0 = 0.0
    
    # determine states in domain, then construct an enumeration of the
    # domain states
    if domain_states is None:

# Path: cmepy/cme_matrix.py
# def compute_propensity(prop, states):
# def optimise_csr_matrix(csr_matrix):
# def non_neg_states(state_array):
# def gen_reaction_matrices(model,
#                           domain_enum,
#                           sink,
#                           validity_test,
#                           outflow=False):
# def create_diff_eqs(reaction_matrices, phi = None):
#     def sum_reaction_matrices(reaction_indices):
#     def diff_eqs(t, p):
# 
# Path: cmepy/domain.py
# def from_rect(shape, slices=None, origin=None):
# def from_iter(state_iter):
# def from_mapping(state_mapping):
# def to_iter(state_array):
# 
# Path: cmepy/ode_solver.py
# class Solver(object):
#     def __init__(self, dy_dt, y_0, t_0 = 0.0, ode_config_callback = None):
#     def set_packing(self, pack, unpack, transform_dy_dt=True):
#     def _initialise_ode(self):
#                 def packed_dy_dt(t, y):
#     def dy_dt(self):
#     def t(self):
#     def y(self):
#     def step(self, t):
# 
# Path: cmepy/other_solver.py
# class SolverOther(Solver):
#     def __init__(self, dy_dt, y_0, t_0 = 0.0, ode_config_callback = None, **args):
#     def exp_euler_step(self, t, y):
#     def heun_step(self, t, y):
#     def imp_euler_step(self, t, y):
#     def imp_two_step(self, t, y, **var):
#     def step(self, t, **var):
#             TOL = var['TOL']
#             TOL = 0.00001
# 
# Path: cmepy/state_enum.py
# def create(initial_states):
#     def __init__(self, initial_states):
#     def update_ordering(self):
#     def extend(self, sigma):
#     def reinitialise(self, initial_states):
#     def indices(self, states):
#     def contains(self, states):
#     def states(self, index):
#     def pack_distribution(self, p_sparse, p_dense=None):
#     def unpack_distribution(self, p_dense, p_sparse=None):
# class StateEnum(object):
# 
# Path: cmepy/model.py
# PROPENSITIES = 'propensities'
# TRANSITIONS = 'transitions'
# NAME = 'name'
# INITIAL_STATE = 'initial_state'
# SHAPE = 'shape'
# SPECIES_NAMES = 'species'
# SPECIES_COUNTS = 'species_counts'
# REACTION_NAMES = 'reactions'
# ENTRIES = frozenset([
#     PROPENSITIES,
#     TRANSITIONS,
#     NAME,
#     INITIAL_STATE,
#     SHAPE,
#     SPECIES_NAMES,
#     SPECIES_COUNTS,
#     REACTION_NAMES,
# ])
# class Model(dict):
#     def __init__(self, **entries):
#     def _ensure_shape_invariance(self, x):
#     def __getattribute__(self, attrname):
#     def validate(self):
# def create(**entries):
# def raise_error(error_type, descr, value, message):
# def must_be_within_range(value, descr=None, min_value=None, max_value=None):
# def must_have_length(value, descr=None, min_len=None, max_len=None):
# def must_be_callable(value, descr=None):
# def must_be_string_like(value, descr=None):
# def must_be_int_like(value, descr=None, min_value=None, max_value=None):
# def must_be_mapping(value, descr=None):
# def must_contain_item(value, descr, item):
# def validate_name(value):
# def validate_propensities(value):
# def validate_species_names(value):
# def validate_species_counts(value):
# def validate_transitions(value):
# def validate_initial_state(value):
# def validate_shape(value):
# def validate_model(m):


# Path: cmepy/solver.py
import numpy
from cmepy import cme_matrix, domain, ode_solver, other_solver, state_enum
from cmepy import model as mdl

        mapping of time dependent coefficient
            functions keyed by subsets of reaction indices, with respect to the
            ordering of reactions determined by the order of the propensity
            functions inside the model. The propensities of the reactions
            with indices included in each subset are multiplied by the time
            dependent coefficient function. By default, no time dependent
            coefficient functions are specified, that is, the CME has
            time-independent propensities.
        
        domain_states : (optional) array of states in the domain.
            By default, generate the rectangular lattice of states defined by
            the 'shape' entry of the model. A ValueError is raised if both
            domain_states and 'shape' are unspecified.
    """
    
    mdl.validate_model(model)

    if sink and outflow:
        raise ValueError('sink and outflow cannot be both True')
    
    if sink_0 is not None:
        if not sink:
            raise ValueError('sink_0 may not be specified if sink is False')
        sink_0 = float(sink_0)
    else:
        sink_0 = 0.0
    
    # determine states in domain, then construct an enumeration of the
    # domain states
    if domain_states is None:

        if mdl.SHAPE not in model: