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

added test_axvspan in test.datetime.py #27130

Merged
merged 3 commits into from
Oct 24, 2023
Merged

added test_axvspan in test.datetime.py #27130

merged 3 commits into from
Oct 24, 2023

Conversation

danielcobej
Copy link
Contributor

@danielcobej danielcobej commented Oct 18, 2023

I´ve added code for test_axvspan method in test_datetime.py mentioned in issue #26864

Image output: (edited)
download

PR summary

PR checklist

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

Copy link
Member

@ksunden ksunden left a comment

Choose a reason for hiding this comment

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

Can you set the random seed so that we get a reproducible result?

(We aren't doing an image test here (yet) but we are likely to make it one at some point, and just having non reproducible test cases can make tracking things down all that much harder)

https://matplotlib.org/stable/devel/testing.html#random-data-in-tests

@danielcobej
Copy link
Contributor Author

Can you set the random seed so that we get a reproducible result?

(We aren't doing an image test here (yet) but we are likely to make it one at some point, and just having non reproducible test cases can make tracking things down all that much harder)

https://matplotlib.org/stable/devel/testing.html#random-data-in-tests

I've added seed number 19680801

)
for i in range(np.random.randint(1, 5)):
xmin = start_date + np.random.randint(0, 30) * time_delta
xmax = xmin + np.random.randint(1, 3) * time_delta
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to my comment on #27139, please use hardcoded values here rather than random draws.


bin_edges = [start_date + i * time_delta for i in range(31)]

fig, (ax1, ax2, ax3) = plt.subplots(3, 1, constrained_layout=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

can shorten to fig, axes = plt.subplots(3, 1, constrained_layout=True), and remove axes = [ax1, ax2, ax3] below

lib/matplotlib/tests/test_datetime.py Outdated Show resolved Hide resolved
Copy link
Contributor

@scottshambaugh scottshambaugh left a comment

Choose a reason for hiding this comment

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

This looks good to me, thank you for adding this test coverage!

@scottshambaugh scottshambaugh merged commit b34e704 into matplotlib:main Oct 24, 2023
40 checks passed
@scottshambaugh scottshambaugh added this to the v3.9.0 milestone Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants