Skip to content

[MRG] Handle torch tensor in DomainAwareDataset#337

Merged
tgnassou merged 9 commits intoscikit-adaptation:mainfrom
vloison:torch-dad
Sep 23, 2025
Merged

[MRG] Handle torch tensor in DomainAwareDataset#337
tgnassou merged 9 commits intoscikit-adaptation:mainfrom
vloison:torch-dad

Conversation

@tom-yneuro
Copy link
Contributor

Adding support for flexible data types (numpy arrays and torch tensors) and a new return type (DeepDADataset) inside DomainAwareDataset.

Enhanced pack Method Functionality:

  • Implemented logic in the pack method to handle data concatenation and return the appropriate format based on the return_type. Added checks for torch availability and raised appropriate errors if required dependencies are missing.
  • Added support for returning data as a DeepDADataset object, which is compatible with PyTorch's Dataset interface and includes domain-specific information.

Testing Enhancements:

  • Added a new test in test_deep_dadataset.py to validate the functionality of the pack method with different return_type values ("array", "tensor", "DeepDADataset"). Ensures that the output matches the expected types and formats.

@codecov
Copy link

codecov bot commented Jun 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.50%. Comparing base (53a494b) to head (e71a980).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #337      +/-   ##
==========================================
+ Coverage   96.18%   96.50%   +0.32%     
==========================================
  Files          63       51      -12     
  Lines        7020     6068     -952     
==========================================
- Hits         6752     5856     -896     
+ Misses        268      212      -56     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tom-yneuro
Copy link
Contributor Author

tom-yneuro commented Jun 25, 2025

I noticed that the behavior of return_X_y isn't obvious when set to False (i.e it returns a Bunch object or a DomainAwareDataset depending on the file)
Here I proposed to change this argument to return_type, in my case allowing several types
Maybe this approach can be generalized to datasets fetch with return_X_y argument
(Subquestion in my case : should I remove the return_X_y argument or deprecate it, for now it's deprecated)

@tom-yneuro tom-yneuro marked this pull request as ready for review June 25, 2025 15:26
@antoinecollas antoinecollas changed the title Handle torch tensor in DomainAwareDataset [TO_REVIEW] Handle torch tensor in DomainAwareDataset Jun 26, 2025
@tgnassou
Copy link
Collaborator

tgnassou commented Jul 2, 2025

LGTM!

@tgnassou tgnassou changed the title [TO_REVIEW] Handle torch tensor in DomainAwareDataset [MRG] Handle torch tensor in DomainAwareDataset Sep 22, 2025
@tgnassou tgnassou merged commit 0215604 into scikit-adaptation:main Sep 23, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants