Skip to content

Conversation

bluevisor
Copy link

@bluevisor bluevisor commented Nov 10, 2024

Summary

This PR resolves a deprecation warning in euler.py that occurs when running ti example 6. The warning appears as follows:
MatplotlibDeprecationWarning: The get_cmap function was deprecated in Matplotlib 3.7 and will be removed in 3.11. Use matplotlib.colormaps[name] or matplotlib.colormaps.get_cmap() or pyplot.get_cmap() instead.

Changes Made

  • Updated import statement:
from matplotlib import cm

to

from matplotlib import colormaps
  • Replaced:
cmap = cm.get_cmap(cmap_name)

with

cmap = colormaps[cmap_name]

Rationale

This change uses the updated API for accessing colormaps in Matplotlib, ensuring compatibility with Matplotlib 3.7+ and removing the deprecation warning.

Testing

  • Verified that the warning is resolved when running ti example 6 with the updated code.
  • Confirmed that the colormap functionality remains the same post-update.

taichi/examples/simulation/euler.py:436: MatplotlibDeprecationWarning: The get_cmap function was deprecated in Matplotlib 3.7 and will be removed in 3.11. Use ``matplotlib.colormaps[name]`` or ``matplotlib.colormaps.get_cmap()`` or ``pyplot.get_cmap()`` instead.
  cmap = cm.get_cmap(cmap_name)
@CLAassistant
Copy link

CLAassistant commented Nov 10, 2024

CLA assistant check
All committers have signed the CLA.

@bluevisor bluevisor changed the title Update euler.py for deprecated get_cmap function in Matplotlib Fix MatplotlibDeprecationWarning in euler.py by updating colormap access method Nov 10, 2024
@bluevisor bluevisor changed the title Fix MatplotlibDeprecationWarning in euler.py by updating colormap access method Update colormap access in euler.py to prevent MatplotlibDeprecationWarning Nov 10, 2024
@bluevisor bluevisor changed the title Update colormap access in euler.py to prevent MatplotlibDeprecationWarning [Fix] Update colormap access in euler.py to prevent MatplotlibDeprecationWarning Nov 10, 2024
@bluevisor bluevisor changed the title [Fix] Update colormap access in euler.py to prevent MatplotlibDeprecationWarning [misc] Update colormap access in euler.py to prevent MatplotlibDeprecationWarning Nov 10, 2024
@bluevisor bluevisor changed the title [misc] Update colormap access in euler.py to prevent MatplotlibDeprecationWarning [Example] Update colormap access in euler.py to prevent MatplotlibDeprecationWarning Nov 10, 2024
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.

2 participants