From e458b58c35b6958c2cf8e099cea5181867056c5e Mon Sep 17 00:00:00 2001 From: robbybp Date: Fri, 24 Nov 2023 12:40:05 -0700 Subject: [PATCH] add some context in hidden code blocks so doctests pass --- .../incidence_analysis/dulmage_mendelsohn.py | 11 ++++++++++- pyomo/contrib/incidence_analysis/interface.py | 13 ++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/pyomo/contrib/incidence_analysis/dulmage_mendelsohn.py b/pyomo/contrib/incidence_analysis/dulmage_mendelsohn.py index d3a460446e6..5a1b125c0ae 100644 --- a/pyomo/contrib/incidence_analysis/dulmage_mendelsohn.py +++ b/pyomo/contrib/incidence_analysis/dulmage_mendelsohn.py @@ -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 diff --git a/pyomo/contrib/incidence_analysis/interface.py b/pyomo/contrib/incidence_analysis/interface.py index 3b2c54f8a60..7670d3a1fae 100644 --- a/pyomo/contrib/incidence_analysis/interface.py +++ b/pyomo/contrib/incidence_analysis/interface.py @@ -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()