-
Notifications
You must be signed in to change notification settings - Fork 358
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
Add some examples for plot implementations in their docstrings #847
Conversation
Codecov Report
@@ Coverage Diff @@
## master #847 +/- ##
==========================================
+ Coverage 94.27% 94.28% +<.01%
==========================================
Files 34 34
Lines 6150 6154 +4
==========================================
+ Hits 5798 5802 +4
Misses 352 352
Continue to review full report at Codecov.
|
databricks/koalas/plot.py
Outdated
:context: close-figs | ||
|
||
>>> s = ks.Series([1, 3, 2]) | ||
>>> ax = s.plot.line() # doctest: +SKIP |
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.
Why should we skip?
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.
@HyukjinKwon This doctest continuously failed on my local test bed like below:
But it actually works well without exception:
so i wanna discussion with others members.
could you test this on your local if when available or have some insight of above failure?
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.
I just undo this skip and pushed again for travis build check. (maybe it will pass on travis server..?)
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.
Failed again. 😢 Do you have any guesswork ??
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.
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.
Anyway, it works! Thanks ! 😸
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.
close-figs
doesn't seem to close figures.
995
996 Examples
997 --------
998 Basic plot.
999
1000 .. plot::
1001 :context: close-figs
1002
1003 >>> import matplotlib.pyplot as plt
1004 >>> plt.get_fignums()
Expected nothing
Got:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]
/Users/harutaka/Desktop/projects/koalas/databricks/koalas/plot.py:1004: DocTestFailure
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.
@charlesdong1991 yeah i totally agree with it. I think i should be find better solution for solve this issue to keep consistency & readable of docs.
@harupy you're right. i think maybe close-figs doesn't work properly either. im going to figure out why this happened 😭
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.
Does close-figs
has any effect when running tests?
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.
@harupy Oops.. sorry i missed your reply
Anyway, yes it seems have any effect, because they are showing same result when i remove all close-figs
options.
This is nice. Thanks for working on this @itholic |
@HyukjinKwon my pleasure. |
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.
Can we also add for Series.plot.barh
and Series.plot.pie
?
databricks/koalas/plot.py
Outdated
:context: close-figs | ||
|
||
>>> import matplotlib.pyplot as plt | ||
>>> plt.close('all') |
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.
Do we still need this?
Seems like others don't have this, otherwise we need to add for the others?
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.
@ueshin at above discussions, maybe there is an issue that :context: close-figs
doesn't work properly. so now it wouldn't work if we remove the line plt.close('all')
to explicitly close all plots. i'm going to figure out how can we solve this problem.
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.
@itholic
I think :context: close-figs
is just for Sphinx, and does nothing when pytest runs tests.
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.
So when running tests, all the plots are drawn onto the same ax
and get messed up.
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.
@harupy Thanks for comment!! It really makes sense. Then i think maybe we need to skip these all examples on pytest, and added them separate unittest (actually most of them already tested in unittest suite though)
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.
but I'm not sure if this is right because plt.close("all")
is also called on tests which are not related to plots.
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.
ah? sorry i can't get it perfectly 😢 maybe could you let me know where they are using for tests not related to plots?
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.
plt.close
is called on test functions where we don't need to call plt.close
.
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.
got it :)
but maybe i think they are only called when we explicitly write the :context: close-figs
in doctest, ain't they?
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.
I think no
Btw, seems like
Can we ignore those files when running |
@ueshin Thanks for comment! |
@ueshin And I'm going to make them ignore in pycodestyle! Thanks for review :) |
@itholic I mean, when I generated the doc, I couldn't see the plots for
tags for them as well, then we can see the plots? |
@ueshin oh i got it :) yes we can see the plots in generated docs by adding i'm going to add them to |
databricks/koalas/plot.py
Outdated
.. plot:: | ||
:context: close-figs | ||
|
||
>>> df = ks.DataFrame({'mass': [0.330, 4.87, 5.97], | ||
... 'radius': [2439.7, 6051.8, 6378.1]}, | ||
... index=['Mercury', 'Venus', 'Earth']) | ||
>>> plot = df.mass.plot.pie(figsize=(5, 5)) |
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.
nit: indent should be one more level?
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.
Thanks for comment!! fixed it :)
databricks/koalas/plot.py
Outdated
@pytest.fixture(autouse=True) | ||
def close_figs(): | ||
yield | ||
plt.close("all") |
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.
We should move this to conftest.py
?
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.
Thanks again, i moved this to conftest.py
:)
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.
LGTM, pending tests.
oh, I forgot about #847 (comment).
|
@ueshin oops, sorry i'm going to fix them soon |
@ueshin Suddenly, i have some question. Is it right way we ignore these tests rather than fix lint fails on doctest in created docs? maybe is it better let them as is to keep lint consistency in documentation? |
Softagram Impact Report for pull/847 (head commit: eaa981e)⭐ Change Overview
📄 Full report
Impact Report explained. Give feedback on this report to [email protected] |
We should definitely keep lint consistency even in documentations. |
@ueshin ah, i just tried, understood why we should ignore them. thanks for explanation! 👍 |
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.
I'd merge this for now.
@itholic Please submit another PR to fix lint-python
for the generated codes, and address the comment below if needed.
Hmm, our official doc doesn't show all the plots. https://koalas.readthedocs.io/en/latest/reference/series.html#plotting |
|
@itholic can you take a look and make a fix? |
@ueshin @HyukjinKwon , okay i'm going to take a look at it and summit another PR for fix them. |
Related with #847 (review) , Fixed flake8 to ignore "docs/build/html/reference/api/*.py" in my local test, it works well, and all plots visible in documentation like below: <img width="927" alt="스크린샷 2019-10-03 오후 2 19 36" src="https://user-images.githubusercontent.com/44108233/66101387-a0d58800-e5e9-11e9-813d-fc48ce117327.png">
Related with databricks/koalas#847 (review) , Fixed flake8 to ignore "docs/build/html/reference/api/*.py" in my local test, it works well, and all plots visible in documentation like below: <img width="927" alt="스크린샷 2019-10-03 오후 2 19 36" src="https://user-images.githubusercontent.com/44108233/66101387-a0d58800-e5e9-11e9-813d-fc48ce117327.png">
Basically we finished the rough implementation of all plots (except 2 in DataFrame).
So it should be better to have some examples for them.