diff --git a/networkz/algorithms/__init__.py b/networkz/algorithms/__init__.py index 5f9af6d..031119f 100644 --- a/networkz/algorithms/__init__.py +++ b/networkz/algorithms/__init__.py @@ -1,4 +1,5 @@ from networkx.algorithms import * +from networkz.algorithms import max_weight_fractional_matching from networkx.algorithms import bipartite from networkz.algorithms.bipartite import rank_maximal_matching from networkx.algorithms import approximation diff --git a/networkz/conftest.py b/networkz/conftest.py new file mode 100644 index 0000000..441743e --- /dev/null +++ b/networkz/conftest.py @@ -0,0 +1,63 @@ +""" +Testing +======= + +General guidelines for writing good tests: + +- doctests always assume ``import networkx as nx`` so don't add that +- prefer pytest fixtures over classes with setup methods. +- use the ``@pytest.mark.parametrize`` decorator +- use ``pytest.importorskip`` for numpy, scipy, pandas, and matplotlib b/c of PyPy. + and add the module to the relevant entries below. + +""" + +import pytest + +import networkz + + +@pytest.fixture(autouse=True) +def add_nx(doctest_namespace): + doctest_namespace["nx"] = networkz + # TODO: remove the try-except block when we require numpy >= 2 + try: + import numpy as np + + np.set_printoptions(legacy="1.21") + except ImportError: + pass + +# What dependencies are installed? + +try: + import numpy + + has_numpy = True +except ImportError: + has_numpy = False + +try: + import scipy + + has_scipy = True +except ImportError: + has_scipy = False + + + +# List of files that pytest should ignore + +collect_ignore = [] + +needs_numpy = [ + "algorithms/max_weight_fractional_matching.py", +] +needs_scipy = [ + "algorithms/max_weight_fractional_matching.py", +] + +if not has_numpy: + collect_ignore += needs_numpy +if not has_scipy: + collect_ignore += needs_scipy diff --git a/pyproject.toml b/pyproject.toml index 608c566..29efeab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,25 +35,16 @@ email = 'networkz-discuss@googlegroups.com' [project.optional-dependencies] default = [ - 'networkx', - 'numpy>=1.22', - 'scipy>=1.9,!=1.11.0,!=1.11.1', + 'networkx[default]', ] developer = [ - 'changelist==0.4', - 'pre-commit>=3.2', - 'mypy>=1.1', - 'rtoml', + 'networkx[developer]', ] extra = [ - 'lxml>=4.6', - 'pygraphviz>=1.11', - 'pydot>=1.4.2', - 'sympy>=1.10', + 'networkx[extra]', ] test = [ - 'pytest>=7.2', - 'pytest-cov>=4.0', + 'networkx[test]', ] [tool.setuptools] diff --git a/requirements/default.txt b/requirements/default.txt index 205c33f..20272f3 100644 --- a/requirements/default.txt +++ b/requirements/default.txt @@ -1,3 +1 @@ -networkx -numpy>=1.22 -scipy>=1.9,!=1.11.0,!=1.11.1 +networkx[default] diff --git a/requirements/developer.txt b/requirements/developer.txt index fd8000c..8051f51 100644 --- a/requirements/developer.txt +++ b/requirements/developer.txt @@ -1,2 +1 @@ -pre-commit>=3.2 -mypy>=1.1 \ No newline at end of file +networkx[developer] \ No newline at end of file diff --git a/requirements/extra.txt b/requirements/extra.txt index 1369cb9..926ed1e 100644 --- a/requirements/extra.txt +++ b/requirements/extra.txt @@ -1,4 +1 @@ -lxml>=4.6 -pygraphviz>=1.11 -pydot>=1.4.2 -sympy>=1.10 \ No newline at end of file +networkx[extra] \ No newline at end of file diff --git a/requirements/test.txt b/requirements/test.txt index 7f06e89..4ff9f8e 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,2 +1 @@ -pytest>=7.2 -pytest-cov>=4.0 \ No newline at end of file +networkx[test] \ No newline at end of file