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

test_post_training_analysis: _FakeSnapshotFrame doesn't support pandas boolean masking

Abierto
#69 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
0
Forks
1
Merge medio
4 h 5 min
PR fusionados (30 d)
24

Descripción

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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.