AllenNeuralDynamics / AllenNeuralDynamics/aind-dynamic-foraging-bfm-wrapper

test_post_training_analysis: _FakeSnapshotFrame doesn't support pandas boolean masking

未關閉
#69 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
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 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。