From b7ca61f8223f318db6d2eef0389e89611fd1dc67 Mon Sep 17 00:00:00 2001 From: "Brett M. Morris" Date: Fri, 18 Oct 2024 12:06:17 -0400 Subject: [PATCH] feat: Choose 'png' image compression in BqplotImageView by default (#470) * choose 'png' image compression by default * updating hashes with compression * Restore scatter2d hashes * another stab at py311-test-visual.json --------- Co-authored-by: Derek Homeier --- glue_jupyter/bqplot/image/frb_mark.py | 4 ++-- glue_jupyter/bqplot/image/viewer.py | 4 ++-- glue_jupyter/tests/images/py311-test-visual.json | 4 ++-- setup.cfg | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/glue_jupyter/bqplot/image/frb_mark.py b/glue_jupyter/bqplot/image/frb_mark.py index bfaebb68..6327d614 100644 --- a/glue_jupyter/bqplot/image/frb_mark.py +++ b/glue_jupyter/bqplot/image/frb_mark.py @@ -17,7 +17,7 @@ class FRBImage(ImageGL): - def __init__(self, viewer, array_maker): + def __init__(self, viewer, array_maker, compression='png'): # FIXME: need to use weakref to avoid circular references self.viewer = viewer @@ -29,7 +29,7 @@ def __init__(self, viewer, array_maker): 'y': self.viewer.scale_y, 'image': self.scale_image} - super().__init__(image=EMPTY_IMAGE, scales=self.scales) + super().__init__(image=EMPTY_IMAGE, scales=self.scales, compression=compression) self.array_maker = array_maker diff --git a/glue_jupyter/bqplot/image/viewer.py b/glue_jupyter/bqplot/image/viewer.py index 4fa916fb..16895b1e 100644 --- a/glue_jupyter/bqplot/image/viewer.py +++ b/glue_jupyter/bqplot/image/viewer.py @@ -34,14 +34,14 @@ class BqplotImageView(BqplotBaseView): tools = ['bqplot:home', 'bqplot:panzoom', 'bqplot:rectangle', 'bqplot:circle', 'bqplot:ellipse', 'bqplot:polygon', 'bqplot:lasso'] - def __init__(self, session): + def __init__(self, session, compression='png'): super(BqplotImageView, self).__init__(session) self.shape = None self._composite = CompositeArray() - self._composite_image = FRBImage(self, self._composite) + self._composite_image = FRBImage(self, self._composite, compression=compression) self.figure.marks = list(self.figure.marks) + [self._composite_image] self.state.add_callback('reference_data', self._reset_limits, echo_old=True) self.state.add_callback('x_att', self._reset_limits, echo_old=True) diff --git a/glue_jupyter/tests/images/py311-test-visual.json b/glue_jupyter/tests/images/py311-test-visual.json index f7e62c2b..b81bf836 100644 --- a/glue_jupyter/tests/images/py311-test-visual.json +++ b/glue_jupyter/tests/images/py311-test-visual.json @@ -1,5 +1,5 @@ { - "glue_jupyter.bqplot.image.tests.test_visual.test_contour_units[chromium]": "53ed6a698cd0fe879f92a7c428e14878e80b2640a8e09d69bb82c3847041bfb9", + "glue_jupyter.bqplot.image.tests.test_visual.test_contour_units[chromium]": "94a99faec5500df042edde00e9cdef58e230d68e9a762c1cd0ed0499eb0de83f", "glue_jupyter.bqplot.scatter.tests.test_visual.test_visual_scatter2d[chromium]": "91fe92465a858548adcfba167b4402c61b927dd4da61dd1ed486f9fed84d5915", "glue_jupyter.bqplot.scatter.tests.test_visual.test_visual_scatter2d_density[chromium]": "d3bd7a7ff60cff14154f50bd75c5b8821cbd25009b01600691ca35b568783c43" -} \ No newline at end of file +} diff --git a/setup.cfg b/setup.cfg index 916e31aa..fb5b793e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -23,7 +23,7 @@ install_requires = ipywidgets>=7.4.0 ipyvue>=1.2.0,<2 ipyvuetify>=1.2.0,<2 - bqplot-image-gl>=1.4.3 + bqplot-image-gl>=1.5.0 bqplot>=0.12.17 bqplot-gl scikit-image