summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--networkx/utils/misc.py24
-rw-r--r--networkx/utils/random_sequence.py10
-rw-r--r--networkx/utils/tests/test__init.py11
3 files changed, 45 insertions, 0 deletions
diff --git a/networkx/utils/misc.py b/networkx/utils/misc.py
index 4caffbe1..bd58a4ed 100644
--- a/networkx/utils/misc.py
+++ b/networkx/utils/misc.py
@@ -19,6 +19,30 @@ import uuid
from itertools import tee, chain
import networkx as nx
+__all__ = [
+ "is_string_like",
+ "iterable",
+ "empty_generator",
+ "flatten",
+ "make_list_of_ints",
+ "is_list_of_ints",
+ "make_str",
+ "generate_unique_node",
+ "default_opener",
+ "dict_to_numpy_array",
+ "dict_to_numpy_array1",
+ "dict_to_numpy_array2",
+ "is_iterator",
+ "arbitrary_element",
+ "consume",
+ "pairwise",
+ "groups",
+ "to_tuple",
+ "create_random_state",
+ "create_py_random_state",
+ "PythonRandomInterface",
+]
+
# some cookbook stuff
# used in deciding whether something is a bunch of nodes, edges, etc.
diff --git a/networkx/utils/random_sequence.py b/networkx/utils/random_sequence.py
index 7bd68c79..ad9b34a3 100644
--- a/networkx/utils/random_sequence.py
+++ b/networkx/utils/random_sequence.py
@@ -7,6 +7,16 @@ import networkx as nx
from networkx.utils import py_random_state
+__all__ = [
+ "powerlaw_sequence",
+ "zipf_rv",
+ "cumulative_distribution",
+ "discrete_sequence",
+ "random_weighted_sample",
+ "weighted_choice",
+]
+
+
# The same helpers for choosing random sequences from distributions
# uses Python's random module
# https://docs.python.org/3/library/random.html
diff --git a/networkx/utils/tests/test__init.py b/networkx/utils/tests/test__init.py
new file mode 100644
index 00000000..ecbcce36
--- /dev/null
+++ b/networkx/utils/tests/test__init.py
@@ -0,0 +1,11 @@
+import pytest
+
+
+def test_utils_namespace():
+ """Ensure objects are not unintentionally exposed in utils namespace."""
+ with pytest.raises(ImportError):
+ from networkx.utils import nx
+ with pytest.raises(ImportError):
+ from networkx.utils import sys
+ with pytest.raises(ImportError):
+ from networkx.utils import defaultdict, deque