Skip to content

Fix TemporalOrderDataset bug and improve test coverage#56

Merged
gchindemi merged 5 commits intomainfrom
bugfix/sampling
Jun 12, 2025
Merged

Fix TemporalOrderDataset bug and improve test coverage#56
gchindemi merged 5 commits intomainfrom
bugfix/sampling

Conversation

@gchindemi
Copy link
Copy Markdown
Member

This pull request refactors the lisbet/datasets.py module to improve parameter validation, enhance debugging capabilities, and simplify dataset configuration. Key changes include stricter input validation, the addition of debugging metadata, and renaming parameters for clarity.

Validation Improvements:

  • Added stricter validation for input parameters, such as ensuring max_shift is positive and max_warp is within valid bounds.

Debugging Enhancements:

  • Introduced debugging metadata (attrs) to track original and transformed coordinates for datasets, including orig_coords, swap_coords, pre_coords, post_coords, shift_coords, and warp_coords.

Parameter Simplifications:

  • Replaced min_delay/max_delay with max_shift for time shifts and min_speed/max_speed with max_warp for temporal warping, simplifying configuration and improving clarity.

Dataset Logic Adjustments:

  • Consolidated redundant validation logic by moving checks (e.g., minimum number of individuals) to the dataset initialization phase to avoid duplication.

Functional Updates:

  • Adjusted window selection logic to split pre- and post-windows more cleanly and ensure proper time alignment.

- Split window extraction into pre and post halves
- Shift post window time coordinates to follow pre window
- Concatenate windows directly instead of slicing
- Add debugging attributes for pre and post coordinates
- Move individual count validation to WindowDataset
- Remove redundant checks from subclasses
- Replace min_delay/max_delay with max_shift in TemporalShiftDataset
- Replace min_speed/max_speed with max_warp in TemporalWarpDataset
- Update docstrings and error messages for clarity and consistency
- Adjust label logic for new parameter conventions
@gchindemi gchindemi linked an issue Jun 12, 2025 that may be closed by this pull request
@gchindemi gchindemi requested a review from Copilot June 12, 2025 13:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug in the TemporalOrderDataset and improves test coverage by refactoring parameter validation, adding debugging metadata, and simplifying configuration parameters.

  • Implements stricter input validations and unified error messaging for time shift and warp configurations
  • Refactors window selection logic and introduces additional debugging attributes for deeper insight during testing
Comments suppressed due to low confidence (2)

src/lisbet/datasets.py:705

  • The error message refers to 'max_warp' as a positive integer while it is defined as a float and expressed as a percentage in the docstring. Consider updating the error message for consistency.
if not (0 < max_warp <= 100):

src/lisbet/datasets.py:619

  • The variable 'frame_idx_delay' is used but not defined in this context. Please define 'frame_idx_delay' before using it in the debugging information.
x.attrs["shift_coords"] = [rec_idx, frame_idx_delay, delta_delay]

@gchindemi gchindemi merged commit efe2921 into main Jun 12, 2025
@gchindemi gchindemi deleted the bugfix/sampling branch June 12, 2025 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect positive sampling in TemporalOrderDataset

2 participants