-
Notifications
You must be signed in to change notification settings - Fork 795
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
Aliases for ImputeParams and TitleParams #2732
Conversation
Let's not merge this for a little while to make sure this doesn't break anything and to think about whether we need to do anything more sophisticated. The point is to make it easier for `impute` and `title` to find the appropriate docstrings, as discussed in #2592
And I would add also make it more convenient and consistent to use these classes since the syntax is briefer and more similar to that of the other classes we use for similar things, e.g. @mattijn do you have any thoughts there? |
There are more candidate aliases I think? import requests as r
import re
vl_scheme = r.get('https://vega.github.io/schema/vega-lite/v5.json').json()
scheme_str = str(vl_scheme['definitions'])
col = []
for word in re.findall(r"\w+", scheme_str):
if 'Params' in word:
col.append(word)
list(set(col)) Returns 10 candidates: ['TimeUnitParams',
'TitleParams',
'SchemeParams',
'GraticuleParams',
'SequenceParams',
'BinParams',
'ImputeParams',
'ScaleBinParams',
'ScaleInterpolateParams',
'AutoSizeParams'] Not sure about this col_offset = []
for word in re.findall(r"\w+", scheme_str):
if 'Offset' in word:
col_offset.append(word)
list(set(col_offset)) ['theta2Offset',
'labelOffset',
'y2Offset',
'strokeDashOffset',
'Offset',
'gridDashOffset',
'yOffset',
'tickDashOffset',
'symbolDashOffset',
'xOffset',
'nestedOffsetPaddingInner',
'StackOffset',
'bandWithNestedOffsetPaddingInner',
'thetaOffset',
'bandWithNestedOffsetPaddingOuter',
'x2Offset',
'OffsetDef',
'strokeOffset',
'radiusOffset',
'radius2Offset',
'domainDashOffset',
'symbolOffset',
'tickOffset',
'gradientLabelOffset',
'labelFlushOffset',
'Offsets'] |
Ah, I only looked through some of the encodings methods when I tried so I missed those other Params helper classes, I think it would make sense to add those. For the Offset, I think |
@joelostblom I don't have a clear view of how the docstrings are currently generated. Is this PR still useful? If it is, I will go through the comments above carefully and try to implement the suggestions. |
These were required in the way I originally implemented the docstrings, but I haven't reviewed if the additions you made changed that. Regardless, I would be in favor of having these shortcuts (at least |
Co-authored-by: Joel Ostblom <joelostblom@users.noreply.github.com>
Thanks @mattijn for the extra examples above. I looked through them but didn't find any others which were being used as these attribute setter methods, so I didn't make any more additions beyond @joelostblom's suggested It seems kind of random to me that the Python 3.8 build is failing but not the builds for Python 3.7, 3.9, 3.10, 3.11. Do any of you see what the issue is? If the test issue can be resolved I'd say this is ready to be merged from my perspective. |
I'll rerun the failed tests. |
Hi @mattijn, thanks! I don't see any conflict with those two definitions you shared. Is there anything in particular you were worried about with those? I do think each customization we add that doesn't stem from Vega-Lite is a possible headache down the road, but since these aliases Please just let me know if I missed your concern! |
Would it be possible to add some examples what is different after this PR? I thought that we are getting a capital case |
I suggest that we remove the Some more detailed thoughts below: It looks like As for when to use I did confirm that these aliases are all required for the propagation of the docstrings from the corresponding helper classes, but the docstring from the |
Thanks @joelostblom for the detailed explanations! I went ahead and removed the I'm a little hesitant to go through changing the docs and examples using these aliases. My understanding is that in the long-run we will probably be using the |
Trying to ensure that we are not overwriting something defined on the Vega-Lite side when we define `Bin`, `Impute`, and `Title` in Altair.
In this most recent commit, I added a test trying to check if we were overwriting anything when we define |
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.
Looking good, and I think that test makes sense but I will ping @mattijn since he recently moved the tests around.
Also note that there is one failing test for Python 3.9.
my understanding is that bin will show the BinParams docstring, and I think that will not indicate that bin(True) is a valid option. To recognize that bin(True) is a valid option, you would have to look at the docs for the encoding channel. For example, the docs for alt.X rather than for alt.X().bin. Does that also match your understanding?
We actually fetch the docstring from both alt.BinParams
and from alt.X
and combine them together. The only thing missing from the alt.X
docstring is the first line, in this case bin : anyOf(boolean, :class:
BinParams, string, None)
which I am not sure would be helpful to include since the hint that we can use BinParams
is unhelpful now that we can write all the parameter names directly in alt.X().bin(param=)
rather than doing alt.X().bin(alt.BinParams(param=))
.
The current docstring actually does include a mention of the boolean, just not on top:
We can continue this discussion in #2806
Co-authored-by: Joel Ostblom <joelostblom@users.noreply.github.com>
Co-authored-by: Mattijn van Hoek <mattijn@gmail.com>
Thank you! GitHub is showing me "1 change requested" but as far as I can tell this is now updated to match the requested changes. |
@joelostblom did not yet approve your changes as part of his review |
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.
LGTM! Thank you!
Let's not merge this for a little while to make sure this doesn't break anything and to think about whether we need to do anything more sophisticated. The point is to make it easier for
impute
andtitle
to find the appropriate docstrings, as discussed in #2592