Skip to content

Commit

Permalink
Merge pull request #10 from OLAnetworkx/mwfm
Browse files Browse the repository at this point in the history
pytest and github actions
  • Loading branch information
oriyalperin authored Nov 9, 2023
2 parents 51f8029 + 0dba128 commit 0c344e2
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 24 deletions.
1 change: 1 addition & 0 deletions networkz/algorithms/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
63 changes: 63 additions & 0 deletions networkz/conftest.py
Original file line number Diff line number Diff line change
@@ -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
17 changes: 4 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,16 @@ email = '[email protected]'

[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]
Expand Down
4 changes: 1 addition & 3 deletions requirements/default.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
networkx
numpy>=1.22
scipy>=1.9,!=1.11.0,!=1.11.1
networkx[default]
3 changes: 1 addition & 2 deletions requirements/developer.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
pre-commit>=3.2
mypy>=1.1
networkx[developer]
5 changes: 1 addition & 4 deletions requirements/extra.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
lxml>=4.6
pygraphviz>=1.11
pydot>=1.4.2
sympy>=1.10
networkx[extra]
3 changes: 1 addition & 2 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
pytest>=7.2
pytest-cov>=4.0
networkx[test]

0 comments on commit 0c344e2

Please sign in to comment.