Skip to content
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

Revise flags of rangebreak pattern #4653

Merged
merged 12 commits into from
Mar 17, 2020
Merged

Conversation

archmoj
Copy link
Contributor

@archmoj archmoj commented Mar 16, 2020

Follow up of #4614 .
This PR changes '%w' to 'day of week'
and replaces '%H' with 'hour'.

Fixes bug for decimal bounds: before vs after

cc: @plotly/plotly_js | @nicolaskruchten

@archmoj archmoj added this to the v1.53.0 milestone Mar 16, 2020
' breaks from Saturday to Monday (i.e. skips the weekends).',
'- { pattern: \'%H\', bounds: [17, 8] }',
' breaks from 5pm to 8am (i.e. skips non-work hours).'
'- { pattern: \'time of day\', bounds: [16, 8] }',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bounds should be [18, 8] ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems reasonable (to me) to set operation' dfltback to "()" for thetime of day` case.

'- { pattern: \'%H\', bounds: [17, 8] }',
' breaks from 5pm to 8am (i.e. skips non-work hours).'
'- { pattern: \'time of day\', bounds: [16, 8] }',
' breaks from 4pm to 8am (i.e. skips non-work hours).'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from 6pm to 9am ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted the hour example and added operation fix in 94f8ef8.
We will come back to finalize this when revising defaults in the following PR.

@alexcjohnson
Copy link
Collaborator

we could potentially accept shorter versions

Let's leave the values as you have them here - I don't want to accept two values that do the same thing just because we can't agree which one is best 😄

@nicolaskruchten
Copy link
Contributor

we could potentially accept shorter versions

In general I tend towards a Pythonic "there should be one way of doing things" and "that one way should bias towards being easy to read rather than easy to write whenever they are in tension" so I'm definitely against something like dw in addition to day of week ;)

@nicolaskruchten
Copy link
Contributor

Per Slack, time of day doesn't make as much sense if it accepts fractional hours. Let's make it hour please. Sorry for all the back and forth.

@archmoj
Copy link
Contributor Author

archmoj commented Mar 17, 2020

Per Slack, time of day doesn't make as much sense if it accepts fractional hours. Let's make it hour please. Sorry for all the back and forth.

Done in d82db2e.

'These are the same directive as in `tickformat`, see',
'https://github.com/d3/d3-time-format#locale_format',
'If *day of week* - Sunday-based weekday as a decimal number [0, 6].',
'If *hour* - hour (24-hour clock) as a decimal number [0, 23].',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this accepts numbers from 0 to 23.999999 right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure.
cc: @alexcjohnson

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's check in on the time-strings here too plz. I don't mind if they're not supported but if they are we should leave it in and document it. :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fractional hours worked in my testing, and time strings did not, but the gold standard is adding a test :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@archmoj your call whether to add these tests here or in another PR but they should be somewhere before the release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am adding them in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are added in 8cc498e.
At the moment this only works properly for integers [0, 24] as mentioned in db38ce9.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in a333acb.

'for more info.',
'Examples:',
'- { pattern: \'%w\', bounds: [6, 0], operation: \'[]\' }',
'- { pattern: \'day of week\', bounds: [6, 0] }',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this PR implement the default operation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Those changes would be done in a separate PR.

@archmoj
Copy link
Contributor Author

archmoj commented Mar 17, 2020

@alexcjohnson I think this PR is provided the task it was supposed to do i.e. renaming those two flags.

@archmoj archmoj added the bug something broken label Mar 17, 2020
@archmoj
Copy link
Contributor Author

archmoj commented Mar 17, 2020

@alexcjohnson this PR is ready for the second round review.
Thank you!

Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! 💃

@archmoj archmoj merged commit 747be93 into master Mar 17, 2020
@archmoj archmoj deleted the change-rangebreak-pattern-flags branch March 17, 2020 23:34
'These are the same directive as in `tickformat`, see',
'https://github.com/d3/d3-time-format#locale_format',
'If *' + DAY_OF_WEEK + '* - Sunday-based weekday as a decimal number [0, 6].',
'If *' + HOUR + '* - hour (24-hour clock) as decimal numbers between 0 and 24.',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh we should note here that weekday needs to be an integer but hour can be fractional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants