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

Incorrectly show error Module 'matplotlib.cm' has no 'coolwarm' member #2289

Closed
Liampor opened this issue Jul 15, 2018 · 1 comment
Closed

Comments

@Liampor
Copy link

Liampor commented Jul 15, 2018

Steps to reproduce

run code, which include cm.coolwarm
For example

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import cm

fig = plt.figure()
ax = fig.gca(projection='3d')
X, Y, Z = axes3d.get_test_data(0.05)
ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3)
cset = ax.contour(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm)
cset = ax.contour(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm)
cset = ax.contour(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm)

ax.set_xlabel('X')
ax.set_xlim(-40, 40)
ax.set_ylabel('Y')
ax.set_ylim(-40, 40)
ax.set_zlabel('Z')
ax.set_zlim(-100, 100)

plt.show()

Current behavior

show error E1101:Module 'matplotlib.cm' has no 'coolwarm' member

Expected behavior

do not show the error E1101:Module 'matplotlib.cm' has no 'coolwarm' member

pylint --version output

pylint 1.8.2

@PCManticore
Copy link
Contributor

The member does not exist because matplotlib.cm does the following to adds its attributes:

# Precache the cmaps with ``lutsize = LUTSIZE``.
# Also add the reversed ones added in the section above:
for cmapname in datad:
    cmap_d[cmapname] = _generate_cmap(cmapname, LUTSIZE)

cmap_d.update(cmaps_listed)

locals().update(cmap_d)

This is not something that pylint supports out of the box, and usually we require an astroid brain plugin in order to patch these values for the offending module.
There's also another choice, which is to use --generated-members as in pylint ... --generated-members=coolwarm.

zingale added a commit to zingale/pynucastro that referenced this issue Mar 4, 2023
get around this issues by specifying --generated-members
following the advice here: pylint-dev/pylint#2289
zingale added a commit to pynucastro/pynucastro that referenced this issue Mar 7, 2023
get around this issues by specifying --generated-members
following the advice here: pylint-dev/pylint#2289
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants