Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixing the tests for ivy.Shape method #28470

Merged
merged 6 commits into from
Mar 6, 2024

Conversation

fnhirwa
Copy link
Contributor

@fnhirwa fnhirwa commented Mar 2, 2024

PR Description

Hi, @vedpatwardhan and @Ishticode I walked through the ivy.Shape class and given that shape implements the Sequence like behaviour. I believe that some of the magic methods implemented for this class always raise TypeError and I decided to remove them as they are not needed for the implementation.
Removed methods

  • __mod__
  • __rmod__
  • __rdiv__
  • __div__
  • __sub__
  • __rsub__
  • __int__
  • __floordiv__

After removing these methods I refactored all unit tests of the ivy.Shape methods as most of them were failing due to wrong passing of parameters.

Related Issue

Closes #

Checklist

  • Did you add a function?
  • Did you add the tests?
  • Did you run your tests and are your tests passing?
  • Did pre-commit not fail on any check?
  • Did you follow the steps we provided?

Socials

shape methods as they're not supposed to be
implemented given that shape implements the Sequence
interface. And these methods will always raise type errors
if called.
@fnhirwa fnhirwa marked this pull request as ready for review March 2, 2024 09:55
Copy link
Contributor

@vedpatwardhan vedpatwardhan left a comment

Choose a reason for hiding this comment

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

Hey @fnhirwa, thanks for creating the PR!
Actually these methods were primarily added because the methods exist in torch.Size, tf.TensorShape, etc. Could you please check if those classes have these methods? If they don't then ofc we can remove them from the ivy.Shape class 😄

@fnhirwa
Copy link
Contributor Author

fnhirwa commented Mar 4, 2024

Hey @fnhirwa, thanks for creating the PR! Actually these methods were primarily added because the methods exist in torch.Size, tf.TensorShape, etc. Could you please check if those classes have these methods? If they don't then ofc we can remove them from the ivy.Shape class 😄

Yeah makes sense,
I did a quick walkthrough and found that the methods in torch.Size that are not implemented are
numel and __getnewargs__ and for the tf.TensorShape are most_specific_common_supertype, cast, __concat__, is_subtype_of, _tf_api_names_v1, experimental_from_proto, flatten, _v2_behavior, experimental_as_proto, assert_is_compatible_with, _dims, merge_with, experimental_type_proto, __nonzero__, as_proto, most_specific_compatible_shape, placeholder_value, to_tensors, from_tensors, and _tf_api_names

So I think these are the ones we can add superset behaviour for🙄

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

PR Compliance Checks

Thank you for your Pull Request! We have run several checks on this pull request in order to make sure it's suitable for merging into this project. The results are listed in the following section.

Issue Reference

In order to be considered for merging, the pull request description must refer to a specific issue number. This is described in our contributing guide and our PR template.
This check is looking for a phrase similar to: "Fixes #XYZ" or "Resolves #XYZ" where XYZ is the issue number that this PR is meant to address.

Copy link
Contributor

@vedpatwardhan vedpatwardhan left a comment

Choose a reason for hiding this comment

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

lgtm! Feel free to merge, thanks @fnhirwa 😄

@fnhirwa fnhirwa merged commit 68b82e2 into Transpile-AI:main Mar 6, 2024
131 of 140 checks passed
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.

None yet

3 participants