[Bug]: Setting a column on an empty AgentSet fails with polars 2.x (ShapeError); CI on main is red
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 74/100
Hướng nghiên cứu
Start by reading the AgentSet column-setting path and the ExampleAgentSet / ExampleAgentSetA fixtures used by tests/test_agentset.py and tests/test_agentsetregistry.py. Reproduce the failure with polars 2.1.0, then compare the behavior with the locked 1.36.1 version. Done means setting the first column on an empty AgentSet works with supported polars versions and the affected tests pass.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
📝 Description
With polars 2.x, setting a column on an empty AgentSet raises polars.exceptions.ShapeError: can't broadcast Series 'wealth' of length 4 to length 0. It works with polars 1.36.1, which is the version pinned in uv.lock.
The cause is a behavior change in polars itself: pl.DataFrame().with_columns(pl.Series("wealth", [1, 2, 3, 4])) returns a (4, 1) DataFrame on polars 1.36.1 and raises the same ShapeError on polars 2.1.0.
This affects users of the library (creating an AgentSet and setting its first column) and it also breaks the test suite: the shared fixtures such as ExampleAgentSet / ExampleAgentSetA do exactly this in __init__. The CI install is not locked, so it pulls polars 2.1.0 and CI Checks fail on every OS and Python version. The scheduled runs on main have been failing the same way since at least Oct 19 (for example https://github.com/mesa/mesa-frames/actions/runs/41457455719).
🔄 Steps to Reproduce
import polars as pl
from mesa_frames import AgentSet, Model
# Plain polars
print(pl.DataFrame().with_columns(pl.Series("wealth", [1, 2, 3, 4])).shape)
# polars 1.36.1 -> (4, 1); polars 2.1.0 -> ShapeError
# mesa-frames
class A(AgentSet):
def step(self):
pass
a = A(Model())
a["wealth"] = pl.Series("wealth", [1, 2, 3, 4])
# polars 1.36.1 -> works (len(a) == 4); polars 2.1.0 -> ShapeError
🎯 Expected Behavior
Setting the first column on a new AgentSet works with the supported polars versions (pyproject.toml currently allows polars>=1.30.0, with no upper bound).
🚨 Actual Behavior
polars.exceptions.ShapeError: can't broadcast Series 'wealth' of length 4 to length 0
With polars 2.1.0 and the project's tests (MESA_FRAMES_RUNTIME_TYPECHECKING=1), running only tests/test_agentset.py and tests/test_agentsetregistry.py gives 52 errors (in fixture setup) and 9 failures. With the locked polars 1.36.1 the only failure in the full suite is test_datacollector.py::test_postgress, which needs a PostgreSQL database.
🖥️ Python Version
Python 3.12.14
Operating System
macOS (Apple Silicon); the same failure shows in CI on Ubuntu (3.11, 3.12, 3.13, 3.13 --pre), macOS and Windows.
Relevant Packages
polars 1.36.1 (works) vs polars 2.1.0 (fails)
📊 Relevant Log Output
ERROR at setup of Test_AgentSet.test_add
E polars.exceptions.ShapeError: can't broadcast Series 'wealth' of length 4 to length 0
➕ Additional Context
I have not yet checked whether anything besides this pattern breaks with polars 2.x, because the setup error hides later failures. Two possible directions, both up to the maintainers: temporarily constrain polars<2 in pyproject.toml to get CI green again, and/or make setting a column on an empty AgentSet work with polars 2.x. I am happy to work on a fix if that would be useful.
Related: #204 / #206 (the tests added there avoid these fixtures, so they pass on both polars versions).
- Ngôn ngữ chính
- Python
- Star
- 44
- Fork
- 20
- Merge trung bình
- 1 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
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 mesa/mesa-frames
-
[Bug]: Registering an empty AgentSet in Model.sets raises ColumnNotFoundError for "unique_id"Có thể đã có người làm @Jay-Naik2526 đã nhận 3 ngày trước. Đang mởbug triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
mesa/mesa-frames#204 ·
-
Mesa-frames 0.2.0Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
mesa/mesa-frames#186 · 10 bình luận ·
-
feature triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
mesa/mesa-frames#177 · 1 bình luận ·
-
[Bug]: Solving polars Deprecation warnings for `is_in`Có thể đã có người làm @adamamer20 đã nhận 435 ngày trước. Đang mởbug good first issue maintenance Sprints!
mesa/mesa-frames#174 · 2 bình luận · 1 người được giao ·
-
[Enhancement] : agents selection in AgentsDf would be better if it returns agent_idx/name as keyĐang mởenhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 40/100
mesa/mesa-frames#162 · 1 bình luận ·
Tất cả issue của mesa/mesa-frames
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
igormcsouza/tether#278 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
aws-samples/sample-per-model-bedrock#803 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation p1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/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 78/100
huggingface/accelerate#4511 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
follow-up
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày