Skip to content

Conversation

WeiguoMa
Copy link
Contributor

Add clip() and floor() functions for backends. Add reshaped() function to abstractbackend as a preparation for qudit systems. Add corresponding tests in tests/test_backends.py for clip() and floor().

Copy link
Member

@refraction-ray refraction-ray left a comment

Choose a reason for hiding this comment

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

Overall looks good, with some minor fixes required


size = self.sizen(a)
if size == 0:
return self.reshape(a, (0,))
Copy link
Member

Choose a reason for hiding this comment

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

what is reshape (0) mean? just return a?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Typically, a tensor with size=0 can still have multiple shape possibilities, such as shape=(2, 0, 5), (0, ), (0, 3). These three tensors with different shapes all belong to the size=0 case. To ensure consistent output under this API and avoid potential shape errors, we use reshape(a, (0, )).

@refraction-ray
Copy link
Member

LGTM now, thanks for the contribution

@refraction-ray refraction-ray merged commit 60eff60 into tensorcircuit:master Aug 28, 2025
1 check passed
@refraction-ray
Copy link
Member

@all-contributors please add @WeiguoMa for code, tests

Copy link
Contributor

@refraction-ray

I've put up a pull request to add @WeiguoMa! 🎉

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.

2 participants