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

Support newest matplotlib release #700

Merged
merged 7 commits into from Oct 7, 2014

Conversation

jairideout
Copy link
Contributor

The newest matplotlib release (1.4.0) had its boxplot functionality largely rewritten/refactored. There were a few unintended API/behavior changes that affect the boxplotting functionality in skbio (skbio.draw.boxplots). The most noticeable change is that a ValueError is raised if an empty distribution is provided; in the past, this type of input was supported.

This bug has been fixed in the latest development version of matplotlib (matplotlib/matplotlib#3571). It was first noticed in pandas (pandas-dev/pandas#8382) and they worked around this issue by passing np.array([np.nan]) instead of an empty sequence (pandas-dev/pandas#8240). We use their approach here in order support plotting empty distributions in pre- and post-1.4.0 matplotlib releases. If we decide to only support matplotlib > 1.4.0 at some point in the future, this NaN hack can be removed.

Some of the existing boxplot test code had to be updated to work in either matplotlib version; this was due to changes in the fliers returned by pyplot.boxplot (matplotlib/matplotlib#3544). I also added (very ugly) test code to test that the NaN hack appears to be working; this will hopefully catch changes to matplotlib's boxplot functionality in the future if the hack stops working as intended.

I updated Travis to test against matplotlib < 1.4.0 and whatever the latest release is, in order to make sure that our code works with either version.

Fixes #649.

Empty distributions are plottable in mpl < 1.4.0. In 1.4.0, a ValueError is raised. This has been fixed in mpl 1.4.0-dev (see matplotlib/matplotlib#3571). In order for skbio.draw.boxplots to support empty distributions across mpl versions, empty distributions are replaced with [np.nan]. See pandas-dev/pandas#8382 and pandas-dev/pandas#8240 for details.
Conflicts:
	setup.py
	skbio/draw/_distributions.py
# pre-1.4.0 version and whatever the latest version is.
- PYTHON_VERSION=3.4 NUMPY_VERSION= MATPLOTLIB_VERSION=
- PYTHON_VERSION=2.7 NUMPY_VERSION= MATPLOTLIB_VERSION= WITH_DOCTEST=True USE_CYTHON=TRUE
- PYTHON_VERSION=2.7 NUMPY_VERSION='=1.7' MATPLOTLIB_VERSION='=1.3.1' WITH_DOCTEST=True
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be more consistent and cleaner to set FOO_VERSION=x.y and keep the = in the conda create command.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, didn't think that'd work for the case where we don't want to specify a version (i.e., to test against the latest version). Will update, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't work (see https://travis-ci.org/biocore/scikit-bio/jobs/37241602). Reverting back to what I had before.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, sorry! My bad, didn't realize how you were getting the latest version instead of hardcoding it. Cool!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No worries, I wish there was a better way to accomplish this 😞

@gregcaporaso
Copy link
Contributor

This looks good, thanks @jairideout!

gregcaporaso added a commit that referenced this pull request Oct 7, 2014
Support newest matplotlib release
@gregcaporaso gregcaporaso merged commit c5546eb into scikit-bio:master Oct 7, 2014
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.

skbio.draw.boxplots tests fail with matplotlib 1.4.0
3 participants