Skip to content

Make cursor text precision actually correspond to pointing precision. #16776

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

Merged
merged 1 commit into from
Apr 11, 2020

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Mar 14, 2020

Currently, the cursor text (x=..., y=...) is typically displayed with
much, much more precision than the mouse cursor has (typically, one
pixel); IOW the last digits displayed are typically meaningless.

Make ScalarFormatter.format_data_short convert the inter-pixel distance
to data space and compute the corresponding number of significant digits
to use (and don't drop the final zeroes if any, as they are now, well,
significant).

(A similar change could be applied to other formatters, e.g.
LogFormatter.)

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer anntzer added this to the v3.3.0 milestone Mar 14, 2020
@anntzer anntzer force-pushed the cursor-significant-digits branch from 9c4d240 to 0dc2bfe Compare March 14, 2020 23:01
@tacaswell
Copy link
Member

👍 in principle, but this is in the hot-loop of user feedback, are we sure that this won't be slow?

@timhoffm
Copy link
Member

Can't we use a simple appoximate solution like digits = abs(log10((xmax - xmin) / NUM_PIXELS)) with an upper estimate of NUM_PIXELS=1e4 (details to be tuned).

@anntzer anntzer force-pushed the cursor-significant-digits branch from 0dc2bfe to ebf2282 Compare March 16, 2020 11:52
@anntzer
Copy link
Contributor Author

anntzer commented Mar 16, 2020

I slightly optimized the code, and added tim's rough (though likely reasonable :-)) estimate for cases other than x/y.

Looks like this PR makes format_data_short ~50x slower than before, but we're still at a reasonable ~100µs per call (so 10^4 calls per second). This should be compared to mouse polling rates (as that's what determines of often this function gets called), which a quick googling suggests is around 100Hz (up to 1kHz for gaming mouses), and screen refresh rates (typically 60Hz).

@anntzer anntzer mentioned this pull request Mar 16, 2020
6 tasks
@anntzer anntzer force-pushed the cursor-significant-digits branch from ebf2282 to 2b4d611 Compare March 16, 2020 15:21
@anntzer
Copy link
Contributor Author

anntzer commented Mar 17, 2020

added whatsnew

Currently, the cursor text (x=..., y=...) is typically displayed with
much, much more precision than the mouse cursor has (typically, one
pixel); IOW the last digits displayed are typically meaningless.

Make ScalarFormatter.format_data_short convert the inter-pixel distance
to data space and compute the corresponding number of significant digits
to use (and don't drop the final zeroes if any, as they are now, well,
significant).

(A similar change could be applied to other formatters, e.g.
LogFormatter.)
@anntzer anntzer force-pushed the cursor-significant-digits branch from 2b4d611 to bfb9cc7 Compare March 17, 2020 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants