BUG: geomspace returns wrong sign for the endpoints when start and stop are negative
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
pytensor/tensor/ 内の geomspace 実装を探してください(result[0] と result[-1] に対する set_subtensor を検索)。endpoints は sign(start) を掛ける前に設定されており、start が負の場合に再度符号が反転してしまいます。endpoints が正しくなるよう、例えば設定する前に sign(start) を掛けるように移動または並べ替えてください。pt.geomspace(np.float64(-2.0), np.float64(-30.0), num=4).eval() で再現し、np.geomspace と比較してください。スカラー入力と配列入力の両方で endpoints が NumPy と一致すれば完了です。注意:起票者はパッチを持っており PR を開く可能性があると言っているので、着手前に確認してください。
索引モデルが issue の本文から書いたものです。
説明
Describe the issue:
pt.geomspace returns the wrong sign for the first and last samples when start and stop are negative. The interior samples are correct.
In geomspace, the endpoints are written into the result with set_subtensor(result[0, ...], start) and set_subtensor(result[-1, ...], stop), and only afterwards the whole result is multiplied by sign(start). For a negative start this multiplies the already-negative endpoints by -1 again.
np.geomspace(-2, -30, 4) gives [-2, -4.93, -12.16, -30]; pt.geomspace gives [2, -4.93, -12.16, 30].
Reproducible code example:
import numpy as np
import pytensor.tensor as pt
start, stop = np.float64(-2.0), np.float64(-30.0)
print(pt.geomspace(start, stop, num=4).eval())
print(np.geomspace(start, stop, num=4))
Error message:
[ 2. -4.93242404 -12.16440357 30. ]
[ -2. -4.93242415 -12.16440399 -30. ]
The same happens per element for array inputs, e.g. start=[-1, 2], stop=[-8, 16] gives [1, -2, -4, 8] for the first sequence.
PyTensor version information:
PyTensor main (2e1005b), NumPy 2.5.4, Python 3.12, macOS arm64.
Context for the issue:
A possible fix is to multiply by sign(start) before setting the exact endpoints (a 2-line change). I have a patch with a regression test and can open a PR if that is welcome.
Disclosure: found, reproduced and the draft fix tested locally with the help of an AI coding agent (Claude Code); reviewed before filing.
- 主要言語
- Python
- スター
- 654
- フォーク
- 258
- 平均マージ
- 3日 41分
- マージ済み PR(30日)
- 42
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pymc-devs/pytensor のほかの issue
-
Docs of mode still mentions C/CVM as the default with FAST_RUN対応中かも @ADITYASINGH1206 が 8 日前に担当しました。 オープンdocs
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
pymc-devs/pytensor#2641 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
docs
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
Reciprocal.impl computes np.float32(1.0) / x: float32 precision for float64 scalars under NEP 50 (Python linker)再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
pymc-devs/pytensor#2430 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
pymc-devs/pytensor#2428 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
pymc-devs/pytensor の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
dgunning/edgartools#2019 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
topoteretes/cognee#6818 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
source_verification_agent: no outcome when the publisher confirms a work but its DOI resolves to a different record対応中かも @pinjun99 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Imbad0202/academic-research-skills#1159 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: DoubleMLData.from_arrays checks the treatment d with force_all_x_finite instead of force_all_d_finite対応中かも @leninworld が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
DoubleML/doubleml-for-py#471 ·
メンテナーはふだん 1 日以内に返信