Skip to content

Remove numpy 1.6 specific work-arounds  #7484

Closed

Description

@tacaswell

In #7396 / #7483 we bumped the minimum numpy version to 1.7.1. We have a number of workarounds in the code base which should be removed

From master:

09:41 $ ack -i 'numpy.*1\.6' --python
lib/matplotlib/cbook.py
2585:# Numpy > 1.6.x deprecates putmask in favor of the new copyto.

lib/matplotlib/tri/triinterpolate.py
1270:        # - it is new in numpy 1.6

lib/matplotlib/category.py
17:#  pure hack for numpy 1.6 support
83:    """Helper function for numpy 1.6, can be replaced with

lib/matplotlib/tests/test_category.py
160:        # Image test would fail on numpy 1.6

lib/matplotlib/colors.py
179:    # Python 2.7 / numpy 1.6 apparently require this to return builtin floats,

I would prefer is we not backport these for 2.0 (just being excessively conservative).

attn @story645

Activity

  1. added
    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
    on Nov 18, 2016
  2. added this to the milestone on Nov 18, 2016
  3. dstansby commented on Nov 21, 2016

    @dstansby
    Member

    The first 4 of those should be fixed in my pull request. The last two I'm not entirely sure what the comments mean/what needs changing...

  4. story645 commented on Nov 21, 2016

    @story645
    Member
    lib/matplotlib/tests/test_category.py
    160:        # Image test would fail on numpy 1.6
    

    is just that numpy1.6 doesn't support unicode and it's a unicode test. That comment can be removed now. And while editing that file, TestConvertToString should also be removed.

  5. story645 commented on Nov 21, 2016

    @story645
    Member
    lib/matplotlib/colors.py
    179:    # Python 2.7 / numpy 1.6 apparently require this to return builtin floats,
    

    colors is weird 'cause that try catch is just to test if what's passed in is a floating point. I think the idea is that the c is expected to have been a numpy float array, and that's why it's being cast to a builtin float (as in 170). You may be able to remove that statement 'cause in theory other types were already captured, (and also remove the cast in 170)... though you may possibly need to put in a c = np.asarray(c, dtype=float) before 170 (possibly in a try/catch).

  6. anntzer commented on Nov 22, 2016

    @anntzer
    Contributor

    Basically something breaks later (on Py2.7+numpy1.6) if a tuple of numpy floats (rather than builtin floats) is returned. See 2fe2c26.

    In fact I don't think that the version that starts with try: c = np.array(c, float) is much better (in fact, it requires additionally checking for ndim == 1), so perhaps you may just as well remove that comment without doing anything.

    As a side note, either implementation suffers from the fact that the cast to float doesn't error when a string is passed in (as in plt.plot([1, 2], c=(".5", ".5", .5, .5))) but I don't think it's really worth checking that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions