-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Fixing np.floor_divide frontend test #9333
Conversation
…ckend implementations but now the tests are passing
@ahmedo42 Can you review this please? |
…visionError and added a condition using hypothesis to make sure that the divisor is not zero after casting to dtype
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @hello-fri-end
The reason why we didn't do np.floor_divide
or jnp.floor_divide
in first place is due to special cases from array API. Doing so can lead to the failure of Array API tests.
Hi @hirwa-nshuti ! Thanks for taking the time to review this PR.
Oh, thanks for the information. I have reverted my changes and added a few |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey check a few comments below
input_dtypes, x, casting, dtype = dtypes_values_casting | ||
assume(not np.any(np.isclose(x[1], 0))) | ||
assume(not np.any(np.isinf([x[1], x[0]]))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to filter out inf
as this is handled inside the data generation
input_dtypes, x, casting, dtype = dtypes_values_casting | ||
assume(not np.any(np.isclose(x[1], 0))) | ||
assume(not np.any(np.isinf([x[1], x[0]]))) | ||
if dtype: | ||
assume(not np.any(np.isclose(np.cast[dtype](x[1]), 0))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also is handled by the above assume block
Thanks for the suggestions. The tests are still failing and I'm not sure what the solution is here. It seems a= np.array([0.000977], dtype=float16)
b = np.array(-[32768.], dtype=float16)
>>> np.floor_divide(a,b)
-1.0
>>> np.divide(a, b)
-0.0
>>> np.floor(np.divide(a,b)).astype(a.dtype)
-0.0 Looks like |
As the ivy implementation conforms to Array API standards these edge cases should not pass as Numpy fully follows the python standards and we can't go ahead and modify the backend implementation🙂 Here we can generate values that are naturally not nearly close to zero to make our tests pass. |
Thanks for the suggestions :) I've added bounds on the array values and the tests are passing for now 👍 |
What if we removed the limitations and use filtering for all values close to zero in inputs |
This seems to work for now, although, I've kept the tolerance values as 1e-1. I've pushed the changes, please review them again :) |
Co-authored-by: hirwa-nshuti <[email protected]>
Co-authored-by: hirwa-nshuti <[email protected]>
Co-authored-by: hirwa-nshuti <[email protected]>
No description provided.