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
sphinxext/plot_directive does not accept a caption #4702
Conversation
I can't think of a good reason I had for that check. I'm perfectly fine with it being removed. |
Does anybody have advice how I make the test (that I added) work? Alternatively, I can just remove the tests again. It did not have tests before, so we would not be worse off. But if there is a way to make the tests work, then I would obviously prefer that. |
@mdboom If you have any advise how I can debug why my tests fail please let me know. |
|
||
def range6(): | ||
plt.figure() | ||
plt.plot(range(6)) |
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 you mean 4 here, not 6
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.
or not have this function at 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.
nevermind, I see the point of this now
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.
The point is that plot 16 executes a specific function in a file. To make sure that works there needs to be some other stuff in the file that is not executed.
However, I might have to protect line 3-5 in some way to make sure they don't get executed on import. Maybe I can just make a function like this
def nevercalled():
raise NotImplementedError
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.
That makes sense
I don't have time to run this branch at the moment, but looking at the test error:
it makes me wonder if the plot directive just simply didn't work (or run?). |
I suspect that the file name is different, but I cannot tell without running this locally, which I cannot do since I apparently failed to install all the dependencies need to compile matplotlib from scratch. |
I'll give it a try later today. |
Can anybody who knows how to compile matplotlib from source please try this and see why the tests fail? |
@hamogu You should learn to compile mpl! It is very hard to develop if you can not actually test your code. |
@tacswell on windows it is really hard :( |
I appreciate your advice about learning to compile mpl in order to contribute to the development. I promise that I devoted and entire afternoon to set up the dependencies and I still failed. Please let me explain why I decided to stop at that point; maybe I can convince you that I'm not just trying to be difficult. @tacaswell : I'm not planning on contributing to mpl regularly. I am a regular contributor to astropy and I have some other astronomy projects in python and C (some of which I'm even paid for). My background is in astronomy and I'd rather concentrate on a few projects, where I can have an impact, instead spending my time to learn each and every build system out there (additionally, my wife just had a baby). @Tillsten : I'm on linux (CentOS) or Mac OS,, which should work in principle, but CentOS generally is not very up-to-date in terms of packages in the repositories and as an added complication, I don't have full root access to that machine. Thus, I use mpl through a binary installer (ananconda). Thus, for projects that I'm not familiar with, I'll generally only contribute trivial PRs (and the code change here is trivial and may have been accepted long ago, if I had not tried to also add the tests that complicate the matter). So, unfortunately, that means that this PR will stay unfinished, unless I find somebody to help me out in debugging this branch. |
If you are on linux and using conda, just install mpl into an env, then remove it, and then do the source install into that enviroment (this is how I run my development for the most part). You probably just need a complier from the underlying OS. anaconda packages are compiled on centOS 5 so it is possible. |
The test fails, because Plot 15 in You can:
If you're not interested anymore in this PR I can also open a new one and just add the patch for one of the options above. |
Travis failed with unrelated issues (connection timeout to coveralls).
All passing now! |
+1 from me. Great job! |
sphinxext/plot_directive does not accept a caption
According to the docstring I should be able to do
However, when I try this I get:
The code to generate the caption is there, but because of this line
https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/sphinxext/plot_directive.py#L655
it is impossible to get there.
@mdboom: I'm sure you had a good reason to put this check there when you wrote it, thus I'll leave this as an issue and don't just submit a PR to remove this check.
(Also, I don't know much about how matplotlib runs tests and the code in the doc string should probably be turned into a doctest...)