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

test_post_training_analysis: _FakeSnapshotFrame doesn't support pandas boolean masking

Aperta
#69 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
0
Fork
1
Merge medio
4h 5m
PR unite (30g)
24

Descrizione

## 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).

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.