def test_update_from_vectors(): """ Update the top and bot vector with the exact same ones as bip already has. The resulting bip should be exactly the same. """ test_bip = bip.from_sequences([2, 1, 3, 2], [2, 2, 2, 2], ["a", "b", "c", "d"], ["alpha", "beta", "gamma", "delta"]) test_bip.update_from_vectors(test_bip.top_vector, test_bip.bot_vector) assert test_bip.top_degree.tolist() == [2, 1, 3, 2] assert test_bip.bot_degree.tolist() == [2, 2, 2, 2] assert test_bip.top_index.tolist() == [0, 2, 3, 6] assert test_bip.top_vector.tolist() == [0, 0, 1, 2, 2, 2, 3, 3] assert test_bip.bot_vector.tolist() == [0, 0, 1, 1, 2, 2, 3, 3] assert test_bip.top_names.tolist() == ["a", "b", "c", "d"] assert test_bip.bot_names.tolist() == ["alpha", "beta", "gamma", "delta"] assert test_bip.small assert test_bip.n_top == 4 assert test_bip.n_bot == 4 assert test_bip.m == 8 assert test_bip.max_top_deg == 3 assert test_bip.min_top_deg == 1 assert test_bip.max_bot_deg == 2 assert test_bip.min_bot_deg == 2 assert test_bip.is_multigraph
def test_reorder_top_decreasing_degree(): test_bip = bip.from_sequences( [3, 1, 4, 2, 6, 1, 1, 3, 2], [2, 1, 8, 3, 1, 1, 2, 1, 4], ["a", "b", "c", "d", "e", "f", "g", "h", "i"], [ "alpha", "beta", "gamma", "delta", "epsilon", "omega", "eta", "upsilon", "zeta" ]) assert test_bip.top_degree.tolist() == [3, 1, 4, 2, 6, 1, 1, 3, 2] assert test_bip.top_names.tolist() == [ "a", "b", "c", "d", "e", "f", "g", "h", "i" ] test_bip.reorder_top_decreasing_degree() assert test_bip.top_degree.tolist() == [6, 4, 3, 3, 2, 2, 1, 1, 1] assert test_bip.top_names.tolist() == [ 'e', 'c', 'h', 'a', 'i', 'd', 'g', 'f', 'b' ]
def test_reorder_bot_decreasing_degree(): test_bip = bip.from_sequences( [3, 1, 4, 2, 6, 1, 1, 3, 2], [2, 1, 8, 3, 1, 1, 2, 1, 4], ["a", "b", "c", "d", "e", "f", "g", "h", "i"], [ "alpha", "beta", "gamma", "delta", "epsilon", "omega", "eta", "upsilon", "zeta" ]) assert test_bip.bot_degree.tolist() == [2, 1, 8, 3, 1, 1, 2, 1, 4] assert test_bip.bot_names.tolist() == [ "alpha", "beta", "gamma", "delta", "epsilon", "omega", "eta", "upsilon", "zeta" ] test_bip.reorder_bot_decreasing_degree() assert test_bip.bot_degree.tolist() == [8, 4, 3, 2, 2, 1, 1, 1, 1] assert test_bip.bot_names.tolist() == [ 'gamma', 'zeta', 'delta', 'eta', 'alpha', 'upsilon', 'omega', 'epsilon', 'beta' ]
def test_genbip_repeated_configuration_asap(): test_bip = bip.from_sequences([2, 1, 3, 2], [2, 2, 2, 2], ["a", "b", "c", "d"], ["alpha", "beta", "gamma", "delta"]) genbip_rep_asap = GenBipRepeatedConfigurationAsap(seed=123) genbip_rep_asap.run(test_bip) assert test_bip.top_degree.tolist() == [3, 2, 2, 1] assert test_bip.bot_degree.tolist() == [2, 2, 2, 2] assert test_bip.top_index.tolist() == [0, 3, 5, 7] assert test_bip.top_vector.tolist() == [0, 0, 0, 1, 1, 2, 2, 3] assert test_bip.bot_vector.tolist() == [1, 0, 2, 0, 3, 2, 1, 3] assert test_bip.small assert test_bip.n_top == 4 assert test_bip.n_bot == 4 assert test_bip.m == 8 assert test_bip.max_top_deg == 3 assert test_bip.min_top_deg == 1 assert test_bip.max_bot_deg == 2 assert test_bip.min_bot_deg == 2 assert not test_bip.is_multigraph
def test_genbip_pruned_configuration(): test_bip = bip.from_sequences([2, 1, 3, 2], [2, 2, 2, 2], ["a", "b", "c", "d"], ["alpha", "beta", "gamma", "delta"]) genbip_pruned_conf = GenBipPrunedConfiguration(seed=123) genbip_pruned_conf.run(test_bip) assert test_bip.top_degree.tolist() == [1, 1, 3, 2] assert test_bip.bot_degree.tolist() == [1, 2, 1, 1, 1, 1] assert test_bip.top_index.tolist() == [0, 1, 2, 5] assert test_bip.top_vector.tolist() == [0, 1, 2, 2, 2, 3, 3] assert test_bip.bot_vector.tolist() == [0, 1, 1, 2, 3, 2, 3] assert test_bip.small assert test_bip.n_top == 4 assert test_bip.n_bot == 6 assert test_bip.m == 7 assert test_bip.max_top_deg == 3 assert test_bip.min_top_deg == 1 assert test_bip.max_bot_deg == 2 assert test_bip.min_bot_deg == 1 assert not test_bip.is_multigraph
def test_genbip_havel_hakimi(): test_bip = bip.from_sequences([2, 1, 3, 2], [2, 2, 2, 2], ["a", "b", "c", "d"], ["alpha", "beta", "gamma", "delta"]) genbip_hh = GenBipHavelHakimi(seed=123) genbip_hh.run(test_bip) assert test_bip.top_names.tolist() == ['c', 'd', 'a', 'b'] assert test_bip.bot_names.tolist() == ['delta', 'gamma', 'beta', 'alpha'] assert test_bip.top_degree.tolist() == [3, 2, 2, 1] assert test_bip.bot_degree.tolist() == [2, 2, 2, 2] assert test_bip.top_index.tolist() == [0, 3, 5, 7] assert test_bip.top_vector.tolist() == [0, 0, 0, 1, 1, 2, 2, 3] assert test_bip.bot_vector.tolist() == [2, 1, 0, 0, 3, 2, 3, 1] assert test_bip.small assert test_bip.n_top == 4 assert test_bip.n_bot == 4 assert test_bip.m == 8 assert test_bip.max_top_deg == 3 assert test_bip.min_top_deg == 1 assert test_bip.max_bot_deg == 2 assert test_bip.min_bot_deg == 2 assert not test_bip.is_multigraph
def test_genbip_configuration(): test_bip = bip.from_sequences([2, 1, 3, 2], [2, 2, 2, 2], ["a", "b", "c", "d"], ["alpha", "beta", "gamma", "delta"]) genbip_conf = GenBipConfiguration(seed=123) assert genbip_conf.seed == 123 genbip_conf.run(test_bip) assert test_bip.top_degree.tolist() == [2, 1, 3, 2] assert test_bip.bot_degree.tolist() == [2, 2, 2, 2] assert test_bip.top_index.tolist() == [0, 2, 3, 6] assert test_bip.top_vector.tolist() == [0, 0, 1, 2, 2, 2, 3, 3] assert test_bip.bot_vector.tolist() == [0, 0, 1, 3, 2, 1, 2, 3] assert test_bip.top_names.tolist() == ["a", "b", "c", "d"] assert test_bip.bot_names.tolist() == ["alpha", "beta", "gamma", "delta"] assert test_bip.small assert test_bip.n_top == 4 assert test_bip.n_bot == 4 assert test_bip.m == 8 assert test_bip.max_top_deg == 3 assert test_bip.min_top_deg == 1 assert test_bip.max_bot_deg == 2 assert test_bip.min_bot_deg == 2 assert test_bip.is_multigraph
def test_instantiation_from_sequences(): from_seq_bip = bip.from_sequences([2, 1, 3, 2], [2, 2, 2, 2], ["a", "b", "c", "d"], ["alpha", "beta", "gamma", "delta"]) assert from_seq_bip.top_filename == "" assert from_seq_bip.bot_filename == "" assert from_seq_bip.top_degree.tolist() == [2, 1, 3, 2] assert from_seq_bip.bot_degree.tolist() == [2, 2, 2, 2] assert from_seq_bip.top_index.tolist() == [0, 2, 3, 6] assert from_seq_bip.top_vector.tolist() == [0, 0, 1, 2, 2, 2, 3, 3] assert from_seq_bip.bot_vector.tolist() == [0, 0, 1, 1, 2, 2, 3, 3] assert from_seq_bip.top_names.tolist() == ["a", "b", "c", "d"] assert from_seq_bip.bot_names.tolist() == [ "alpha", "beta", "gamma", "delta" ] assert from_seq_bip.small assert from_seq_bip.n_top == 4 assert from_seq_bip.n_bot == 4 assert from_seq_bip.m == 8 assert from_seq_bip.max_top_deg == 3 assert from_seq_bip.min_top_deg == 1 assert from_seq_bip.max_bot_deg == 2 assert from_seq_bip.min_bot_deg == 2 assert from_seq_bip.is_multigraph