-
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
Add standard_t
function to numpy frontend
#21549
Add standard_t
function to numpy frontend
#21549
Conversation
Thanks for contributing to Ivy! 😊👏 |
If you are working on an open task, please edit the PR description to link to the issue you've created. For more information, please check ToDo List Issues Guide. Thank you 🤗 |
denominator = ivy.gamma(df / 2, 1.0, shape=size, dtype="float64") | ||
return ivy.sqrt(df / 2) * ivy.divide(numerator, ivy.sqrt(denominator)) |
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.
Should I be using the division function implemented in ivy here (ivy.divide
)? I tried to do that but the gamma function fails because it expects to have integers
or floats
as inputs rather than ivy.arrays
.
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.
Gamma accepts both Array
and NativeArray
so this shouldn't be an issue
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.
denominator = ivy.gamma(df / 2, 1.0, shape=size, dtype="float64") | |
return ivy.sqrt(df / 2) * ivy.divide(numerator, ivy.sqrt(denominator)) | |
denominator = ivy.gamma(ivy.divide(df, 2), 1.0, shape=size, dtype="float64") | |
return ivy.sqrt(ivy.divide(df, 2)) * ivy.divide(numerator, ivy.sqrt(denominator)) |
When I run the tests locally with ivy.divide
I get an error saying:
ivy.utils.exceptions.IvyBackendException: numpy: gamma: low and high bounds must be numerics when shape is specified
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.
Error on the CI seems to be somewhat different anbd suggest input issues. Please check the same and request a review once done
https://github.com/unifyai/ivy/actions/runs/5811559595/job/15755368193?pr=21549#step:3:543
The mathematical formula that was implemented was found from numpy's source code |
@@ -410,6 +410,40 @@ def test_numpy_standard_gamma( | |||
) | |||
|
|||
|
|||
@handle_frontend_test( | |||
fn_tree="numpy.random.standard_t", | |||
df=st.floats(min_value=0, max_value=20, exclude_min=True), |
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.
Please get integers here instead of floats for df
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.
I had it as integers
initially, but the documentation of numpy.random.standard_t
says that df
is a float
. Do you still want me to change that to integers
?
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 is okay then, unless its causing failures elsewhere
Thanks for contributing, could you please comment |
Frontend Task ChecklistIMPORTANT NOTICE 🚨:The Ivy Docs represent the ground truth for the task descriptions and this checklist should only be used as a supplementary item to aid with the review process. Please note that the contributor is not expected to understand everything in the checklist. It's mainly here for the reviewer to make sure everything has been done correctly 🙂 LEGEND 🗺:
CHECKS 📑:
|
@@ -410,6 +410,40 @@ def test_numpy_standard_gamma( | |||
) | |||
|
|||
|
|||
@handle_frontend_test( | |||
fn_tree="numpy.random.standard_t", | |||
df=st.floats(min_value=1, max_value=20), |
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.
@aparajith21 The tests failed when df
was so small that it was practically 0
even though the exclude_min
argument was set to True
. I changed the min_value
of floats
from 0
to 1
and I believe everything passes now 👍
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.
Alright, thanks for the contribution! LGTM now then. Sorry for the late review, really busy personally.
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.
Please request review again once you resolve merge conflicts, and will then merge it
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.
@aparajith21 No problem at all. Have resolved the merge conflict but now some tests fail on the jax
backend 🤷♂️
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 issues, sorry for the late review, believe it's not directly related to your PR, will go ahead and merge, thanks!
Close #21547