diff --git a/mpisppy/convergers/primal_dual_converger.py b/mpisppy/convergers/primal_dual_converger.py index 69ef0cb7..15e0ab17 100644 --- a/mpisppy/convergers/primal_dual_converger.py +++ b/mpisppy/convergers/primal_dual_converger.py @@ -9,7 +9,6 @@ import numpy as np import os import pandas as pd -import matplotlib.pyplot as plt import mpisppy.convergers.converger from mpisppy import MPI from mpisppy.extensions.phtracker import TrackedData @@ -149,6 +148,9 @@ def plot_results(self): Plot the results of the convergence checks by reading in csv file and plotting """ + # don't create a hard dependency on matplotlib + import matplotlib.pyplot as plt + plot_fname = self.tracker.plot_fname conv_data = pd.read_csv(self.tracker.fname) @@ -167,4 +169,4 @@ def post_everything(self): Reading the convergence data and plotting the results ''' if self.tracking and self._rank == 0: - self.plot_results() \ No newline at end of file + self.plot_results() diff --git a/mpisppy/extensions/phtracker.py b/mpisppy/extensions/phtracker.py index c95ab462..dde9fafe 100644 --- a/mpisppy/extensions/phtracker.py +++ b/mpisppy/extensions/phtracker.py @@ -10,7 +10,6 @@ Must use the PH object for this to work ''' import ast -import matplotlib.pyplot as plt import numpy as np import os import pandas as pd @@ -452,6 +451,9 @@ def add_xbars(self, final=False): def plot_gaps(self, var): ''' plot the gaps; Assumes gaps are saved in a csv file ''' + # only import this if needed so we + # don't create a hard dependency + import matplotlib.pyplot as plt df = pd.read_csv(self.track_dict[var].fname, sep=',') diff --git a/setup.py b/setup.py index 4f6a0ef8..eef10dd6 100644 --- a/setup.py +++ b/setup.py @@ -39,6 +39,7 @@ 'numpy<2', 'scipy', 'pyomo>=6.4', + 'pandas', # should probably remove ], extras_require={ 'doc': [