Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/networkx/utils/tests/test_random_sequence.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 import pytest | |
2 from networkx.utils import ( | |
3 powerlaw_sequence, | |
4 zipf_rv, | |
5 random_weighted_sample, | |
6 weighted_choice, | |
7 ) | |
8 | |
9 | |
10 def test_degree_sequences(): | |
11 seq = powerlaw_sequence(10, seed=1) | |
12 seq = powerlaw_sequence(10) | |
13 assert len(seq) == 10 | |
14 | |
15 | |
16 def test_zipf_rv(): | |
17 r = zipf_rv(2.3, xmin=2, seed=1) | |
18 r = zipf_rv(2.3, 2, 1) | |
19 r = zipf_rv(2.3) | |
20 assert type(r), int | |
21 pytest.raises(ValueError, zipf_rv, 0.5) | |
22 pytest.raises(ValueError, zipf_rv, 2, xmin=0) | |
23 | |
24 | |
25 def test_random_weighted_sample(): | |
26 mapping = {"a": 10, "b": 20} | |
27 s = random_weighted_sample(mapping, 2, seed=1) | |
28 s = random_weighted_sample(mapping, 2) | |
29 assert sorted(s) == sorted(mapping.keys()) | |
30 pytest.raises(ValueError, random_weighted_sample, mapping, 3) | |
31 | |
32 | |
33 def test_random_weighted_choice(): | |
34 mapping = {"a": 10, "b": 0} | |
35 c = weighted_choice(mapping, seed=1) | |
36 c = weighted_choice(mapping) | |
37 assert c == "a" |