Skip to content
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

Make "classic" style have effect #5437

Merged
merged 3 commits into from Nov 16, 2015

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Nov 8, 2015

Hopefully fixes failures in #5416

EDIT: I'm adding some background to these changes up here.

We discovered in #5416 that the code to force classic mode on all of the tests by default was broken, because the classic style was being turned on but later the rcParams were all being reset to defaults. So it was a matter of changing the order of operations to

(1) Reset to rcdefaults
(2) Apply the classic style
(3) Additionally apply some settings we've always done for testing such as turning font hinting off

The next step is that in #5214, when the default font was changed from Bitstream Vera to Deja Vu, the classic style was still left at Vera. This means that the classic style was using fonts that we don't ship, which is a problem on Travis, but also could be a problem for users who may not have Vera installed elsewhere on their system. Since these two fonts are identical in looks, and DejaVu only adds additional characters (and some "bugfixes") I think it's still within the definition of "classic mode" to move to the new font.
#5214 also accidentally changed a baseline image to use the new default math font rather than the classic computer modern math font. (Probably just based on the assumption that classic mode testing was working). This has been reverted.

The last thing is really obscure. There is code in mathtext that controls the placement of sub/superscripts based on the current mathtext.fontset rcParam. Each of the fontsets, (cm, stix* and dejavu*) need slightly different offsets for the sub/superscripts and that information is not stored in the font file itself. However, it's actually possible to use DejaVu font when mathtext.fontset is "cm" when the text is inside a \mathdefault{} block (which means use the non-math font for the content inside {}). All that means that when in classic mode, the exponents in the ticks on a log plot were misplaced. The fix is to use the sub/superscript offsets appropriate for the "current font in use within a particular part of the math expression" rather than the global rcParam "mathtext.fontset".

All that hopefully means we properly have classic mode working in all tests and we can proceed with the style changes, but Travis-CI will tell.

@mdboom mdboom added this to the next major release (2.0) milestone Nov 8, 2015
@mdboom mdboom closed this Nov 8, 2015
@tacaswell
Copy link
Member

@mdboom Did this get folded into something else?

@mdboom
Copy link
Member Author

mdboom commented Nov 11, 2015

No -- I was testing it in conjuction with #5416, but I think we can/should still merge this as a separate PR first.

@mdboom
Copy link
Member Author

mdboom commented Nov 11, 2015

It's just the symlog image comparison test that is failing now. Not sure why yet.

@mdboom
Copy link
Member Author

mdboom commented Nov 16, 2015

I think this is ready to go in now. We should probably merge sooner than later to prevent fewer false positive results from creeping in.

# in the STIX fonts, so we have to detect this one separately.
if (constants is STIXFontConstants and
isinstance(state.font_output, StixSansFonts)):
return STIXSansFontConstants
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tab this over one so that it doesn't line up with the code block.

Sorry, made that comment in the commit rather than the PR.

@WeatherGod
Copy link
Member

I haven't personally vetted the conversion from dictionaries to classes, but the unit tests don't fail, so I am guessing that is ok. Besides the one little PEP8 thing, I am +1 (and even that, I don't care too much about). I am a bit curious why the pep8 tests didn't catch that.

@tacaswell
Copy link
Member

Pretty sure that is one of the pep8 errors/warnings we have blacklisted.

@WeatherGod
Copy link
Member

Really? That is actually one of the PEP8 rules that I think makes the most
sense. I get tripped up all the time by seeing clause statements lined up
with code blocks because Python is so whitespace-oriented.

On Mon, Nov 16, 2015 at 10:51 AM, Thomas A Caswell <notifications@github.com

wrote:

Pretty sure that is one of the pep8 errors/warnings we have blacklisted.


Reply to this email directly or view it on GitHub
#5437 (comment)
.

@jenshnielsen
Copy link
Member

👍 It looks like some of the symlog images are changed twice. Would it make sense to squash the commits?

@mdboom
Copy link
Member Author

mdboom commented Nov 16, 2015

Sure, I can squash the commits.

Also, let's hold off -- I think I just discovered another case where this isn't working...

@mdboom
Copy link
Member Author

mdboom commented Nov 16, 2015

Ok -- I've fixed one last thing and now I have my massive style changes branch passing (stay tuned). (The @cleanup decorator wasn't applying the classic style, which soon will affect things like view limits that even non-image-comparison tests care about).

Also addressed @WeatherGod's indentation comment.

Once Travis passes, I'd say this is good to go.

return make_cleanup
else:
result = make_cleanup(style)
style = 'classic'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this backwards?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, nevermind... I got mixed up

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. The idea here is to keep @cleanup without arguments working. If you pass it no arguments, the first argument should be a function and we want to use classic mode by default. If you pass a string it specifies a style, and the function will be passed in later (through function chaining). This is just typical decorator madness, but I can add a comment if you think it would help.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps make a comment here explaining that style in some cases isn't really a style name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a comment.

@WeatherGod
Copy link
Member

one of the Travis errors seems spurious, but the other one seems to be some sort of odd stix font issue that only happens in py3.4? I restarted the spurious one, though.

@mdboom
Copy link
Member Author

mdboom commented Nov 16, 2015

@WeatherGod:

one of the Travis errors seems spurious, but the other one seems to be some sort of odd stix font issue that only happens in py3.4? I restarted the spurious one, though.

Travis looks green now.

# cleanup if called with an argument, it is a string naming a
# style, and the function will be passed as an argument to what we
# return. This is a confusing, but somewhat standard, pattern for
# writing a decorator with optional arguments.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! Very clear and helpful.

WeatherGod added a commit that referenced this pull request Nov 16, 2015
@WeatherGod WeatherGod merged commit 6dd4103 into matplotlib:master Nov 16, 2015
@WeatherGod
Copy link
Member

I presume this gets cherry-picked to v2.0.x branch, or did we want to hold off on that while other stuff is going on?

@mdboom
Copy link
Member Author

mdboom commented Nov 16, 2015

No, it should be on 2.0.x now -- everything else we're doing ends up sort of relying on this. I'll go ahead and do that now.

WeatherGod added a commit that referenced this pull request Nov 16, 2015
@mdboom
Copy link
Member Author

mdboom commented Nov 16, 2015

Backported to 2.0.x as 10e2af5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants