def test_initial_iteration(grid_3x3_graph): spanning_cluster = grid_3x3_graph.graph['span'] ret = next( percolate.sample_states(grid_3x3_graph, spanning_cluster=spanning_cluster)) assert ret['n'] == 0 assert ret['max_cluster_size'] == 1 assert np.array_equal(ret['moments'], np.ones(5, dtype=int) * 8) assert ('has_spanning_cluster' in ret) == spanning_cluster if spanning_cluster: assert not ret['has_spanning_cluster']
def test_sample_state_one_sided_auxiliary_nodes(empty_graph): empty_graph.add_node(1, span=0) with pytest.raises(ValueError): next(percolate.sample_states(empty_graph, spanning_cluster=True))
def test_sample_state_not_implemented_model(empty_graph): with pytest.raises(ValueError): next(percolate.sample_states(empty_graph, model='site'))
def test_sample_state_no_auxiliary_nodes(empty_graph): with pytest.raises(ValueError): next(percolate.sample_states(empty_graph, spanning_cluster=True))
def state_it(grid_3x3_graph): spanning_cluster = grid_3x3_graph.graph['span'] ret = percolate.sample_states(grid_3x3_graph, spanning_cluster=spanning_cluster) return ret, spanning_cluster