Bug in contour x/y values filtering in mpl_toolkits/basemap/__init__.py ?
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- numpy, python
調査の方向性
mpl_toolkits/basemap/init.py の contour(self, x, y, data, ...) のフィルタリングロジックから始め、入力を matplotlib.tri triangulation traceback と比較します。提案されている座標境界によるフィルタリングを確認し、利用可能であれば既存の contour または contourf テストを実行します。完了の条件は、contour が報告された非構造化データを、空の座標配列を triangulation に渡すことなく処理できることです。
索引モデルが issue の本文から書いたものです。
説明
I have been trying to plot unstructured data with contour and contourf, using the tri=True parameter. It works fine with contourf, but I get a huge traceback when using contour on the same data.
[...]
File "/home/share/unix_files/cdat/versions/cdat_install_uv-2.1.0_x86_64_gcc4_13/lib/python2.7/site-packages/matplotlib-1.4.0-py2.7-linux-x86_64.egg/matplotlib/tri/triangulation.py", line 55, in __init__
self.triangles, self._neighbors = _qhull.delaunay(x, y)
ValueError: x and y arrays must have a length of at least 3
After spending some time in the python debugger, I have found out that indeed the x and y coordinate arrays passed to the triangulation function had a zero size (and therefore less than 3 elements) because they were empty! More digging helped me find a very suspicious way of filtering the x and y values in the contour(self,x,y,data,args,*kwargs) function
# for unstructured grids, toss out points outside
# projection limb (don't use those points in triangulation).
[...]
mask = np.logical_or(x<self.xmin,y<self.xmin) +\
np.logical_or(x>self.xmax,y>self.xmax)
x = np.compress(mask,x)
y = np.compress(mask,y)
Why would y be compared to the values of xmin and xmax instead of ymin and ymax, and is the logical combination ok???
I think we want to keep the values where: xmin<=x<=xmax AND ymin<=y<=ymax. And the mask has to be True where we want to keep the value, in np.compress! This is a bit misleading because it works in the opposite way that masks work in np.ma ...
The contour function works fine if I replace the mask definition above with
mask = np.logical_and(np.logical_and(x>=self.xmin, x<=self.xmax),
np.logical_and(y>=self.ymin, y<=self.ymax))
Can somebody review this? And it may be wise to use a slightly less misleading name for the mask variable. Maybe replace mask with select_xy_ok?
- 主要言語
- Python
- スター
- 817
- フォーク
- 395
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
matplotlib/basemap のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
matplotlib/basemap#368 ·
-
Python 3.14 wheels オープン
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
matplotlib/basemap#652 · コメント 2 件 · リアクション 5 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
matplotlib/basemap#649 · リアクション 2 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
matplotlib/basemap#646 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 48/100
matplotlib/basemap#645 · コメント 2 件 ·
matplotlib/basemap の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
syfoud/Simulated_Scepter#172 ·
-
A cancelled tests run makes the coverage comment workflow fail and reports it as a red check on main オープンarea: ci bug perceived difficulty: 3
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Nitjsefnie-Harness-Commons/daedalus#921 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
EleutherAI/lm-evaluation-harness#4207 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ClickHouse/clickhouse-connect#1057 ·