Ejemplo n.º 1
0
def test_project_yeast():
    bn = BooleanNetwork(rules=dynpy.sample_nets.budding_yeast_bn)
    bnensemble1 = MarkovChain.from_deterministic_system(bn, issparse=True)
    bnensemble2 = MarkovChain.from_deterministic_system(bn, issparse=False)

    marg1 = bnensemble1.project([0,1,2,3])
    marg2 = bnensemble2.project([0,1,2,3])
    assert_array_equal(marg1.transition_matrix.todense(), marg2.transition_matrix)
Ejemplo n.º 2
0
def test_project_yeast():
    bn = BooleanNetwork(rules=dynpy.sample_nets.budding_yeast_bn)
    bnensemble1 = MarkovChain.from_deterministic_system(bn, issparse=True)
    bnensemble2 = MarkovChain.from_deterministic_system(bn, issparse=False)

    marg1 = bnensemble1.project([0, 1, 2, 3])
    marg2 = bnensemble2.project([0, 1, 2, 3])
    assert_array_equal(marg1.transition_matrix.todense(),
                       marg2.transition_matrix)
Ejemplo n.º 3
0
def _test_project(issparse, initial_dist=None, expected=[[1., 0.], [0.5, 0.5]]):
    bn = BooleanNetwork(rules=bnrules, mode='FUNCS')
    bnensemble = MarkovChain.from_deterministic_system(
    				bn, issparse=issparse)
    marg = bnensemble.project([0], initial_dist=initial_dist)
    trans = dynpy.mx.todense(marg.transition_matrix)
    assert_array_equal(trans, np.core.asarray(expected))
Ejemplo n.º 4
0
def _test_project(issparse,
                  initial_dist=None,
                  expected=[[1., 0.], [0.5, 0.5]]):
    bn = BooleanNetwork(rules=bnrules, mode='FUNCS')
    bnensemble = MarkovChain.from_deterministic_system(bn, issparse=issparse)
    marg = bnensemble.project([0], initial_dist=initial_dist)
    trans = dynpy.mx.todense(marg.transition_matrix)
    assert_array_equal(trans, np.core.asarray(expected))
Ejemplo n.º 5
0
def test_from_deterministic():
    bn = BooleanNetwork(rules=bnrules, mode='FUNCS')
    mc = MarkovChain.from_deterministic_system(bn)

    expected = np.array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 1., 0., 0.],
                         [0., 0., 0., 1.]])

    assert_array_equal(dynpy.mx.todense(mc.transition_matrix), expected)
Ejemplo n.º 6
0
def test_from_deterministic():
	bn = BooleanNetwork(rules=bnrules, mode='FUNCS')
	mc = MarkovChain.from_deterministic_system(bn)

	expected = np.array([[ 1.,  0.,  0.,  0.],
						 [ 0.,  1.,  0.,  0.],
						 [ 0.,  1.,  0.,  0.],
						 [ 0.,  0.,  0.,  1.]])

	assert_array_equal(dynpy.mx.todense(mc.transition_matrix), expected)
Ejemplo n.º 7
0
def _test_attractors(issparse):
	bn = BooleanNetwork(rules=dynpy.sample_nets.budding_yeast_bn)
	bn_ensemble = MarkovChain.from_deterministic_system(bn, issparse=issparse)

	final_dist = bn_ensemble.iterate(bn_ensemble.get_uniform_distribution(), 100)
	bn.get_attractor_basins()
	total_states = 2 ** bn.num_vars

	dist2 = np.zeros(bn_ensemble.get_uniform_distribution().shape)
	for att, basin in zip(*bn.get_attractor_basins()):
	    basin_size = len(basin)
	    weight = float(basin_size) / total_states
	    dist2[ bn_ensemble.state2ndx_map[att[0]] ] = weight
	    
	assert_allclose(dist2, np.ravel(dynpy.mx.todense(final_dist)))
Ejemplo n.º 8
0
def _test_attractors(issparse):
    bn = BooleanNetwork(rules=dynpy.sample_nets.budding_yeast_bn)
    bn_ensemble = MarkovChain.from_deterministic_system(bn, issparse=issparse)

    final_dist = bn_ensemble.iterate(bn_ensemble.get_uniform_distribution(),
                                     100)
    bn.get_attractor_basins()
    total_states = 2**bn.num_vars

    dist2 = np.zeros(bn_ensemble.get_uniform_distribution().shape)
    for att, basin in zip(*bn.get_attractor_basins()):
        basin_size = len(basin)
        weight = float(basin_size) / total_states
        dist2[bn_ensemble.state2ndx_map[att[0]]] = weight

    assert_allclose(dist2, np.ravel(dynpy.mx.todense(final_dist)))
Ejemplo n.º 9
0
def test_check_transition_matrix_cont_sum():
    MarkovChain(transition_matrix=np.zeros((2, 2)), discrete_time=False)
Ejemplo n.º 10
0
def test_check_transition_matrix_discrete_sum():
    MarkovChain(transition_matrix=np.eye(2))
Ejemplo n.º 11
0
def test_check_transition_matrix_not_square():
    MarkovChain(transition_matrix=np.zeros(shape=[1, 2]))
Ejemplo n.º 12
0
def test_check_transition_matrix_discrete_wrongsum():
    MarkovChain(transition_matrix=np.ones((2, 2)))