Modernize package#2
Merged
Merged
Conversation
Reproducible dev env (python 3.11-3.13 features, numpy/pandas/scipy + pytest) with build/test/test-cov tasks. Root conftest.py puts the repo on sys.path so the flat module imports during the pre-packaging test phases.
Golden-master capture/replay locking current numerical output for all 29 public functions across 3 seeded synthetic experiments + a repeated-presentation case. golden.npz captured on numpy 1.24/pandas 2.3; suite passes identically on numpy 2.4/pandas 3.0. Two known-broken behaviors (undefined `mat` in loftus_masson_unequal_variance_kahana; IndexError in pd_min_temp_fact default path) are pinned as pytest.raises and logged in bug_report.md.
Hand-coded value tests, mathematical-property tests, and edge cases for all 29 functions, layered on the Phase 4 behavior lock. 114 new tests (193 total), passing on numpy 1.24 and numpy 2.4. Known-broken behaviors pinned with pins_bug markers. Surfaced two new bugs (reported, not fixed): operator-precedence NaN-padding misclassification in make_recalls_matrix/make_poss_recalls_matrix, and ZeroDivisionError in cousineau for a single condition.
Loads 5 sessions of real ltpFR2 scalp-EEG free-recall data from rhino and runs
the pybeh_pd pipeline, asserting the temporal contiguity effect (lag+1 CRP is the
max, forward asymmetry, lag 0 NaN) and above-chance temporal clustering. Verifies
the direct per-subject call equals the canonical groupby('subject').apply(pd_crp)
convention from the lab notebooks, and that the synthetic fixture mirrors the real
event schema. Gated behind needs_data (cmlreaders + rhino mount); skipped
otherwise (6-7 skipped off-rhino).
Adds a 'rhino' pixi environment installing cmlreaders from git (no-build-isolation,
since its setup.py imports pandas) so the ltpFR2 integration tests run via pixi,
not just the lab conda env. Reworked the per-subject equivalence test to express
the canonical groupby-apply decomposition by explicit slicing: the literal
groupby('subject').apply(pd_crp) idiom breaks on pandas 3 (grouping column dropped;
logged as a pandas-3 compat follow-up). Real-data suite now passes on pandas 2.3
and 3.0.
Commit 5 sessions of ltpFR2 (LTP093) behavioral events as tests/data/ ltpfr2_5sessions.csv plus frozen pybeh_pd outputs (ltpfr2_golden.npz), so the real-data integration tests run anywhere without cmlreaders or the rhino mount. Drops the pixi rhino env. The golden comprehensively locks every analysis applicable to plain free-recall events (matrix builders, full lag-CRP family incl. min_crp, temporal factor incl. min_temp_fact, pooled and per-session) via a capture_outputs() shared by the test and the regeneration script; semantic CRP / distance-factor stay locked on the synthetic suite (ltpFR2 has no semantic space). 216 tests pass on numpy 1.24/pandas 2.3 and numpy 2.4/pandas 3.0.
Restructure the flat pybeh_pd.py + pybeh_copy.py into a proper package: src/pybeh_pd/__init__.py - re-exports the public API (unchanged surface) src/pybeh_pd/_core.py - former pybeh_pd.py (intra-package import of vendored) src/pybeh_pd/_pybeh.py - former pybeh_copy.py (vendored pybeh subset) The implicit 'from pybeh_copy import ...' becomes 'from ._pybeh import ...', fixing the import that previously only worked with the repo root on sys.path. Adds a hatchling pyproject.toml (pip install / editable / wheel + sdist all verified) and wires an editable self-install into the pixi envs; pytest config moves from pytest.ini into pyproject. Behavior-preserving: 216 tests pass on numpy 1.24/pandas 2.3 and numpy 2.4/pandas 3.0; clean-venv wheel install exposes the same 36 public names.
Relocate the 5 demo notebooks and the MATLAB Loftus-Masson reference out of the repo root into examples/ (excluded from the wheel). Notebook API updates are handled in the documentation phase.
Test job across Python 3.11-3.13 x numpy 1/2 (numpy 1 excluded on 3.13 where it has no wheels), running the full suite incl. the committed ltpFR2 real-data tests (no cmlreaders needed). Build job builds wheel+sdist via PEP 517 and smoke-installs the wheel. Validated locally: numpy 1.24/pandas 2.3, numpy 1.26/pandas 3.0, and numpy 2.4/pandas 3.0 all pass 216 tests.
Annotate all functions across _core.py and _pybeh.py to pyright 0 errors/0 warnings (basic mode, pyrightconfig.json scoped to the package). Remove pyflakes-flagged dead imports (scipy.spatial.distance) and unused locals (n_items in make_recalls_matrix, possibles_range/with_repeats in min_temp_fact, M_C in loftus_masson_analytic). The two undefined-name findings (mat, warnings) ARE bugs B1/B2 — left unfixed, suppressed with type-ignore + noqa citing the bug IDs so they stay tracked. 'types' kept with noqa (it is used via df.query @types, a pyflakes false positive). Adds ruff (F rules) to the pixi env + a CI lint job; pyright/ruff ratchet wired into the pre-commit hook. Behavior-neutral: 216 tests pass on numpy 1 and 2.
Replace the stale 'just a module, append to sys.path' README with a full one: purpose, the utilities provided, pip/editable/git install paths, a quickstart that tests/test_readme.py executes (so it can't drift), dev/test instructions, and the CI summary. Strip the hardcoded sys.path.append lines from the example notebooks now that the package is pip-installable. Notebook data-gating, the pandas-3 groupby idiom, and the missing LICENSE file are flagged in documentation_report.md for human follow-up. 217 tests pass.
Add __version__ = 0.1.0 to the package, read dynamically by hatchling (pyproject version is now dynamic). Add an MIT LICENSE file and point pyproject license at it (+ MIT classifier). Add CHANGELOG.md documenting the modernization and the eight discovered-but-unfixed bugs (B1-B8) pinned for a later fix pass. import and dist metadata both report 0.1.0; 217 tests pass.
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.