cc() truncates periodic coordinates for integer input with fractional bounds
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 989
- Fork
- 108
- Merge trung bình
- 1 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pydata/patsy
-
VarLookupDict should implement __iter__, causes CPython crash when using statsmodels in marimo notebookCó thể đã có người làm @kouyouqi123 đã nhận 142 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Add link to license in readmeĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
-
`build._eval_factor` error condition attempts to access attribute `dtype` on `DataFrame` object, but no such attribute existsCó thể đã có người làm @kouyouqi123 đã nhận 142 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 55/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
Issue tương tự
-
Edit tool converts CRLF files to LFCó thể đã có người làm @RaphaelFakhri đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
huggingface/tau#774 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
show ignores the row limit when a column or table name contains "limit"Có thể đã có người làm @RaphaelFakhri đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Agents panel: Codex token stats always empty because Codex now writes `*.jsonl.zst` sessionsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 2 ngày
-
documentation good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
eclipse-score/inc_someip_gateway#356 ·
Maintainer thường phản hồi trong vòng 2 ngày