Should LinearColormap.to_step(n=1) create a one-step colormap?
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 58/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- python
調査の方向性
branca/colormap.py の LinearColormap.to_step 周辺から始め、n=1 のときに n - 1.0 の計算でエラーが発生することを確認し、issue の失敗を再現してください。既存の API と周辺のテストから、単一ステップで意図されている動作を判断してください。選択した動作が実装され、明確に仕様化され、回帰テストでカバーされていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
LinearColormap(...).to_step(n=1) raises a ZeroDivisionError.
In map/choropleth workflows, after filtering or classification, there may be only one bucket/class to display, and a one-step colormap seems semantically reasonable.
Currently, we get:
❯ uv run --with branca python
Python 3.12.3 (main, Mar 23 2026, 19:04:32) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import branca
>>> from branca.colormap import LinearColormap
>>> print(branca.__version__)
0.8.2
>>>
>>> cm = LinearColormap(["red", "blue"], vmin=0, vmax=1)
>>> cm.to_step(n=1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../branca/colormap.py", line 450, in to_step
index[i] * (1.0 - i / (n - 1.0)) + index[i + 1] * i / (n - 1.0),
~~^~~~~~~~~~~
ZeroDivisionError: float division by zero
The API says n is the expected number of colors in the output StepColormap. When no index/data is supplied it constructs a regular grid from n; later, it computes colors using n - 1.0, which fails at n=1.
Possibilities:
- Could
to_step(n=1)to return aStepColormapwith one color/bin? - Or should
n <= 1be explicitly rejected with a clearValueError? - Or a mention in the docs stating that callers need to special-case single-class data?
- 主要言語
- Python
- スター
- 134
- フォーク
- 69
- 平均マージ
- 1時間 10分
- マージ済み PR(30日)
- 1
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python-visualization/branca のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
python-visualization/branca#213 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
python-visualization/branca#195 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
python-visualization/branca#190 · コメント 6 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
python-visualization/branca#182 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 30/100
python-visualization/branca#174 · コメント 9 件 ·
python-visualization/branca の issue をすべて見る
似ている issue
-
essnmx good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
-
[Feature] 奇物选择添加优先级 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
syfoud/Simulated_Scepter#174 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Giskard-AI/giskard-oss#2840 · コメント 1 件 ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success オープンarea: repo bug perceived difficulty: 2
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
yeti-platform/yeti#1380 ·