AllenNeuralDynamics / AllenNeuralDynamics/aind-dynamic-foraging-bfm-wrapper
test_post_training_analysis: _FakeSnapshotFrame doesn't support pandas boolean masking
- 主要语言
- Python
- 星标
- 0
- 派生
- 1
- 平均合并
- 4 小时 5 分钟
- 30 天内合并 PR
- 24
描述
## What
Split out of #68 while fixing its "4 dead-fixture tests" item — see
AllenNeuralDynamics/aind-disrnn-wrapper#67-adjacent branch `test/fix-dead-fixture`
for the discovery.
`test_post_training_analysis.py` has 3 copy-pasted `_FakeSnapshotFrame` /
`_FakeFrameSeries` classes (a hand-rolled stand-in for a pandas DataFrame, used
to avoid constructing a real one in tests that mock everything else). They
implement `__len__`, `__getitem__`, `__setitem__`, `.copy()`, and (as of the
linked commit) `.columns`.
`generative_analysis._fill_offcurriculum_curriculum_name` — called from
`load_animal_session_history` — has grown past what these fakes model: it does
boolean-mask filtering and calls `.any()` on the result, which the fakes
return as a plain Python `list`, not anything array-like.
## Confirmed pre-existing, confirmed shared
All 3 use sites fail identically on `origin/main`, independent of anything in
#68:
- `test_load_animal_session_history_uses_snapshot_without_raw_nwb_loading`
- `test_load_animal_session_history_multisubject_uses_trained_subject_ids`
- `test_load_animal_session_history_multisubject_aligns_session_ids_to_training_namespace`
```
AttributeError: 'list' object has no attribute 'any'
at generative_analysis.py:8704, in _fill_offcurriculum_curriculum_name
```
## Fix options
1. **Flesh out the fakes** to support the pandas operations
`_fill_offcurriculum_curriculum_name` (and anything else downstream) needs
— brittle, grows every time production code adds another pandas call these
tests happen to exercise.
2. **Switch these 3 tests to a real, small `pandas.DataFrame`.** Almost
certainly the right fix — pandas is already a hard dependency of this
codebase, so there's no reason to hand-roll a partial reimplementation of
it. Removes the whole class of "fake doesn't support method X" bugs, not
just this one.
Recommend (2).
## Acceptance criteria
- [ ] All 3 affected tests pass
- [ ] The 3 `_FakeSnapshotFrame`/`_FakeFrameSeries` pairs are gone, replaced by
real `pandas.DataFrame` construction
- [ ] No other test in the file silently relied on the fakes' specific
(non-pandas) behavior
## Blocked by
None (can start immediately; independent of #68's other items).
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。