| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Which error do you mean? Can you add a test as well? |
Sorry, something went wrong.
|
Hi @JunTan, Please add a meaningful description of the patch you propose and a link to the ticket. |
Sorry, something went wrong.
|
I just pushed a simple test for that. On Sun, Oct 23, 2016 at 5:51 PM, Elliott Sales de Andrade <
|
Sorry, something went wrong.
| # webagg unconditiionally. | ||
| if (self.canvas is not None and | ||
| 'WebAgg' in self.canvas.__class__.__name__): | ||
| 'WebAgg' in self.canvas.__class__.__name__): |
There was a problem hiding this comment.
This should probably match the exact class name instead.
Sorry, something went wrong.
There was a problem hiding this comment.
This is a pep8 modification, so no need to hold this PR on that
Sorry, something went wrong.
There was a problem hiding this comment.
No, my point was "this should be something like self.canvas.__class__.__name__ == "<something>"" (or self.canvas.__class__.__module__ == "<something>") rather than a substring check.
Sorry, something went wrong.
There was a problem hiding this comment.
Actually the whole condition should just get rewritten as if type(self.canvas).__name__ == "FigureCanvasWebAgg": ...
Sorry, something went wrong.
|
Hi @JunTan |
Sorry, something went wrong.
|
@NelleV what is PR? I figure out there is a blank line contains whitespace in figure.py |
Sorry, something went wrong.
|
PR is short for "Pull Request". Sorry, we tend to get used to our jargon. On Wed, Nov 2, 2016 at 2:30 PM, JunTan notifications@github.com wrote:
|
Sorry, something went wrong.
| @cleanup | ||
| def test_stack_remove(): | ||
| ''' | ||
| Before fixing the bug, doing the following will give you following error: |
There was a problem hiding this comment.
This docstring is not very useful. The reason is that nose uses the first line as the name of the test. So the test gets called "Before fixing the bug, doing the following will give you following error:" which is just wrong.
Anyway, I don't think this docstring provides any useful information, because it is clear from the name and the test code itself what it is. I think you can just drop the docstring entirely.
Sorry, something went wrong.
There was a problem hiding this comment.
sure, I added the docstring because I got people asking me what is the test for.
Sorry, something went wrong.
| a = figure.AxesStack() | ||
| a.add(key, plt.figure().add_subplot(111)) | ||
| assert_raises(KeyError, a.add, key, plt.figure().add_subplot(111)) | ||
| # Verify some things |
There was a problem hiding this comment.
Is something supposed to come after this?
Sorry, something went wrong.
There was a problem hiding this comment.
no, sorry , it should come before the assertion.
Sorry, something went wrong.
… or modify the old one
|
If this is complete (which it seems to be), please remove the [WIP] from the title. |
Sorry, something went wrong.
| except TypeError: | ||
| raise ValueError("first argument, %s, is not a valid key" % key) | ||
|
|
||
| a_existing = self.get(key) |
There was a problem hiding this comment.
Why does reaching into the internals and casting it to a dict fixes this bug?
Sorry, something went wrong.
There was a problem hiding this comment.
the casting is there because there was a stack.remove() takes in the casting value as an argument not the one return from self.get(key). Now the stack.remove() is removed because the old key-value pair should not be removed or changed if the key is added again.
Sorry, something went wrong.
There was a problem hiding this comment.
I do not follow 😞
Sorry, something went wrong.
There was a problem hiding this comment.
refer to this JunTan@db343c3#diff-c3ce78ddcc28c54e04ade080c149c1b1R130
There was a stack.remove() attempts to remove the key-value pair if the key is added to the stack again. stack.remove() takes in (key, (self.ind, axes)) as its parameter.Before casting, stack.remove() takes in (key, , axes). Thus the casting fixes this problem.
Then we decide to remove stack.remove() because the old key-value pair should not be removed or changed if the key is added again. Now it just raises error if you try to add an old key again.
Thus the casting fixes the bug of the call to stack.remove().
Sorry, something went wrong.
There was a problem hiding this comment.
I now see that the underlying self.get() also casts self._elements through a dict. It turns out I am deeply confused about this class (and it's super class) works.
Sorry, something went wrong.
|
Won't this just swap the error that the OP raised from remove failing to this error? It looks like changing the remove to self.remove(a_existing) would have been the minimal change? |
Sorry, something went wrong.
|
Hi @tacaswell Note that if a user is using the AxesStack class on it's own, to obtain the "old" behavior (that did not work), the user could explicitly remove the axes from the stack manually using the remove method. I think it is much more pythonic being explicit about this rather than the initial intended behavior. |
Sorry, something went wrong.
|
Looking at the history this code it looks like @efiring wrote this in 2010 and this functionality worked for 3 days ;) This patch does not actually fix the bug that the OP reported, but changes the API to raise a different exception. I still think it is better to just fix the intended behavior (if it should have beet public or not, it is), but if you want to change the API (which is low impact due to their being a bug) then this needs to be documented in API changes (and probably documented in the docstring). It is not clear to me that the intended behavior is 'non-pythonic', it seems equivalent to __setitem__ being able to replace a value. |
Sorry, something went wrong.
|
If we are going to accept #7377 or some variation on it, then I think it makes sense to leave things alone for now rather than merge this, with or without modifications. |
Sorry, something went wrong.
|
Looking again at #7377, I see that it is not OK as-is, but I look favorably on the proposal to deprecate and remove the behavior in which add_axes returns an existing one instead of a new one. |
Sorry, something went wrong.
|
Hi @JunTan |
Sorry, something went wrong.
|
|
||
| matplotlib 2.0 supports Python 2.7, and 3.4+ | ||
|
|
||
| The behavior of AxesStack re-add key changes |
There was a problem hiding this comment.
I'm not sure AxesStack is what should be documented here; it's an internal (if not private) implementation detail and what the user really sees is that Figure.add_axes (and plt.axes?) no longer has this behaviour. "What's new" should be about user-visible changes. This specific information could probably go in api/api_changes.
Sorry, something went wrong.
There was a problem hiding this comment.
Agreed that this should be moved to the api_changes and cleaned up (see @QuLogic's comment below).
Sorry, something went wrong.
| If the user really wants to re-add the same key, then the old one should | ||
| be removed first by using :func:`AxesStack.remove` and re-add the new key. | ||
|
|
||
| :func:`~figure.AxesStack.add` |
There was a problem hiding this comment.
This seems to be leftover from something.
Sorry, something went wrong.
|
@anntzer Can you check this PR? It'd be nice to have this in 2.0. @QuLogic We document AxesStack because this "bug" was detected by someone who was explicitely using this function. It is in our public API, thus is public. If it wasn't, this bug would never have been detected as the case described here never happens when AxesStack is used internally. |
Sorry, something went wrong.
|
I'm not saying not to document it; I'm saying it should be in the API's What's New section. What should be in the main What's New section is something about Figure.add_axes (or plt.axes), because that is what gets used by most users. |
Sorry, something went wrong.
| # Check if sharing a subplots axis | ||
| if (ax._sharex is not None and | ||
| isinstance(ax._sharex, SubplotBase)): | ||
| isinstance(ax._sharex, SubplotBase)): |
There was a problem hiding this comment.
Just make this if isinstance(ax._sharex, SubplotBase): (the first check is not needed).
Sorry, something went wrong.
| key = '123' | ||
| axes = plt.figure().add_subplot(111) | ||
| a.add(key, axes) | ||
| # Verify some things |
There was a problem hiding this comment.
Should the comment be more specific?
Sorry, something went wrong.
|
Closing as we're just going (in the long run) to deprecate AxesStack (or rather, make it private). See #9037 and linked issues. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Before fixing the bug, doing the following will give you error:
#7194
Now the warning should be more clear and should not raise any error