-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add rcfile function (which loads rc params from a given file). #861
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5bb3c2a
Add rcfile (loads parameters from a file).
3954377
Add rc_context and rename rcfile to rc_file.
44f2d83
Add docstring to rc_context and accept a dictionary too.
a54325e
Add test_rcparams.py to test rc_file and rc_context.
memmett 2430747
Update/tidy test_rcparams.py and move mpl.rc to test_rcparams.rc.
memmett 2847ad3
Merge pull request #1105 from pelson/test_failure
pelson ceb66d4
Add rcfile (loads parameters from a file).
2045bdb
Add rc_context and rename rcfile to rc_file.
0f81dff
Add docstring to rc_context and accept a dictionary too.
45cba0f
Add test_rcparams.py to test rc_file and rc_context.
memmett c8f5512
Update/tidy test_rcparams.py and move mpl.rc to test_rcparams.rc.
memmett 84a50e7
Merge branch 'master' of github.com:memmett/matplotlib
memmett 121f214
Add note about rc params to whats_new.rst.
memmett File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add test_rcparams.py to test rc_file and rc_context.
- Loading branch information
commit a54325e50ab6e4343af2d4123f4da7ef00193c87
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lines.linewidth: 33 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import os | ||
|
||
import matplotlib as mpl | ||
mpl.rc('text', usetex=False) | ||
mpl.rc('lines', linewidth=22) | ||
|
||
fname = os.path.abspath(os.path.dirname(__file__)) + os.sep + 'mpl.rc' | ||
|
||
def test_rcparams(): | ||
|
||
usetex = mpl.rcParams['text.usetex'] | ||
linewidth = mpl.rcParams['lines.linewidth'] | ||
|
||
# test context given dictionary | ||
with mpl.rc_context(rc={'text.usetex': not usetex}): | ||
assert mpl.rcParams['text.usetex'] == (not usetex) | ||
assert mpl.rcParams['text.usetex'] == usetex | ||
|
||
# test context given filename (mpl.rc sets linewdith to 33) | ||
with mpl.rc_context(fname=fname): | ||
assert mpl.rcParams['lines.linewidth'] == 33 | ||
assert mpl.rcParams['lines.linewidth'] == linewidth | ||
|
||
# test context given filename and dictionary | ||
with mpl.rc_context(fname=fname, rc={'lines.linewidth': 44}): | ||
assert mpl.rcParams['lines.linewidth'] == 44 | ||
assert mpl.rcParams['lines.linewidth'] == linewidth | ||
|
||
# test rc_file | ||
mpl.rc_file(fname) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will have a global effect on the tests and will need to be undone at the end of execution. Perhaps:
|
||
assert mpl.rcParams['lines.linewidth'] == 33 | ||
|
||
|
||
if __name__ == '__main__': | ||
test_rcparams() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This line is fine, but I don't believe the
abspath
is necessary. Normally:Would suffice.