-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make bqplot linear scatter sizes more closely match matplotlib viewer #394
Conversation
I suppose the image comparison failure is not unexpected, as the produced figure should look different now – have to update the reference image then. Do we only need to update glue-jupyter/glue_jupyter/tests/images/py311-test-visual.json Lines 2 to 3 in 83aeb3a
to
then? |
self.scatter_mark.default_size = int(self.state.size_scaling * 7) | ||
s = ensure_numerical(self.layer[self.state.size_att].ravel()) | ||
s = ((s - self.state.size_vmin) / | ||
(self.state.size_vmax - self.state.size_vmin)) | ||
np.clip(s, 0, 1, out=s) | ||
s *= 0.95 | ||
s += 0.05 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those numbers (size_scaling * 7
, s
ranging from 0.05 to 1.0) are taken from comparison with the matplotlib defaults?
I was wondering if the division by 0 in
scatter_density_mark.py:210: RuntimeWarning: invalid value encountered in divide
normalized_counts = (self._counts - vmin) / (vmax - vmin)
was related, but that warning already pops up prior to this PR – I suppose that's bad user input really.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the 7 is a magic constant that I thought gave the closest match to the matplotlib layer artist - basically it's meant to serve a role similar what 30 does here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the parent LayerArtist
is crafted that way, matching that makes sense. I'm good with the implantation so far, let's wait a little if @astrofrog has any comments.
I'm not super familiar with the CircleCI system yet, but I think you're right that we just need to update the hashes. Once we're satisfied with all the code changes I'll take care of that. |
Go ahead with updating the hashes if you wish; once the CI is fixed this should be good to go in for the 0.18.0 release. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #394 +/- ##
==========================================
+ Coverage 86.61% 86.84% +0.22%
==========================================
Files 89 89
Lines 4946 5077 +131
==========================================
+ Hits 4284 4409 +125
- Misses 662 668 +6
☔ View full report in Codecov by Sentry. |
Thanks! Struggling to make sense of it myself – image comparison is now passing with the expected hash, though the figure_report still shows a different (the original) baseline image. From the pytest invocation I take that the reference figures are pulled from https://github.com/glue-viz/glue-jupyter-visual-tests; this in turn seems to be automatically updated when a change in I was more worried about the docs build still failing, but seeing now that readthedocs tries to use an obsolete .readthedocs.yml with Python 3.6. Should have rebased to pull in #386, but I think this will also sort itself out on merging. |
This PR aims to resolve #392 by making the linear size scaling behave more similarly to that of the matplotlib viewer. To do this, I ended up not using the size scales for the layer, but rather following the matplotlib viewer's example and capping the size.
FWIW, my initial thought was to do something like
but that gave results that differed from the matplotlib implementation when
size_vmin
was nonzero (like e.g. the example data in #392).