From 391a50434acace04fbd4d3bf1470082dfbf21a46 Mon Sep 17 00:00:00 2001 From: Thomas Weise Date: Wed, 27 Dec 2023 12:57:37 +0800 Subject: [PATCH] minor fix to bin packing solution plotting --- moptipyapps/binpacking2d/plot_packing.py | 10 ++++++---- moptipyapps/version.py | 2 +- requirements.txt | 2 +- setup.cfg | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/moptipyapps/binpacking2d/plot_packing.py b/moptipyapps/binpacking2d/plot_packing.py index c9fb5da5..0b354a02 100644 --- a/moptipyapps/binpacking2d/plot_packing.py +++ b/moptipyapps/binpacking2d/plot_packing.py @@ -5,6 +5,7 @@ import moptipy.utils.plot_defaults as pd import moptipy.utils.plot_utils as pu from matplotlib.artist import Artist # type: ignore +from matplotlib.axes import Axes # type: ignore from matplotlib.figure import Figure # type: ignore from matplotlib.patches import Rectangle # type: ignore from matplotlib.text import Text # type: ignore @@ -95,8 +96,10 @@ def plot_packing(packing: Packing | str, # initialize the different plots bin_width: Final[int] = packing.instance.bin_width bin_height: Final[int] = packing.instance.bin_height + axes_list: Final[list[Axes]] = [] for the_axes, _, _, _, _, _ in bin_figures: axes = pu.get_axes(the_axes) + axes_list.append(axes) axes.set_ylim(0, bin_width) # pylint: disable=E1101 axes.set_ybound(0, bin_height) # pylint: disable=E1101 axes.set_xlim(0, bin_width) # pylint: disable=E1101 @@ -111,11 +114,10 @@ def plot_packing(packing: Packing | str, font_size: Final[float] = importance_to_font_size_func(-1) # get the transforms needed to obtain text dimensions - renderers: Final[list] = [ - pu.get_renderer(axes) for axes, _, _, _, _, _ in bin_figures] + renderers: Final[list] = [pu.get_renderer(axes) for axes in axes_list] inverse: Final[list] = [ axes.transData.inverted() # type: ignore # pylint: disable=E1101 - for axes, _, _, _, _, _ in bin_figures] + for axes in axes_list] z_order: int = 0 # the z-order of all drawing elements @@ -136,7 +138,7 @@ def plot_packing(packing: Packing | str, background = colors[item_id - 1] foreground = pd.text_color_for_background(colors[item_id - 1]) - axes = pu.get_axes(bin_figures[item_bin - 1][0]) + axes = axes_list[item_bin - 1] rend = renderers[item_bin - 1] inv = inverse[item_bin - 1] diff --git a/moptipyapps/version.py b/moptipyapps/version.py index 45af4409..d4250b13 100644 --- a/moptipyapps/version.py +++ b/moptipyapps/version.py @@ -1,4 +1,4 @@ """An internal file with the version of the `moptipyapps` package.""" from typing import Final -__version__: Final[str] = "0.8.42" +__version__: Final[str] = "0.8.43" diff --git a/requirements.txt b/requirements.txt index 71fa8e71..a018f28b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -22,7 +22,7 @@ # `moptipy` provides the basic optimization infrastructure and the spaces and # tools that we use for optimization. -moptipy == 0.9.101 +moptipy == 0.9.102 # `numpy` is needed for its efficient data structures. numpy == 1.26.1 diff --git a/setup.cfg b/setup.cfg index ef964215..c1cbd836 100644 --- a/setup.cfg +++ b/setup.cfg @@ -41,7 +41,7 @@ include_package_data = True install_requires = certifi >= 2023.7.22 defusedxml >= 0.7.1 - moptipy >= 0.9.101 + moptipy >= 0.9.102 numpy >= 1.26.1 numba >= 0.58.1 matplotlib >= 3.8.0