Skip to content

DeprecationWarning from calc_label_rot_and_inline in contour.py - array index is a float #3137

Description

@andrewfowlie

When I use the function clabel, I receive the warning:

/usr/lib/pymodules/python2.7/matplotlib/contour.py:486: DeprecationWarning: using a
non-integer number instead of an integer will result in an error in the future
nlc.append(np.r_[xy2, lc[I[1]:]])

The problem is that the array index I in lc[I[1]:]] is a float not an integer. The current code is

        # Make integer
        I = [np.floor(I[0]), np.ceil(I[1])]

Unfortunately, floor and ceil return floats rather than integers. I suggest converting I to integers, if possible (need to take care, make sure we don't do int(nan))

        # Make integer
        I = [np.floor(I[0]), np.ceil(I[1])]
        I = [ int(i) if not np.isnan(i) else i for i in I ]

or something similar - is there a way to make floor and ceil return integers? If not, maybe this will do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions