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

feat: adding np.ndarray.var to the frontends #22336

Merged
merged 11 commits into from
Oct 4, 2023

Conversation

PushpamJha14
Copy link
Contributor

closes #21949

@github-actions
Copy link
Contributor

Thanks for contributing to Ivy! 😊👏
Here are some of the important points from our Contributing Guidelines 📝:
1. Feel free to ignore the run_tests (1), run_tests (2), … jobs, and only look at the display_test_results job. 👀 It contains the following two sections:
- Combined Test Results: This shows the results of all the ivy tests that ran on the PR. ✔️
- New Failures Introduced: This lists the tests that are passing on main, but fail on the PR Fork. Please try to make sure that there are no such tests. 💪
2. The lint / Check formatting / check-formatting tests check for the formatting of your code. 📜 If it fails, please check the exact error message in the logs and fix the same. ⚠️🔧
3. Finally, the test-docstrings / run-docstring-tests check for the changes made in docstrings of the functions. This may be skipped, as well. 📚
Happy coding! 🎉👨‍💻

@ivy-leaves ivy-leaves added the NumPy Frontend Developing the NumPy Frontend, checklist triggered by commenting add_frontend_checklist label Aug 22, 2023
Copy link
Contributor

@hello-fri-end hello-fri-end left a comment

Choose a reason for hiding this comment

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

Hey @PushpamJha14 ! Thanks for opening this PR. Just left a few minor comments. Feel free to request another review when you are done with the changes,.

},
method_all_as_kwargs_np={
"axis": axis,
"dtype": "float64",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we hardcoding this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

method_all_as_kwargs_np={
"axis": axis,
}

Is it fine now?

Copy link
Contributor

Choose a reason for hiding this comment

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

You should write a strategy for generating values for the dtype parameter as well and then add the generated value to this.

Comment on lines 3627 to 3632
@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="numpy.array",
method_name="var",
dtype_x_axis=helpers.dtype_values_axis(
available_dtypes=helpers.get_dtypes("float"),
Copy link
Contributor

Choose a reason for hiding this comment

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

You should generate values for all the parameters of the function, dtype ddof, keepdims and where are missing here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

keepdims=st.booleans(),
where=np_frontend_helpers.where(),
dtype=x=helpers.get_dtypes(kind="integer")
ddof=0

Is it right?

method_all_as_kwargs_np={
"axis": axis,
"dtype": "float64",
"out": None,
Copy link
Contributor

Choose a reason for hiding this comment

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

The testing pipeline will take care of testing the out argument, no need to pass that as None here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

method_all_as_kwargs_np={
"axis": axis,
},

Is it fine?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just remove "out":None

},
method_all_as_kwargs_np={
"axis": axis,
"dtype": "float64",
Copy link
Contributor

Choose a reason for hiding this comment

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

You should write a strategy for generating values for the dtype parameter as well and then add the generated value to this.

method_all_as_kwargs_np={
"axis": axis,
"dtype": "float64",
"out": None,
Copy link
Contributor

Choose a reason for hiding this comment

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

Just remove "out":None

Copy link
Contributor

@hello-fri-end hello-fri-end left a comment

Choose a reason for hiding this comment

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

Just a minor comment this time. Would you please resolve the merge conflict and look into the failing test cases? Feel free to request another review whenever you are done 👍

),
keepdims=st.booleans(),
where=np_frontend_helpers.where(),
dtype=helpers.get_dtypes(kind="integer"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why should this only be integer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it to valid, is it right now?

Comment on lines 3672 to 3687
dtype_x_axis=helpers.dtype_values_axis(
available_dtypes=helpers.get_dtypes("valid"),
valid_axis=True,
),
keepdims=st.booleans(),
where=np_frontend_helpers.where(),
dtype=helpers.get_dtypes(kind="integer"),
Copy link
Contributor

Choose a reason for hiding this comment

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

You can take a look at the test of the frontend np.var - there's a helper function used there _statistical_dtype_values which you can use to generate the values. It makes sure that the inputs have reasonable bounds and it will also take care of your ddof parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

to use it I have to import it, is it allowed to import new modules?

@PushpamJha14 PushpamJha14 reopened this Sep 1, 2023
@PushpamJha14
Copy link
Contributor Author

I am not getting how to remove these errors especially lint error, can your please help me

@hello-fri-end
Copy link
Contributor

hello-fri-end commented Sep 9, 2023

ivy-gardener
✅ Ivy gardener has formatted your code.
If changes are requested, don't forget to pull your fork.

Copy link
Contributor

@hello-fri-end hello-fri-end left a comment

Choose a reason for hiding this comment

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

Hey @PushpamJha14! Apologies for the delayed response here. ivy-gardener should be able to fix your linting errors. As mentioned in the previous review, could you please update the test to use _statistical_dtype_values to generate the values. Ideally the test should look exactly the same as the corresponding frontend function -- the test for numpy frontend var function is present in /workspaces/ivy/ivy_tests/test_ivy/test_frontends/test_numpy/test_statistics/test_averages_and_variances.py. Happy to clarify any other doubts :)

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 Passed!

@hello-fri-end hello-fri-end changed the title Update ndarray.py Adding np.ndarray.var to the frontends Sep 16, 2023
Copy link
Contributor

@hello-fri-end hello-fri-end left a comment

Choose a reason for hiding this comment

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

Hey @PushpamJha14, left a minor comment. Could you make sure the tests are passing locally after the change? Happy to review once again after you are done. Thanks :)

Comment on lines 727 to 738
def var(
self, axis=None, dtype=None, out=None, ddof=0, keepdims=False, *, where=True
):
return np_frontend.var(
self,
axis=axis,
dtype=dtype,
out=out,
ddof=ddof,
keepdims=keepdims,
where=where,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the tests are failing because they are unable to locate this function (https://github.com/unifyai/ivy/actions/runs/6200453935/job/16835349713?pr=22336#step:3:10495). Could you move this function at bit higher up in the file where other numpy nd.array instance methods are implemented?

@PushpamJha14
Copy link
Contributor Author

image

@hello-fri-end hello-fri-end changed the title Adding np.ndarray.var to the frontends feat: adding np.ndarray.var to the frontends Sep 21, 2023
Copy link
Contributor

@hello-fri-end hello-fri-end left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes @PushpamJha14 ! The tests are failing on the CI but the traceback is empty, I have informed the CI team about this. Have you tried to run the test locally?

@PushpamJha14
Copy link
Contributor Author

image
I am getting this error

@PushpamJha14
Copy link
Contributor Author

Hi, @hello-fri-end I am still getting the same error and warning

Copy link
Contributor

@hello-fri-end hello-fri-end left a comment

Choose a reason for hiding this comment

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

There are no failing tests on the CI, will merge this after ivy-gardener fixes the linting errors. Thanks for your contribution @PushpamJha14

@hello-fri-end hello-fri-end merged commit 2bfb19a into ivy-llc:main Oct 4, 2023
224 of 269 checks passed
druvdub pushed a commit to druvdub/ivy that referenced this pull request Oct 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NumPy Frontend Developing the NumPy Frontend, checklist triggered by commenting add_frontend_checklist
Projects
None yet
Development

Successfully merging this pull request may close these issues.

var
4 participants