cc() truncates periodic coordinates for integer input with fractional bounds
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 35/100
調査の方向性
Start with _map_cyclic() in the cyclic spline implementation and trace how it handles integer coordinates with fractional bounds; compare that path with the natural spline cr() control described in the issue. Reproduce the provided direct cc() and DesignInfo prediction examples with integer and float inputs, then verify both produce matching bases while preserving input immutability.
索引モデルが issue の本文から書いたものです。
説明
cc() silently truncates periodic coordinates when its input has an integer dtype and its exterior bounds are non-integral. The same numeric values produce different spline bases when passed as integers and floats, including when predicting with an existing DesignInfo.
Reproduced with the latest PyPI release, Patsy 1.0.3, and current master 8ce7441586fc228b9ff487a97e3a6ebe9fde6aad on Windows with Python 3.13.15, NumPy 2.5.4 and SciPy 1.18.1:
import numpy as np
from patsy import cc, dmatrix, build_design_matrices
x = np.arange(-1, 6)
kwargs = dict(knots=[1., 2., 3.], lower_bound=0.1, upper_bound=3.4)
integer_basis = cc(x, **kwargs)
float_basis = cc(x.astype(float), **kwargs)
print(np.max(np.abs(integer_basis - float_basis)))
# 1.1751149047931713 (expected: 0)
formula = "0 + cc(x, knots=[1., 2., 3.], lower_bound=0.1, upper_bound=3.4)"
training = dmatrix(formula, {"x": np.array([1., 2., 3.])})
integer_prediction = build_design_matrices([training.design_info], {"x": x})[0]
float_prediction = build_design_matrices([training.design_info], {"x": x.astype(float)})[0]
print(np.max(np.abs(integer_prediction - float_prediction)))
# 1.1751149047931713 (expected: 0)
For example, the period is 3.3, so x=4 maps to approximately 0.7. _map_cyclic() writes that coordinate into a copy of the integer input and truncates it to zero; its subsequent lower-bound mapping then moves it to another incorrect coordinate. The returned design matrix contains no warning about this loss of precision.
Integer and float input agree for points inside the bounds, for whole-number exterior bounds, and for the corresponding natural spline cr() control. A fix can convert integer coordinates to floating point before periodic mapping while preserving the existing floating-point input dtype and input immutability.
- 主要言語
- Python
- スター
- 989
- フォーク
- 108
- 平均マージ
- 1日 1時間
- マージ済み PR(30日)
- 3
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pydata/patsy のほかの issue
-
VarLookupDict should implement __iter__, causes CPython crash when using statsmodels in marimo notebook対応中かも @kouyouqi123 が 145 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
-
`build._eval_factor` error condition attempts to access attribute `dtype` on `DataFrame` object, but no such attribute exists対応中かも @kouyouqi123 が 145 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 55/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
khuisman/mcp-gee-sweet#1166 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
lugassawan/swe-workbench#823 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
gramaziokohler/compas_timber#870 ·
-
security-scan-failure
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
semantica-agi/semantica#2089 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
autowarefoundation/autoware_carla_scenario#500 ·
メンテナーはふだん 1 日以内に返信