Removed nan-handlers for torch tensors. Updated the unit tests.#751
Removed nan-handlers for torch tensors. Updated the unit tests.#751
Conversation
There was a problem hiding this comment.
Pull request overview
Removes the torch-specific NaN handling paths from DataProvider now that batches are expected to remain NumPy until they reach the model, and updates the NaN-related unit tests accordingly.
Changes:
- Removed the
torch.Tensor-specific_handle_nansregistration and torch-based NaN helper functions. - Updated
test_nan.pyto use NumPy-based NaN assertions and removed the test-only NaN dataset subclass.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/hyrax/data_sets/data_provider.py |
Drops torch tensor NaN-handling logic and simplifies tuple/list handling to NumPy arrays only. |
tests/hyrax/test_nan.py |
Removes torch dependency and adapts tests to validate NaN handling with NumPy arrays and HyraxRandomDataset. |
You can also share your feedback on Copilot code review. Take the survey.
| else: | ||
| # Keep non-tensor elements unchanged (e.g., labels, metadata) | ||
| # Keep non-numpy elements unchanged (e.g., labels, metadata) | ||
| handled_elements.append(element) | ||
|
|
||
| return tuple(handled_elements) |
There was a problem hiding this comment.
_handle_nans_tuple is registered for both tuple and list, but it always returns tuple(handled_elements). This changes the type for list inputs (and contradicts the backward-compatibility comment). Consider preserving the input type (e.g., return list for list inputs) and updating the docstring/comment to reflect that it handles both tuples and lists.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #751 +/- ##
==========================================
+ Coverage 64.45% 64.62% +0.17%
==========================================
Files 61 61
Lines 5925 5875 -50
==========================================
- Hits 3819 3797 -22
+ Misses 2106 2078 -28 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Click here to view all benchmarks. |
Change Description
Closes #737
Removed nan handlers for torch tensors and updated the associated test file.
The unit tests were simplified as well. There was an unused (or hardly used) dataset class that would produce data with nans, but that was previously packed into the HyraxRandomDataset. So I removed the old
RandomNanDatasetthat was exclusively used for testing this feature. This is ok because HyraxRandomDataset can produce nans in it's random data and exercise the same functionality.