Matplotlib deprecation warning

未關閉 適合新手
#122 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

@KCollins 已經在處理了。

開始於 2026年11月1日。

  • #123 來自 @KCollins —— 未關閉

評估

難度
1/5
預估耗時
1 小時以內
新手友好度
88/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
matplotlib, python

研究方向

過時的呼叫位於 cmocean/cm.py 中,那裡以 N 參數實例化了 colors.ListedColormap。要重現問題,請執行 issue 中的程式片段,並觀察匯入時出現的 MatplotlibDeprecationWarning。當從這些實例化中移除 N 參數,且匯入 cmocean 時不再發出任何棄用警告,即為完成。

由索引模型根據 Issue 內容生成。

描述

Error description

Importing cmocean gives a Matplotlib deprecation warning. MWE to reproduce the issue:

import warnings
import matplotlib
# Import the specific warning class from matplotlib
from matplotlib import MatplotlibDeprecationWarning

print(f"Testing environment with Matplotlib version: {matplotlib.__version__}")

# Force this specific warning to always print for testing purposes
warnings.simplefilter('always', MatplotlibDeprecationWarning)

try:
    # This import triggers the internal loop in cmocean/cm.py
    import cmocean
    print("cmocean imported successfully (check above for warnings).")
except MatplotlibDeprecationWarning as e:
    print(f"Caught the expected warning as an error: {e}")

Proposed fix

The N parameter can be omitted from the colors.ListedColormap instantiations inside cmocean/cm.py, as the passed color arrays (rgb_with_alpha and its reversed slice) are already scaled to the proper lengths (rgb.shape[0] and rgb_i.shape[0]).

主要語言
Python
星號
272
分支
54
PR 合併指標
30 天內沒有已合併 PR

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

matplotlib/cmocean 的其他 Issue

查看 matplotlib/cmocean 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。