Add support to more feasiable function to. - #23
Merged
Conversation
hzhangxyz
force-pushed
the
dev/add-support-to-dtype-to
branch
from
July 31, 2025 03:55
3e97afa to
cc44007
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #23 +/- ##
==========================================
+ Coverage 28.81% 38.57% +9.76%
==========================================
Files 3 3
Lines 177 197 +20
Branches 19 26 +7
==========================================
+ Hits 51 76 +25
+ Misses 126 121 -5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
hzhangxyz
force-pushed
the
dev/add-support-to-dtype-to
branch
2 times, most recently
from
July 31, 2025 04:03
f716d8a to
fb4141e
Compare
hzhangxyz
force-pushed
the
dev/add-support-to-dtype-to
branch
from
July 31, 2025 05:41
fb4141e to
bc1d886
Compare
hzhangxyz
force-pushed
the
dev/add-support-to-dtype-to
branch
from
July 31, 2025 05:47
bc1d886 to
f62c660
Compare
hzhangxyz
force-pushed
the
dev/add-support-to-dtype-to
branch
from
July 31, 2025 05:51
f62c660 to
9508f04
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the to method of the ParityTensor class to support more flexible conversion options, including device and dtype conversions with multiple parameter formats. The method now accepts positional arguments for device/dtype specifications alongside keyword arguments.
- Expands the
tomethod signature to accepttorch.device,torch.dtype, or string parameters - Adds comprehensive test coverage for various parameter combinations and error cases
- Implements validation to prevent duplicate parameter specifications
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| parity_tensor/parity_tensor.py | Enhanced to method with flexible parameter handling and dtype conversion support |
| tests/conversion_test.py | Added comprehensive test suite covering parameter combinations and edge cases |
Comments suppressed due to low confidence (2)
tests/conversion_test.py:41
- The condition
len(args) <= 1means cases with 2 positional arguments (device + dtype) are never tested, leaving important functionality uncovered.
if len(args) <= 1:
parity_tensor/parity_tensor.py:67
- The parameter name
whateveris unclear and unprofessional. Consider renaming it to something more descriptive liketargetordestination.
def to(self, whatever: torch.device | torch.dtype | str | None = None, *, device: torch.device | None = None, dtype: torch.dtype | None = None) -> ParityTensor:
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.