-
Notifications
You must be signed in to change notification settings - Fork 794
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
docs: Promote when-then-otherwise
in User Guide
#3544
Conversation
No visual change, but makes the markup itself easier to read
…d/altair into when-then-user-guide
- Replaced `dict` with `when-then-otherwise` - Replaced string expressions with `python` equivalent - Formatting update to avoid horizontal overflow
@joelostblom since your mention of this PR in #3548 (reply in thread), I've circled back to this. If you have the time, would you be able to double-check the tasks I've added in the description please? Going to start working through them now |
Looks great! The location for the callout seems suitable to me. The only thing I would add is that I think we should include an example in the user guide section for the use of empty inside the conditional, as opposed to in the parameter definition (#3490). |
Perfect thanks @joelostblom, I've added that to the list. Managed to get through a good chunk today, I'm expecting |
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.
I had a peak and it is looking great so far! One comment regarding syntax, curious to hear what you think.
First draft version. Unlike the other commits, this has to introduce the concept - so will require more scrutiny. vega#3544 (comment)
@joelostblom I wanted to check in with you, as I'm hoping to merge this PR soon. The following are complicated somewhat by this remaining open:
I'm thinking pragmatically here, if the only possibly outstanding concerns were regarding formatting - would you be okay if we tackled that in a follow up? I'm really happy with these updates we put together and wish to build on them further in the other issues/PRs I linked |
@mattijn if you're available I'm planning to merge this tomorrow and follow it up with The short rundown is that it will be adding support all the classes like this:
when used in both of these calls:
I can delay this if anyone would have an issue - but as I mentioned in #3544 (comment) - I'd really like to close this PR off if possible |
I haven't had a look to this PR before, but just had a quick glance. I understand the title to promote the when-then-otherwise in the user guide, but (unintentionally?) you ruffed many examples into another style that we did not like to promote in the examples. |
During NumFOCUS summit @binste and I had come up with a config object based on YAPF that comes close to the style of the Altair examples how one would write it manually. One can test that config style as such: import yapf
from yapf.yapflib.yapf_api import FormatCode
# Define the code you want to format
code = """
def example_function(x,y):
return (x+y)* (x-y)
"""
# Define YAPF configuration
style_config = {
'based_on_style': 'pep8',
'COLUMN_LIMIT': 88,
'SPLIT_BEFORE_EXPRESSION_AFTER_OPENING_PAREN': True,
'SPLIT_BEFORE_FIRST_ARGUMENT': True,
'ALLOW_SPLIT_BEFORE_DEFAULT_OR_NAMED_ASSIGNS': True,
'NO_SPACES_AROUND_SELECTED_BINARY_OPERATORS': False,
'DEDENT_CLOSING_BRACKETS': True,
'COALESCE_BRACKETS': True,
'SPLIT_BEFORE_DOT': True,
'SPLIT_BEFORE_CLOSING_BRACKET': True,
}
# Format the code using YAPF
formatted_code, _ = FormatCode(code, style_config=style_config)
# Display formatted code
print(formatted_code) I've to mention that this style is not endorsed by @binste, he just prefer to ruff it all! 😄 |
@dangotbanned Sorry for the delay here. I wanted to go in an revert the examples to the old syntax, but I've been buried in work lately =/ I don't want to hold up your future PRs, so I'm ok if this needs to be merged although if there is something that can be done to bring it closer to the old syntax (like what Mattijn is suggesting maybe?) then that might save time long term instead of trying to change these back in a follow up PR. As I mentioned in #3570 I do see the advantages of adhering to a syntax that is supported by Ruff, and if our current syntax is making it hard to update the docs effectively, then that's another argument in favor of switching. |
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.
Thanks for getting back to me @joelostblom (
#3544 (comment)), and @mattijn for your input (#3544 (comment))
I've marked up every instance I spotted that might be considered a change in syntax.
The good news is that @joelostblom's original comment that picked up on the change meant that most of this is limited to the .rst
examples.
So despite this PR touching 64 files; only 10 of these may require changes.
yapf
@mattijn I haven't looked into this in much detail yet, but have some thoughts.
Since it has both a CLI and module interface - there may be multiple ways we could use it with the code block stuff I added in #3630.
I called out #3570 (comment) directly there, as this was the exact use case I had in mind.
If we went down that route, I'd still prefer to keep that separate from this PR.
I do want to reiterate that I feel more strongly towards some form of autoformatting for examples - than a specific style.
My preference is ruff
, but within reason, I'm happy for this to be anything that others agree upon
tests/examples_arguments_syntax/bar_chart_with_highlighted_bar.py
Outdated
Show resolved
Hide resolved
Thank you for going through and reverting the style on all of these examples before merging @dangotbanned ! |
Will close #3500
Status
All outstanding work should be scoped to
parameters.rst
.Corrections/suggestions elsewhere are still welcome
The linked version represents Draft 1.
alt.condition
when-then-otherwise
examples #3492 (review)Tasks
alt.when
in waterfall chartv5.4.0
change commentparameters.rst
altair/doc/user_guide/interactions/parameters.rst
Lines 148 to 155 in 5207768
when(..., empty=False)
example in User Guide commentdf5555c
(#3544)parameters.rst
condition
references withwhen
commentbindings_widgets.rst
expressions.rst
jupyter_chart.rst
geoshape.rst
line.rst
text.rst
filter.rst
pivot.rst
compound_charts.rst
times_and_dates.rst
exploring-weather.rst
README.md
examples_methods_syntax/*.py
examples_arguments_syntax/*.py