8000 check freetype version also specifies what is wrong by prhbrt · Pull Request #6403 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

check freetype version also specifies what is wrong #6403

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

Closed
wants to merge 10 commits into from
Next Next commit
Added an {figure,.pyplot}.encode_as feature to encode a figure as a b…
…ytestring (not writing it to file), which can be practical in combination with the base64-package. Also addded a {figure,pyplot}.subplots_iterator which returns an iterator over subplots, which can be practical in for example ipynb's, where one wants to make many graphs and likes them to be 3 (or 5 or whatever) on a line.
  • Loading branch information
Herbert Kruitbosch committed May 11, 2016
commit 5a3a8827b685c49853f4bedb9484d8ef4fae9c98
8 changes: 7 additions & 1 deletion lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1513,6 +1513,7 @@ def _jupyter_nbextension_paths():
'matplotlib.tests.test_streamplot',
'matplotlib.tests.test_style',
'matplotlib.tests.test_subplots',
'matplotlib.tests.test_subplots_iterator',
'matplotlib.tests.test_table',
'matplotlib.tests.test_text',
'matplotlib.tests.test_texmanager',
Expand Down Expand Up @@ -1553,7 +1554,12 @@ def _init_tests():
warnings.warn(
"matplotlib is not built with the correct FreeType version to run "
"tests. Set local_freetype=True in setup.cfg and rebuild. "
"Expect many image comparison failures below.")
"Expect many image comparison failures below. "
"Expected {0} != found {1}".format(
Copy link
Member

Choose a reason for hiding this comment

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

should these be in the other order? We expected LOCAL_FREETYPE_VERSION but did not find it.

ft2font.__freetype_version__,
LOCAL_FREETYPE_VERSION
Copy link
Member

Choose a reason for hiding this comment

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

This message might be a little misleading, I would think, because this isn't the full condition that needs to be satisfied. @mdboom, I will defer to you on this.

Copy link
Author

Choose a reason for hiding this comment

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

Although you are right, I've actually set local_freetype=True in setup.cfg, then ran setup.py clean and setup.py install, afterwards this error message still occurred.

It makes me wonder if ft2font.__freetype_build_type__ == 'local' can actually happen.

Copy link
Member

Choose a reason for hiding this comment

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

It does work Travis uses it all the time Please check the Travis logs for instance here

https://travis-ci.org/matplotlib/matplotlib/jobs/129092969

Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if setup.py clean is sufficient to remove everything that needs to be, I tend to use git clean -xfd to reset things 😉.

There is also the MPLLOCALFREETYPE env which if it is set to anything true will use the local freetype (this is what I do).

Copy link
Author

Choose a reason for hiding this comment

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

@tacaswell You might be right. What also seemed to have worked is removing the ubuntu, the virtualenv, and re-executing setup.py install :)

)
)

try:
import nose
Expand Down
38 changes: 37 additions & 1 deletion lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
TransformedBbox)
from matplotlib.backend_bases import NonGuiException

import io

docstring.interpd.update(projection_names=get_projection_names())


Expand Down Expand Up @@ -1082,7 +1084,7 @@ def subplots(self, nrows=1, ncols=1, sharex=False, sharey=False,
--------
pyplot.subplots : pyplot API; docstring includes examples.
"""

# for backwards compatibility
if isinstance(sharex, bool):
sharex = "all" if sharex else "none"
Expand Down Expand Up @@ -1144,6 +1146,29 @@ def subplots(self, nrows=1, ncols=1, sharex=False, sharey=False,
# Returned axis array will be always 2-d, even if nrows=ncols=1.
return axarr


def subplots_iterator(self, nrows=1, ncols=1, show_in_between=False,
sharex=False, sharey=False, squeeze=True,
subplot_kw=None, gridspec_kw=None):
""" Iteratively yields the axis object of a rows x cols subplot and creates new subplots when needed"""
while True:
axes = self.subplots(
nrows=nrows,
ncols=ncols,
sharex=sharex,
sharey=sharey,
squeeze=False,
subplot_kw=subplot_kw,
gridspec_kw=gridspec_kw
)
assert axes.shape == (nrows, ncols), "Matplotlib panic: the returned shape of subplots() is not what was expected: {0} != {1}".format(axes.shape, (nrows, ncols))
for row in range(nrows):
for col in range(ncols):
yield axes[row, col]
if show_in_between:
self.show(block=False)


def __remove_ax(self, ax):
def _reset_loc_form(axis):
axis.set_major_formatter(axis.get_major_formatter())
Expand Down Expand Up @@ -1673,6 +1698,17 @@ def savefig(self, *args, **kwargs):
ax.patch.set_facecolor(cc[0])
ax.patch.set_edgecolor(cc[1])

def encode_as(self, **kwargs):
""" Equivalent of savefig, but does not store to a file, but returns a bytestring
using io.BytesIO. All kwargs are passed to savefig."""
assert 'format' in kwargs, "Make sure to specify the format"
assert 'fname' not in kwargs, "Do not provide a filename, this method returns a bytestring and does not write to a file"

in_memory_file = io.BytesIO()
self.savefig(in_memory_file, **kwargs)
in_memory_file.seek(0)
return in_memory_file.getvalue()

@docstring.dedent_interpd
def colorbar(self, mappable, cax=None, ax=None, use_gridspec=True, **kw):
"""
Expand Down
30 changes: 30 additions & 0 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from matplotlib.externals import six

import sys
import io
import warnings
import types

Expand Down Expand Up @@ -688,6 +689,18 @@ def savefig(*args, **kwargs):
return res



def encode_as(**kwargs):
""" Equivalent of savefig, but does not store to a file, but returns a bytestring
using io.BytesIO. All kwargs are passed to savefig."""
assert 'format' in kwargs, "Make sure to specify the format"
assert 'fname' not in kwargs, "Do not provide a filename, this function returns a bytestring and does not write to a file"

in_memory_file = io.BytesIO()
savefig(in_memory_file, **kwargs)
in_memory_file.seek(0)
return in_memory_file.getvalue()

@docstring.copy_dedent(Figure.ginput)
def ginput(*args, **kwargs):
"""
Expand Down Expand Up @@ -1146,6 +1159,23 @@ def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
gridspec_kw=gridspec_kw)
return fig, axs

def subplots_iterator(nrows=1, ncols=1, show_in_between=False, sharex=False,
sharey=False, squeeze=True, subplot_kw=None,
gridspec_kw=None, **fig_kw):
""" Iteratively yields the axis object of a rows x cols subplot and creates new subplots when needed"""
for axis in (
figure(**fig_kw).subplots_iterator(
nrows=nrows,
ncols=ncols,
sharex=sharex,
sharey=sharey,
squeeze=squeeze,
subplot_kw=subplot_kw,
gridspec_kw=gridspec_kw
)
):
yield axis


def subplot2grid(shape, loc, rowspan=1, colspan=1, fig=None, **kwargs):
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/testing/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def test(self):
shutil.copyfile(orig_expected_fname, expected_fname)
else:
will_fail = True
fail_msg = 'Do not have baseline image %s' % expected_fname
fail_msg = 'Do not have baseline image {0} because this file does not exist: {1}'.format(expected_fname, orig_expected_fname)

@knownfailureif(
will_fail, fail_msg,
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

_multiprocess_can_split_ = True

import pyparsing;

# Check that the test directories exist
if not os.path.exists(os.path.join(
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
0