-
Notifications
You must be signed in to change notification settings - Fork 0
Adds a decorator for teeplot called teewrap
#9
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 all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a9f754c
initial commit
vivaansinghvi07 ef19222
use kwargs as default instead of both
vivaansinghvi07 a623011
add int and float to printable params
vivaansinghvi07 43e9618
use builtin behavior of teeplot_outinclude
vivaansinghvi07 c866a0f
use bool and str only, not numerical arguments
vivaansinghvi07 803011e
reverted to old code for anything other than teewrap
vivaansinghvi07 ee57e5d
add newline between functions
vivaansinghvi07 f5f06be
remove outdated part of documentation
vivaansinghvi07 864bc82
fix type hints
vivaansinghvi07 3951860
allow teewrap outattrs for more flexibility and general flags
vivaansinghvi07 913d0ba
update documentation
vivaansinghvi07 dab6bae
added tests for teewrap
vivaansinghvi07 3f0fa08
Update teeplot/teeplot.py
vivaansinghvi07 8838962
Update teeplot/teeplot.py
vivaansinghvi07 5eec37c
inline argument validation
vivaansinghvi07 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
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 |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| """Top-level package for teeplot.""" | ||
|
|
||
| __author__ = """Matthew Andres Moreno""" | ||
| __email__ = 'm.more500@gmail.com' | ||
| __version__ = '1.2.0' | ||
| __email__ = "m.more500@gmail.com" | ||
| __version__ = "1.2.0" |
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
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,96 @@ | ||
| #!/usr/bin/env python | ||
|
|
||
| ''' | ||
| `tee` tests for `teeplot` package. | ||
| ''' | ||
|
|
||
| import functools | ||
| import os | ||
|
|
||
| import numpy as np | ||
| import pytest | ||
| import seaborn as sns | ||
|
|
||
| from teeplot import teeplot as tp | ||
|
|
||
|
|
||
| @tp.teewrap( | ||
| teeplot_outattrs={ | ||
| 'additional' : 'teedmetadata', | ||
| 'for' : 'output-filename', | ||
| '_one-for' : 'exclusion', | ||
| }, | ||
| ) | ||
| @functools.wraps(sns.lineplot) | ||
| def teed_snslineplot_outattrs(*args, **kwargs): | ||
| return sns.lineplot(*args, **kwargs) | ||
|
|
||
| def test(): | ||
|
|
||
| teed_snslineplot_outattrs( | ||
| x='timepoint', | ||
| y='signal', | ||
| hue='region', | ||
| style='event', | ||
| data=sns.load_dataset('fmri'), | ||
| ) | ||
|
|
||
| for ext in '.pdf', '.png': | ||
| assert os.path.exists( | ||
| os.path.join('teeplots', f'additional=teedmetadata+for=output-filename+hue=region+style=event+viz=lineplot+x=timepoint+y=signal+ext={ext}'), | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("format", [".png", ".pdf", ".ps", ".eps", ".svg"]) | ||
| def test_outformat(format): | ||
|
|
||
| # adapted from https://seaborn.pydata.org/generated/seaborn.lineplot.html | ||
| np.random.seed(1) | ||
| x, y = np.random.normal(size=(2, 5000)).cumsum(axis=1) | ||
|
|
||
| @tp.teewrap( | ||
| teeplot_outattrs={ | ||
| 'outformat' : 'teedmetadata', | ||
| }, | ||
| teeplot_subdir='mydirectory', | ||
| teeplot_save={format}, | ||
| ) | ||
| @functools.wraps(sns.lineplot) | ||
| def teed_lineplot_outformat(*args, **kwargs): | ||
| return sns.lineplot(*args, **kwargs) | ||
|
|
||
| teed_lineplot_outformat( | ||
| x=x, | ||
| y=y, | ||
| sort=False, | ||
| lw=1, | ||
| ) | ||
|
|
||
| assert os.path.exists( | ||
| os.path.join('teeplots', 'mydirectory', f'outformat=teedmetadata+viz=lineplot+ext={format}'), | ||
| ) | ||
|
|
||
|
|
||
| @tp.teewrap(teeplot_outinclude=['a', 'b']) | ||
| @functools.wraps(sns.lineplot) | ||
| def teed_snslineplot_extra_args(*args, a, b, **kwargs): | ||
| return sns.lineplot(*args, **kwargs) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize('a', [False, 1, 1]) | ||
| @pytest.mark.parametrize('b', ['asdf', '']) | ||
| def test_included_outattrs(a, b): | ||
|
|
||
| teed_snslineplot_extra_args( | ||
| a=a, | ||
| b=b, | ||
| x='timepoint', | ||
| y='signal', | ||
| hue='region', | ||
| data=sns.load_dataset('fmri'), | ||
| ) | ||
|
|
||
| for ext in '.pdf', '.png': | ||
| assert os.path.exists( | ||
| os.path.join('teeplots', f'a={a}+b={b}+hue=region+viz=lineplot+x=timepoint+y=signal+ext={ext}'), | ||
| ) |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.