From 0fb02b9d7166edb49fe6fd276ef71b47213b8c58 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 9 Apr 2024 15:50:51 +0200 Subject: [PATCH 1/3] fix colorbars on different layers only show after additional draw --- eomaps/colorbar.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/eomaps/colorbar.py b/eomaps/colorbar.py index 94f53d878..9f243b066 100644 --- a/eomaps/colorbar.py +++ b/eomaps/colorbar.py @@ -255,31 +255,26 @@ def xchanged(event): self.ax_cb_plot.callbacks.connect("ylim_changed", ychanged) def _hide_singular_axes(self): - sing_hist = (self.ax_cb_plot.bbox.width <= 2) or ( self.ax_cb_plot.bbox.height <= 2 ) sing_cb = (self.ax_cb.bbox.width <= 2) or (self.ax_cb.bbox.height <= 2) - # trigger a draw to update axes positions before checking singularity - # (ignore any errors in here to avoid any remaining issues with singular axes - # if hist-updates are triggered faster than draw-events...) - try: - self._m.f.canvas.draw() - except Exception: - pass - sing_hist = (self.ax_cb_plot.bbox.width <= 2) or ( self.ax_cb_plot.bbox.height <= 2 ) sing_cb = (self.ax_cb.bbox.width <= 2) or (self.ax_cb.bbox.height <= 2) - if sing_hist: + # use additional constraint < 0.1 to re-show axes after they have been hidden + # (positions of hidden axes are not updated so we don't know the new position + # before re-drawing... and a re-draw is not wanted because it would fetch + # a new unnecessary background + if sing_hist and self._hist_size < 0.01: self.ax_cb_plot.set_visible(False) else: self.ax_cb_plot.set_visible(True) - if sing_cb: + if sing_cb and self._hist_size > 0.99: self.ax_cb.set_visible(False) else: self.ax_cb.set_visible(True) From e5344796abd0008bf628c3374cb03302edd0cc0e Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 9 Apr 2024 15:55:53 +0200 Subject: [PATCH 2/3] handle numpy linalg errors resulting from singular colorbar axes --- eomaps/_blit_manager.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/eomaps/_blit_manager.py b/eomaps/_blit_manager.py index f07e7cbaa..0bf21be33 100644 --- a/eomaps/_blit_manager.py +++ b/eomaps/_blit_manager.py @@ -1413,7 +1413,13 @@ def blit_artists(self, artists, bg="active", blit=True): cv.restore_region(bg) for a in artists: - self.figure.draw_artist(a) + try: + self.figure.draw_artist(a) + except np.linalg.LinAlgError: + # Explicitly catch numpy LinAlgErrors resulting from singular matrices + # that can occur when colorbar histogram sizes are dynamically updated + if _log.getEffectiveLevel() <= logging.DEBUG: + _log.debug(f"problem drawing artist {a}", exc_info=True) if blit: cv.blit() From 034ce667a07bdb14cdc9e75296086466785620b3 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 9 Apr 2024 15:56:19 +0200 Subject: [PATCH 3/3] update version to v8.1.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index fa9437b13..ff2b9f6a8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ eomaps = ["logo.png", "NE_features.json", "qtcompanion/icons/*"] [project] name = "eomaps" -version = "8.1" +version = "8.1.1" description = "A library to create interactive maps of geographical datasets." readme = "README.md" license = {file = "LICENSE"}