glue-viz / bqplot-image-gl

Jupyter widget for displaying images with a focus on astronomy
MIT License
19 stars 13 forks source link

fix: allow over 8 orders of magnitude in zooming #91

Closed maartenbreddels closed 2 years ago

maartenbreddels commented 2 years ago

see scales-delta.glsl for details.

The issues could be exposed using:

import numpy as np
from bqplot import Figure, LinearScale, Axis, ColorScale, Lines
from bqplot_image_gl import LinesGL
import ipywidgets as widgets

N = int(1e5)
x = np.arange(N) * 100 + 1e9
y = np.cumsum(np.random.random(N)*2-1)
y -= y.mean()

scale_x = LinearScale(min=x.min(), max=x.min()+1, allow_padding=False)
scale_y = LinearScale(allow_padding=False)
scales = {'x': scale_x, 'y': scale_y}
axis_x = Axis(scale=scale_x, label='x')
axis_y = Axis(scale=scale_y, label='y', orientation='vertical')
line_gl = LinesGL(x=x, y=y, scales=scales, colors=['orange'])
marks = [line_gl]
figure = Figure(scales=scales, axes=[axis_x, axis_y], marks=marks)
display(figure)

Fixes https://github.com/spacetelescope/jdaviz/issues/1177

codecov[bot] commented 2 years ago

Codecov Report

Merging #91 (bc5a791) into master (8677a0e) will not change coverage. The diff coverage is n/a.

@@           Coverage Diff           @@
##           master      #91   +/-   ##
=======================================
  Coverage   55.38%   55.38%           
=======================================
  Files           7        7           
  Lines         130      130           
=======================================
  Hits           72       72           
  Misses         58       58           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 8677a0e...bc5a791. Read the comment docs.

maartenbreddels commented 2 years ago

Note that after zooming in for 14 order of magnitude, we hit the float64 limit, I don't think that is easy to fix as it might involve fixing several layers (e.g. d3).