X Tutup
Skip to content

colorbar _ticker +_locate bug #6109

@DeadParrot

Description

@DeadParrot

The addition of this code block to ColorbarBase._ticker in matplotlib 1.5.x:

        if isinstance(locator, ticker.LogLocator):
            eps = 1e-10
            b = b[(b <= intv[1] * (1 + eps)) & (b >= intv[0] * (1 - eps))]
        else:
            eps = (intv[1] - intv[0]) * 1e-10
            b = b[(b <= intv[1] + eps) & (b >= intv[0] - eps)]

can cause a numpy array scalar to be passed to ColorbarBase._locate but when that happens the np.searchsorted call in _locate returns an numpy.int64 scalar, which causes the indexing operations:

        i0[itop] -= 1
        ii[itop] -= 1
        i0[ibot] += 1
        ii[ibot] += 1

to generate the exception: 'numpy.int64' object does not support item assignment.

My quick and dirty patch for this was to add this line before the np.searchsorted call in _locate:

        if np.ndim(xn) == 0: xn = np.array([xn[()]])

I don't propose this as a formal patch since it may not be the most efficient fix and this issue may be broader than what I am seeing.

Specs:

  • Windows 10 64-bit
  • Python 2.7.11 64-bit (python.org installer)
  • matplotlib 1.5.1 (pip install)
  • Regression: OK in 1.4.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup