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

test_post_training_analysis: _FakeSnapshotFrame doesn't support pandas boolean masking

オープン
#69 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
0
フォーク
1
平均マージ
4時間 5分
マージ済み PR(30日)
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 を短くまとめたダイジェスト。