[Bug]: Registering an empty AgentSet in Model.sets raises ColumnNotFoundError for "unique_id"
まだ誰も着手していません。
評価
調査の方向性
Start with AgentSetRegistry.add in mesa_frames/concrete/agentsetregistry.py, where agentset["unique_id"] is read around line 108, then check _recompute_ids and the empty pl.DataFrame() created in AgentSet.__init__. Reproduce with the snippet in the issue. Done means an empty set can be registered with zero agents, and index and pos work on it, with a regression test added. The maintainer has not yet chosen between restoring a typed empty column and handling its absence, so confirm the approach before writing code.
索引モデルが issue の本文から書いたものです。
説明
📝 Description
Adding an AgentSet that has no agents yet to model.sets (or an
AgentSetRegistry) raises polars ColumnNotFoundError: unable to find column
"unique_id".
This worked before PR #110 ("Generate automatically unique_id"). At that
point an empty AgentSet was created with a unique_id column in its schema.
After #110, an empty AgentSet has no columns, but AgentSetRegistry.add still
reads agentset["unique_id"].
The same missing column also makes _recompute_ids, AgentSet.index and
(when a space is set) AgentSet.pos fail on an empty set.
🔄 Steps to Reproduce
from mesa_frames import AgentSet, Model
class E(AgentSet):
def step(self):
pass
m = Model()
m.sets += E(m)
🎯 Expected Behavior
I expected the empty AgentSet to be registered with zero agents, so that a
set can be declared (for example in Model.init) and populated later. This
worked before #110.
🚨 Actual Behavior
polars.exceptions.ColumnNotFoundError: unable to find column "unique_id";
valid columns: []
🖥️ Python Version
3.13.2
Operating System
Windows 11 (build 10.0.26300)
Relevant Packages
polars 1.36.1
mesa 3.3.1
mesa-frames at main, commit ef92326
📊 Relevant Log Output
Traceback (most recent call last):
File "<string>", line 5, in <module>
m.sets += E(m)
File "mesa_frames/abstract/agentsetregistry.py", line 480, in __iadd__
return self.add(sets=other, inplace=True)
File "mesa_frames/concrete/agentsetregistry.py", line 108, in add
[obj._ids] + [pl.Series(agentset["unique_id"]) for agentset in other_list]
...
polars.exceptions.ColumnNotFoundError: unable to find column "unique_id"; valid columns: []
➕ Additional Context
Before commit e757571 (#110), AgentSet.init created the empty frame with
a unique_id column: pl.DataFrame(schema={"unique_id": pl.Int64}). After it,
it is pl.DataFrame() with no columns, but AgentSetRegistry.add (and
_recompute_ids) still read agentset["unique_id"].
The same missing column also makes AgentSet.index fail on an empty set, and
AgentSet.pos fail when a space is set.
I searched open and closed issues and PRs for "empty", "unique_id" and
"AgentSetRegistry" and did not find this reported.
Question: should empty sets be registrable? If so, would you prefer restoring
a typed empty unique_id column, or handling its absence where it is read? Or
is the current behaviour intended?
I'm happy to send a PR once you say which approach you prefer.
- 主要言語
- Python
- スター
- 44
- フォーク
- 20
- 平均マージ
- 1分
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
mesa/mesa-frames のほかの issue
-
Mesa-frames 0.2.0オープン
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
mesa/mesa-frames#186 · コメント 10 件 ·
-
feature triage
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
mesa/mesa-frames#177 · コメント 1 件 ·
-
[Bug]: Solving polars Deprecation warnings for `is_in`対応中かも @adamamer20 が 429 日前に担当しました。 オープンbug good first issue maintenance Sprints!
mesa/mesa-frames#174 · コメント 2 件 · 担当者 1 名 ·
-
[Enhancement] : agents selection in AgentsDf would be better if it returns agent_idx/name as keyオープンenhancement
難易度 3/5 1〜2日 初心者へのやさしさ 40/100
mesa/mesa-frames#162 · コメント 1 件 ·
-
[Feature]: Easy seed accessor across the entire codebase再び着手できるかも @falloficaruss が 328 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンfeature good first issue Sprints!
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
mesa/mesa-frames#159 · コメント 3 件 ·
mesa/mesa-frames の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
yt-project/yt#5624 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
NousResearch/hermes-agent#148376 ·
メンテナーはふだん 1 日以内に返信
-
Analysis
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
SACGF/variantgrid#2615 ·
メンテナーはふだん 1 日以内に返信