| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
Good fix!
Will be revisited during the keypoint refactoring, ofc. But good to include this fix before we work on that. (Great that you added tests BTW)
Sorry, something went wrong.
Add a new test module exercising outlier_frames.compute_deviations. Introduces fixtures to build dense and sparse multi-animal DataFrames, plus mocks for SARIMAX fitting and HDF writing. Adds a regression test ensuring sparse layouts preserve only actual streams (not the Cartesian product of non-'coords' levels) and a behavior-preservation test verifying dense layouts match the old product-based column ordering. Tests also assert output shapes, selectable derived-stat levels, zero-distance behavior with a deterministic fake fitter, expected SARIMAX call counts, and that the 'full' storeoutput path attempts persistence.
Replace MultiIndex.from_product with a MultiIndex built from the existing keypoint coordinate combinations (preserving their original order). The change detects the 'coords' level, selects base columns for the 'x' coordinate, appends statistical fields (distance, sig, meanx, etc.), and constructs a MultiIndex.from_tuples with an added 'stats' level. This avoids generating invalid/extra keypoint combinations and keeps column ordering consistent when assembling the deviations DataFrame.
Simplify extraction of base columns by replacing manual level-index lookup and droplevel logic with Dataframe.xs("x", axis=1, level="coords", drop_level=True).columns. Updated comment to note that 'y' could be used interchangeably. This makes the code clearer and reduces explicit MultiIndex handling.
|
Rebased as per #3263 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Scope
Fixes extract_outlier_frames(..., outlieralgorithm="fitting") for multi-animal projects with sparse column layouts (e.g. projects using uniquebodyparts).
The current code was rebuilding a MultiIndex over all unique, non-coords level values, which would create invalid individual × bodypart combinations that do not actually exist, leading to a shape mismatch when constructing the output dataframe.
This occurs in the fitting branch of extract_outlier_frames.
Fix
Instead of rebuilding the output columns with MultiIndex.from_product(...), derive the base tuples from the existing dataframe columns by selecting the "x" columns and dropping the coords level, preserving only the valid keypoint combinations in their original order.
We then append the derived stats to those actual stream tuples, keeping the output columns aligned with np.concatenate(preds, axis=1).
Tests
Two tests were added :