Skip to content

Commit

Permalink
module to "test" visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbybp committed Mar 23, 2024
1 parent 6464db3 commit 4f78f7a
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions pyomo/contrib/incidence_analysis/tests/test_visualize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
# rights in this software.
# This software is distributed under the 3-clause BSD License.
# ___________________________________________________________________________

import pyomo.common.unittest as unittest
from pyomo.common.dependencies import matplotlib, matplotlib_available
from pyomo.contrib.incidence_analysis.visualize import spy_dulmage_mendelsohn
from pyomo.contrib.incidence_analysis.tests.models_for_testing import (
make_gas_expansion_model,
make_dynamic_model,
make_degenerate_solid_phase_model,
)


@unittest.skipUnless(matplotlib_available, "Matplotlib is not available")
class TestSpy(unittest.TestCase):

def test_spy_dulmage_mendelsohn(self):
models = [
make_gas_expansion_model(),
make_dynamic_model(),
make_degenerate_solid_phase_model(),
]
for m in models:
fig, ax = spy_dulmage_mendelsohn(m)
# Note that this is a weak test. We just test that we can call the
# plot method, it doesn't raise an error, and gives us back the
# types we expect. We don't attemt to validate the resulting plot.
self.assertTrue(isinstance(fig, matplotlib.pyplot.Figure))
self.assertTrue(isinstance(ax, matplotlib.pyplot.Axes))


if __name__ == "__main__":
unittest.main()

0 comments on commit 4f78f7a

Please sign in to comment.