-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Patch issue #6035 #6054
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
Patch issue #6035 #6054
Conversation
@afvincent, this is encouraging. In working through this, have you figured out what "mutation_scale" and "dpi_cor" really are? Can they be explained in the documentation so that a user will be able to understand how to use them? It looks to me like |
0 - TL;DRSomebody corrects me if I am wrong but I would say that:
For people who have time, here are some explanations. 1 - What is dpi_cor?Well So I would say that 2 - What is mutation_scale?Concerning
NB: from reading other method signatures, I would guess that Then
If I understood correctly everything, it is then for example called from inside _path, fillable = self.get_arrowstyle()(_path,
self.get_mutation_scale() * dpi_cor,
self.get_linewidth() * dpi_cor,
self.get_mutation_aspect()
)
# NB: the 2nd line tends to support the idea that mutation_size
# is nothing else than mutation_scale, doesn't it?
Note that no units are precised. And this description is confirmed by this kind of lines in some methods of head_length = self.head_length * mutation_size and one can also read:
So I would say that both head_length and head_width are unitless, while Further, in
So The case of the class Annotation
as in ms = d.pop("mutation_scale", self.get_size())
self.arrow_patch.set_mutation_scale(ms) that pass argument to the ad-hoc 3 - Tentative of conclusion about mutation_scaleSo from what I read and understood, I see Small remark: from my point of view, the fact that in raw |
About the commit 1df0f7e Failures in test_axesI think it solves some of the problems that I didn't expected when patching Failures in test_streamplotAdditionally, I finished to convinced myself that the unit tests Currently the problem is that the two upper panels (@ 100 DPI) are not perfectly identical: the arrow sizes are not the same. It is confirmed by the Failure in test_transformsFrom the |
I do not have time to say anything technically meaningful, but thank you for your detailed work on this! ======================================================================
ERROR: matplotlib.tests.test_artist.test_clipping.test
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/travis/build/matplotlib/matplotlib/venv/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/testing/decorators.py", line 55, in failer
result = f(*args, **kwargs)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/testing/decorators.py", line 249, in do_test
self._tol, in_decorator=True)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/testing/compare.py", line 332, in compare_images
rms = calculate_rms(expectedImage, actualImage)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/testing/compare.py", line 246, in calculate_rms
abs_diff_image = abs(expectedImage - actualImage)
ValueError: operands could not be broadcast together with shapes (540,720,3) (270,360,3) Those failures worry me a bit. I suspect that if you track down the issue with the stream plots, the polar plot issue will go away. The new stream plot does look a bit better to my eyes, it would not take much to convince me that the test images should be updated. |
It is weird, I have no problem with In [3]: run test_artist.py
/home/adrien/matplotlib-git/matplotlib/lib/matplotlib/__init__.py:885:
UserWarning: axes.color_cycle is deprecated and replaced with axes.prop_cycle;
please use the latter. # I still didn't have a look into the new color_cycle thing,
# but that should irrelevant for our concern, shouldn't it?
warnings.warn(self.msg_depr % (key, alt_key))
/home/adrien/matplotlib-git/matplotlib/lib/matplotlib/testing/decorators.py:363:
UserWarning: test module run as script. guessing baseline image locations
warnings.warn('test module run as script. guessing baseline image locations')
.........
----------------------------------------------------------------------
Ran 9 tests in 2.641s
OK |
Travis is running this PR against latest master, not 1.5.1. There have been many changes since then, but the most likely one is a change in the default DPI. |
Just to say that I didn't have time lately to dedicate checking the final details of this PR, but I am still working on it to understand why some unit tests fail, especially the ones that do by only a few pixels. |
About the failures of
|
Thanks for the detailed investigation. I tend to agree with you that this change is not significant and we can just replace the image with the new version. It's really hard to set the tolerance for image comparison tests. We used to have a much higher tolerance but that resulted in a number of issues going unnoticed over the years. |
@afvincent Echoing Jens, thank you for the very detailed work tracking this down! For changes that small please replace the images. |
@@ -4057,7 +4057,7 @@ def __init__(self, posA=None, posB=None, | |||
def set_dpi_cor(self, dpi_cor): | |||
""" | |||
dpi_cor is currently used for linewidth-related things and | |||
shrink factor. Mutation scale is not affected by this. |
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.
just drop the 'not', in the near future no one will remember the old behavior and the 'now'
will just add confusion.
👍 I am sold on this once the tests are updated. |
self.get_linewidth() * dpi_cor, | ||
self.get_mutation_aspect() | ||
) | ||
self.get_mutation_scale() * dpi_cor, |
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 this actually pass pep8?
@tacaswell I did another rebase, skipping the failing 3 last patches (2110e5e, 56f337f and 83fb8d1) about failing PNG baseline test images, and then re-updated these test images on my local repository. Unfortunately,
Homemade translation:
So I guess I managed once more to get git in an unwanted situation… If it matters, just before rebasing, I used
Wouldn't it be easier to create a new branch from the current master, on which I will report the changes of the current patch, and then to open a new PR? PS : I also did |
You need to do git push --force origin patch-issue-6035 To tell git to do something that might lose commits. On Sat, May 14, 2016, 05:41 afvincent notifications@github.com wrote:
|
276aea3
to
c9faebe
Compare
The previous updated PNGs test images seemed to be still failing due to difference in the fonts of the axis labels, so I just re-commited the same images but produced on a computer than seemed to be free of the font issues I have on my personal computer. Apparently the associated failures have disappeared after this last commit. So now only the failures of |
I am a bit lost with the failures of ======================================================================
FAIL: matplotlib.tests.test_artist.test_clipping.test
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/travis/build/matplotlib/matplotlib/venv/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/testing/decorators.py", line 55, in failer
result = f(*args, **kwargs)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/testing/decorators.py", line 255, in do_test
self._tol, in_decorator=True)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/testing/compare.py", line 337, in compare_images
rms = calculate_rms(expectedImage, actualImage)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/testing/compare.py", line 248, in calculate_rms
"actual size {1}".format(expectedImage.shape, actualImage.shape))
ImageComparisonFailure: image sizes do not match expected size: (600, 800, 3) actual size (300, 400, 3)
======================================================================
FAIL: matplotlib.tests.test_artist.test_clipping.test
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/travis/build/matplotlib/matplotlib/venv/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/testing/decorators.py", line 55, in failer
result = f(*args, **kwargs)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/testing/decorators.py", line 255, in do_test
self._tol, in_decorator=True)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/testing/compare.py", line 337, in compare_images
rms = calculate_rms(expectedImage, actualImage)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/testing/compare.py", line 248, in calculate_rms
"actual size {1}".format(expectedImage.shape, actualImage.shape))
ImageComparisonFailure: image sizes do not match expected size: (432, 576, 3) actual size (216, 288, 3)
======================================================================
FAIL: matplotlib.tests.test_artist.test_clipping.test
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/travis/build/matplotlib/matplotlib/venv/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/testing/decorators.py", line 55, in failer
result = f(*args, **kwargs)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/testing/decorators.py", line 255, in do_test
self._tol, in_decorator=True)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/testing/compare.py", line 337, in compare_images
rms = calculate_rms(expectedImage, actualImage)
File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/testing/compare.py", line 248, in calculate_rms
"actual size {1}".format(expectedImage.shape, actualImage.shape))
ImageComparisonFailure: image sizes do not match expected size: (540, 720, 3) actual size (270, 360, 3) Looks like (at least) one of the problems is that the DPI value use when saving the images is half the expected one. QuLogic suggested a while ago it might be related to a change in the default DPI value, but then should'nt there be a lot more of test failures (basically all the image comparison tests)? Furthermore, isn't it a bit strange that even the PNG conversions of the PDF and SVG images are also saved with half the expected resolution? |
On a different topic than the remaining issues with |
If you feel compelled to write a test we will not protest, but a vast majority of mpl_toolkit is not tested and cleaning that up is not a burden we want to put on this PR. It is also not very well documented which means that it's usage is probably pretty low. It also sounds like you have made things better not worse? |
I would say the situation is better now, as the size of the arrow heads of the axes are not dpi-dependent anymore. Before the patch, |
The issue with For reasons unknown Making the method private by renaming it to |
Replaced by #6504. |
Here is a proposition of patch that should fix issue #6035, without breaking
annotate
(at least the relevant unit test seems still OK).As @efiring suggested, I tried not to directly modify the value of the attribute
mutation_scale
(as it is exposed as an argument). Basically, the idea is to scalemutation_scale
accordingly to the DPI correction (dpi_cor
), insideget_path_in_displaycoord
, which is called in thedraw
method of theFancyPatchArrow
class. This way, the head (and tail) size of aFancyPatchArrow
should not depend on the DPI value.Besides, I removed the same kind of scaling operation that was done “externally” in
annotate
(intext.py
), since it is now performed directly insideFancyArrowPatch
. Astest_fancyarrow
still is OK, I would assume nothing has been broken.I also added an
image_comparison
test (well in fact two, one for the PNG export at 100 DPI and another one at 200 DPI). Visually both exported pictures look the same in term of the size of the arrow head. Concerning the code in itself, it seems a bit clunky to me to use two separate test functions only to export with two different DPI values identical figures, but I did not managed to get a workingclass Test_*
… (Nevertheless, the current situation should do the job.)PS: I struggled a bit with git (I “had to” remove one branch from my fork): I hope everything is fine with the commits for the PR.