Skip to content

Commit

Permalink
fix: fixing the tests for ivy.Shape method and removed unused methods(
Browse files Browse the repository at this point in the history
ivy-llc#28470)

Removed methods:
* `__mod__`
*  `__rmod__`
*  `__rdiv__`
*  `__div__`
*  `__sub__`
*  `__rsub__`
*  `__int__`
*  `__floordiv__`

Methods to add as superset:
`torch.Size`: `numel` and `__getnewargs__` 
`tf.TensorShape`: `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`
  • Loading branch information
fnhirwa authored Mar 6, 2024
1 parent 726c478 commit 68b82e2
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 348 deletions.
42 changes: 3 additions & 39 deletions ivy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,59 +304,23 @@ def __rmul__(self, other):
return self

def __bool__(self):
if ivy.current_backend_str() == "tensorflow":
return builtins.bool(builtins.tuple(self._shape))
return builtins.bool(self._shape)

def __div__(self, other):
return to_ivy(self._shape // other)

def __floordiv__(self, other):
return to_ivy(self._shape // other)

def __mod__(self, other):
return to_ivy(self._shape % other)

def __rdiv__(self, other):
return to_ivy(other // self._shape)

def __rmod__(self, other):
return to_ivy(other % self._shape)

def __reduce__(self):
return (self.__class__, (self._shape,))

def as_dimension(self, other):
if isinstance(other, self._shape):
return to_ivy(other)
else:
return to_ivy(self._shape)

def __sub__(self, other):
try:
self._shape = self._shape - other
except TypeError:
self._shape = self._shape - list(other)
return self

def __rsub__(self, other):
try:
self._shape = other - self._shape
except TypeError:
self._shape = list(other) - self._shape
return self
return self._shape

def __eq__(self, other):
self._shape = Shape._shape_casting_helper(self._shape, other)
return self._shape == other

def __int__(self):
if hasattr(self._shape, "__int__"):
res = self._shape.__int__()
else:
res = int(self._shape)
if res is NotImplemented:
return res
return to_ivy(res)

def __ge__(self, other):
self._shape = Shape._shape_casting_helper(self._shape, other)
return self._shape >= other
Expand Down
Loading

0 comments on commit 68b82e2

Please sign in to comment.