Skip to content

Commit

Permalink
minor fix to bin packing solution plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasWeise committed Dec 27, 2023
1 parent 30b8fe5 commit 391a504
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions moptipyapps/binpacking2d/plot_packing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion moptipyapps/version.py
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 391a504

Please sign in to comment.