# 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
        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:
            lament = 'if no states given, model must contain key \'%s\''
            raise KeyError(lament % mdl.SHAPE)
        else:
            domain_states = domain.from_rect(shape = model.shape)
    
    domain_enum = state_enum.create(domain_states)
    
    # determine p_0, then construct a dense representation with respect to
    # the domain enumeration
    initial_state = model.get(mdl.INITIAL_STATE, None)
    if p_0 is None:
        if initial_state is None:
            lament = 'if no p_0 given, model must contain key \'%s\''
            raise ValueError(lament % mdl.INITIAL_STATE)
        else:
            p_0 = {initial_state : 1.0}
    
    if t_0 is None:
        t_0 = 0.0
    

# 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

        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:
            lament = 'if no states given, model must contain key \'%s\''
            raise KeyError(lament % mdl.SHAPE)
        else:
            domain_states = domain.from_rect(shape = model.shape)
    
    domain_enum = state_enum.create(domain_states)
    
    # determine p_0, then construct a dense representation with respect to
    # the domain enumeration
    initial_state = model.get(mdl.INITIAL_STATE, None)
    if p_0 is None:
        if initial_state is None:
            lament = 'if no p_0 given, model must contain key \'%s\''
            raise ValueError(lament % mdl.INITIAL_STATE)
        else:
            p_0 = {initial_state : 1.0}
    
    if t_0 is None:
        t_0 = 0.0
    

    member_flags = domain_enum.contains(domain.from_iter(p_0))