Conversation
- Replace cm.get_cmap with plt.get_cmap for matplotlib 3.9 compatibility - Read version via regex in setup.py to fix installation bug, add pyproject.toml - Rename Vector directory to vector to fix import error in method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
(1)在 matplotlib >= 3.9 环境下,调用
meb.def_cmap_clevs(...)(内部调用cm.get_cmap)会报错AttributeError: module 'matplotlib.cm' has no attribute 'get_cmap',因为matplotlib.cm.get_cmap在 matplotlib 3.9 中已被移除,涉及 4 个文件共 19 处;(2)另外
pip install -e .会失败:setup.py 第 11 行version = __import__(name).__version__在构建时导入 meteva 包本身,触发meteva/__init__.py→from . import method→from . import vector的循环导入;(3)排查中还发现目录大小写问题,method下目录名
Vector与代码from . import vector不一致会报错。修改内容
(1)4 个文件共 19 处
cm.get_cmap替换为plt.get_cmap(matplotlib >= 3.0 均可用,兼容旧版本);(2)setup.py 改用正则从
meteva/__init__.py读取__version__,避免构建时导入包本身,添加pyproject.toml声明构建系统;(3)method下文件夹Vector改为vector。
测试
matplotlib 3.9 环境下原先报错的绘图流程运行正常;
pip install -e .可正常完成。