8000 Turn autoscale into a contextmanager. by anntzer · Pull Request #5538 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Turn autoscale into a contextmanager. #5538

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

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add basic test for switching autoscale status.
  • Loading branch information
anntzer committed Nov 23, 2015
commit 4f30ccec5e3314da2ad7860c3e7503d72e13a4f5
17 changes: 17 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4118,6 +4118,23 @@ def test_axisbg_warning():
("The axisbg attribute was deprecated in version 2.0.")))


@cleanup
def test_autoscale():
plt.plot([0, 1], [0, 1])
assert_equal(plt.xlim(), (0, 1))
plt.autoscale(False)
plt.plot([2, 3], [2, 3])
assert_equal(plt.xlim(), (0, 1))
plt.autoscale(True)
plt.plot([1, 2], [1, 2])
assert_equal(plt.xlim(), (0, 3))
with plt.autoscale(False):
plt.plot([3, 4], [3, 4])
assert_equal(plt.xlim(), (0, 3))
plt.plot([4, 5], [4, 5])
assert_equal(plt.xlim(), (0, 5))


if __name__ == '__main__':
import nose
import sys
Expand Down
0