Skip to content

Commit

Permalink
add some context in hidden code blocks so doctests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbybp committed Nov 24, 2023
1 parent 71d1f7e commit e458b58
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
11 changes: 10 additions & 1 deletion pyomo/contrib/incidence_analysis/dulmage_mendelsohn.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,16 @@ def dulmage_mendelsohn(matrix_or_graph, top_nodes=None, matching=None):
For example:
.. doctest::
:skipif: True
:hide:
:skipif: not (networkx_available and scipy_available)
>>> # Hidden code block to make the following example runnable
>>> import scipy.sparse as sps
>>> from pyomo.contrib.incidence_analysis.dulmage_mendelsohn import dulmage_mendelsohn
>>> matrix = sps.identity(3)
.. doctest::
:skipif: not (networkx_available and scipy_available)
>>> row_dmpartition, col_dmpartition = dulmage_mendelsohn(matrix)
>>> rdmp = row_dmpartition
Expand Down
13 changes: 12 additions & 1 deletion pyomo/contrib/incidence_analysis/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,18 @@ def dulmage_mendelsohn(self, variables=None, constraints=None):
pairs in this maximum matching. For example:
.. doctest::
:skipif: True
:hide:
:skipif: not (networkx_available and scipy_available)
>>> # Hidden code block creating a dummy model so the following doctest runs
>>> import pyomo.environ as pyo
>>> from pyomo.contrib.incidence_analysis import IncidenceGraphInterface
>>> model = pyo.ConcreteModel()
>>> model.x = pyo.Var([1,2,3])
>>> model.eq = pyo.Constraint(expr=sum(m.x[:]) == 1)
.. doctest::
:skipif: not (networkx_available and scipy_available)
>>> igraph = IncidenceGraphInterface(model)
>>> var_dmpartition, con_dmpartition = igraph.dulmage_mendelsohn()
Expand Down

0 comments on commit e458b58

Please sign in to comment.