-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add ability to generate ER hypergraphs without multiedges * update * Remove bad characters * Fix #361 * Revert "Fix #361" This reverts commit 28cbbf3. * Fix #361 * Update test.yml * fix non-multi-edge probability * formatting * Update random.py * Update xgi/generators/uniform.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> * Update using-xgi.rst * Response to review * Update uniform.py * Update xgi/generators/random.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> * Update xgi/generators/random.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> * Update xgi/generators/uniform.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> * Update xgi/generators/uniform.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> * Update xgi/generators/uniform.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> * Update xgi/generators/uniform.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> * Update xgi/generators/uniform.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> * Update xgi/generators/uniform.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> * updates * Conditional API note (#595) * Conditional API note * Update api_reference.rst * Remove bad characters * Update random.py * Update xgi/generators/random.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> * Update xgi/generators/random.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> * response to review * updates * Update random.py * format * Update random.py * update docs * add unit tests * Fix test * test different version * fix test * updates * last additions * update * fix error * unnecessary import * add unit tests * Update xgi/generators/random.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> * Update xgi/generators/random.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> * Update xgi/generators/random.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> * Update xgi/generators/random.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> --------- Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com>
- Loading branch information
1 parent
f2e2241
commit cce09e3
Showing
16 changed files
with
335 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[pytest] | ||
# always run doctests | ||
addopts = --doctest-modules | ||
addopts = --doctest-modules --ignore=docs | ||
# custom markers | ||
markers = | ||
webtest: mark test as an online test. | ||
slow: mark test as slow. | ||
slow: mark test as slow. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import random | ||
|
||
import numpy as np | ||
import pytest | ||
from scipy.special import comb | ||
|
||
import xgi | ||
|
||
|
||
def test_chung_lu_hypergraph(): | ||
k1 = {1: 1, 2: 2, 3: 3, 4: 4} | ||
k2 = {1: 2, 2: 2, 3: 3, 4: 3} | ||
H = xgi.chung_lu_hypergraph(k1, k2) | ||
assert H.num_nodes == 4 | ||
|
||
# seed | ||
H1 = xgi.chung_lu_hypergraph(k1, k2, seed=1) | ||
H2 = xgi.chung_lu_hypergraph(k1, k2, seed=2) | ||
H3 = xgi.chung_lu_hypergraph(k1, k2, seed=2) | ||
assert H1._edge != H2._edge | ||
assert H2._edge == H3._edge | ||
|
||
with pytest.warns(Warning): | ||
_ = xgi.chung_lu_hypergraph({1: 1, 2: 2}, {1: 2, 2: 2}) | ||
|
||
|
||
def test_dcsbm_hypergraph(): | ||
n = 50 | ||
k1 = {i: random.randint(1, n) for i in range(n)} | ||
k2 = {i: sorted(k1.values())[i] for i in range(n)} | ||
g1 = {i: random.choice([0, 1]) for i in range(n)} | ||
g2 = {i: random.choice([0, 1]) for i in range(n)} | ||
omega = np.array([[n // 2, 10], [10, n // 2]]) | ||
|
||
H = xgi.dcsbm_hypergraph(k1, k2, g1, g2, omega) | ||
|
||
assert H.num_nodes == 50 | ||
|
||
# seed | ||
H1 = xgi.dcsbm_hypergraph(k1, k2, g1, g2, omega, seed=1) | ||
H2 = xgi.dcsbm_hypergraph(k1, k2, g1, g2, omega, seed=2) | ||
H3 = xgi.dcsbm_hypergraph(k1, k2, g1, g2, omega, seed=2) | ||
assert H1._edge != H2._edge | ||
assert H2._edge == H3._edge | ||
|
||
|
||
def test_random_hypergraph(): | ||
# seed | ||
H1 = xgi.random_hypergraph(10, [0.1, 0.01], seed=1) | ||
H2 = xgi.random_hypergraph(10, [0.1, 0.01], seed=2) | ||
H3 = xgi.random_hypergraph(10, [0.1, 0.01], seed=2) | ||
|
||
assert H1._edge != H2._edge | ||
assert H2._edge == H3._edge | ||
|
||
assert H1.num_nodes == 10 | ||
assert xgi.unique_edge_sizes(H1) == [2, 3] | ||
|
||
# wrong inputs | ||
# p > 1 | ||
with pytest.raises(ValueError): | ||
H1 = xgi.random_hypergraph(10, [1, 1.1]) | ||
# p < 0 | ||
with pytest.raises(ValueError): | ||
H1 = xgi.random_hypergraph(10, [1, -2]) | ||
# p list and order number | ||
with pytest.raises(ValueError): | ||
H1 = xgi.random_hypergraph(10, [0.1, 0.1], order=3) | ||
# different lengths | ||
with pytest.raises(ValueError): | ||
H1 = xgi.random_hypergraph(10, [0.1, 0.1], order=[3]) | ||
|
||
# uniform | ||
H4 = xgi.random_hypergraph(10, 0.1, order=2, seed=1) | ||
assert H4.num_nodes == 10 | ||
assert xgi.unique_edge_sizes(H4) == [3] | ||
|
||
H5 = xgi.random_hypergraph(10, [0.1, 0.1], order=[1, 3], seed=1) | ||
assert H5.num_nodes == 10 | ||
assert xgi.unique_edge_sizes(H5) == [2, 4] | ||
|
||
|
||
def test_fast_random_hypergraph(): | ||
# seed | ||
H1 = xgi.fast_random_hypergraph(10, [0.1, 0.01], seed=1) | ||
H2 = xgi.fast_random_hypergraph(10, [0.1, 0.01], seed=2) | ||
H3 = xgi.fast_random_hypergraph(10, [0.1, 0.01], seed=2) | ||
|
||
assert H1._edge != H2._edge | ||
assert H2._edge == H3._edge | ||
|
||
assert H1.num_nodes == 10 | ||
assert xgi.unique_edge_sizes(H1) == [2, 3] | ||
|
||
# wrong inputs | ||
# p > 1 | ||
with pytest.raises(ValueError): | ||
H1 = xgi.fast_random_hypergraph(10, [1, 1.1]) | ||
# p < 0 | ||
with pytest.raises(ValueError): | ||
H1 = xgi.fast_random_hypergraph(10, [1, -2]) | ||
# p list and order number | ||
with pytest.raises(ValueError): | ||
H1 = xgi.fast_random_hypergraph(10, [0.1, 0.1], order=3) | ||
# different lengths | ||
with pytest.raises(ValueError): | ||
H1 = xgi.fast_random_hypergraph(10, [0.1, 0.1], order=[3]) | ||
|
||
# uniform | ||
H4 = xgi.fast_random_hypergraph(10, 0.1, order=2, seed=1) | ||
assert H4.num_nodes == 10 | ||
assert xgi.unique_edge_sizes(H4) == [3] | ||
|
||
H5 = xgi.fast_random_hypergraph(10, [0.1, 0.1], order=[1, 3], seed=1) | ||
assert H5.num_nodes == 10 | ||
assert xgi.unique_edge_sizes(H5) == [2, 4] | ||
|
||
H5 = xgi.fast_random_hypergraph(10, [1, 1]) | ||
assert H5.num_edges == comb(10, 2) + comb(10, 3) | ||
|
||
with pytest.raises(ValueError): | ||
xgi.fast_random_hypergraph(10, 0.1) | ||
|
||
with pytest.raises(ValueError): | ||
xgi.fast_random_hypergraph(10, 0.1, order=[1, 2]) | ||
|
||
with pytest.raises(ValueError): | ||
xgi.fast_random_hypergraph(10, [1.1, 1]) | ||
|
||
with pytest.raises(ValueError): | ||
xgi.fast_random_hypergraph(10, [-0.1, 1]) |
50 changes: 21 additions & 29 deletions
50
tutorials/in_depth/In Depth 4 - Drawing multilayer-style.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.