-
Notifications
You must be signed in to change notification settings - Fork 76
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
layer-lettering to handle 2 "digits" (up to 700 layers) #1850
Conversation
081c493
to
6253904
Compare
6253904
to
b7a59f0
Compare
Codecov ReportBase: 88.29% // Head: 88.30% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1850 +/- ##
=======================================
Coverage 88.29% 88.30%
=======================================
Files 95 95
Lines 10396 10404 +8
=======================================
+ Hits 9179 9187 +8
Misses 1217 1217
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
do we need test coverage for this? I could move the function out of the method and just test it directly, but I also don't expect that we'd touch this code often/ever, so maybe we can ignore it 🤷 I definitely don't think we want a test that loads dozens of entries to force the code to go through this logic though, right? |
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.
Why not just cycle through unicode to increase max limit to 100k or so? 😉
jdaviz/utils.py
Outdated
@@ -175,6 +175,21 @@ def bqplot_clear_figure(fig): | |||
setattr(fig, 'axis_registry', {}) | |||
|
|||
|
|||
def alpha_index(index): | |||
"""Converts an index to A-Z, AA-ZZ |
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.
Since this might be used by other devs down the road, would be nice to expand a little bit with proper numpydoc and maybe even a short example, so they don't have to dig the test code to find out.
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.
Also do we have to worry about someone providing negative index? Is that possible?
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.
this is why I originally had it nested in the method as its not really intended to be used generally 😜 Negative index would give non-alphabet characters as long as 97-index >= 0
and would otherwise raise an error. I can catch and raise errors for negative indices if we want to keep this general, but that would never happen in its current use since it is always passed a length as the index.
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.
Okay, just want to make sure we'll never do fancy slicing numpy-style.
* full api doc description * better range checking and errors * use pytest.mark.parameterize * accept input larger than 701 (although starts to return non-alphabet strings)
jdaviz/utils.py
Outdated
""" | ||
# if we ever want to support more than 702 layers, then we'll need a third | ||
# "digit" and will need to account for the horizontal space in the legends | ||
if not isinstance(index, int): # pragma: no cover |
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.
Would still be nice to test the exceptions but as a separate test function from the parametrized one. Sorry for the extra work!
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.
The check for index > 701
is gone. Is there no more max limit?
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.
no, I decided to remove it. I don't think layer-lettering is a good place to enforce a maximum number of layers with a confusing traceback. As noted in the comments and the description of the PR, this will start to introduce special characters after index 701 (which was the previous behavior after 25). If that becomes a common use-case, then we can extend this logic to three (or N) digits and will need to update the styling of all components to handle the extra horizontal space required.
2a13ce8
to
9b24e60
Compare
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.
Looks good to me, I loaded a bunch of spectra and confirmed that it successfully goes into the double digits.
Co-authored-by: P. L. Lim <[email protected]>
2ef2eee
to
00b530b
Compare
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.
Feel free to merge when CI passes. Thanks!
… (up to 700 layers)
…0-on-v3.1.x Backport PR #1850 on branch v3.1.x (layer-lettering to handle 2 "digits" (up to 700 layers))
Description
(Ok, technically 702 layers). This pull request improves support for more than 26 layers by lettering with "AA" through "ZZ" instead of going to random characters that happen to be after
char(97 + 26)
.For inputs larger than
701
, this will begin to use non-alphabet characters in the first digit.702
gives'{a'
, for example.Change log entry
CHANGES.rst
? If you want to avoid merge conflicts,list the proposed change log here for review and add to
CHANGES.rst
before merge. If no, maintainershould add a
no-changelog-entry-needed
label.Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
trivial
label.