ivy icon indicating copy to clipboard operation
ivy copied to clipboard

split #6104

Open Aniket2002 opened this issue 2 years ago • 6 comments

added split function

Aniket2002 avatar Oct 24 '22 11:10 Aniket2002

Hi! Thanks for the PR!

Mostly looks good, but there are a few things that need to be fixed before this can be merged.

  1. The argument names in our numpy frontend should match the names in the original numpy function exactly. Here is a link to the docs for that original function. https://numpy.org/doc/stable/reference/generated/numpy.split.html
  2. In your implementation, you have the line return ivy.split(a, splits=None, axis=0). This looks like you've tried to set the default arguments to your implementation here, but that should be done in the def ... line for this function. Here's a very short and quick example of what I mean by having the default arguments in the def line.
def f(a=0): 
    return a+2
  1. The test should provide a value for all arguments (including all optional ones), those values should be drawn from as wide of a range as is reasonably possible (while still being valid inputs for the original numpy function), and the names of the arguments as written in the test should also match the names used by the original numpy function. Once the missing splits argument has been added, and once the test passes, this should be good.

Any questions or comments please let me know!

JamieLine avatar Oct 27 '22 14:10 JamieLine

Thanks Jamie, I will look into those points and change the model as soon as possible as I'll be busy for a while now. The deadline would be 7 days from today right?

Aniket2002 avatar Oct 27 '22 14:10 Aniket2002

I think that deadline is just how long until GitHub will mark a PR as stale and delete it, if you keep doing stuff for the PR (it might require comments to be posted or maybe commits count I don't really know) then it won't delete it.

JamieLine avatar Oct 27 '22 19:10 JamieLine

Hi Jamie, I am getting an error due to some line in the torches folder. Do I have to correct it ir can I skip debugging that?

Aniket2002 avatar Oct 29 '22 08:10 Aniket2002

Hi! You don't need to fix the errors caused by the torch folder, but you will need to fix the errors found in your code. The logs will tell you which file and which lines to look at. You'll also need to fix the test, as it tries to pass arguments to your function with different names than the function is expecting.

JamieLine avatar Oct 29 '22 18:10 JamieLine

Hi Jamie, I am getting the following error in the logs: FAILED ivy_tests/test_ivy/test_frontends/test_numpy/test_manipulation_routines/test_splitting_arrays.py::test_numpy_split[cpu-ivy.functional.backends.numpy-False-False-numpy] This same error occurs 4 times with each framework i.e. NumPy, torch, TensorFlow, and Jax. I can't really figure out what to correct in the code so a little guidance would be really helpful

Aniket2002 avatar Nov 01 '22 05:11 Aniket2002

Hi!

Sorry this is so late I've had a few very busy days at Uni. I've had a look and I've worked out what the error is, later on in the error message you get a message saying ValueError: not enough values to unpack (expected 4, got 1). This is because in the @given decorator you generate a value for dtype (which will be a dtype) and then try to unpack 4 different values out of it as if it were a collection. Add a new line to the @given decorator for each argument you wish to generate (so one for ary, indices_or_sections and axis) and add a parameter to the test function itself to accept them. You may wish to use helpers.dtype_and_values to generate a tuple of an array and the data type of that array. This should get the test to start running. Once you get there fixing any errors should be fairly easy.

Hope this helps! Any questions or comments please let me know!

JamieLine avatar Nov 06 '22 01:11 JamieLine

Hi! I am getting this error, is this relevant to us and if it is, how do I remove it: TypeError: 'CompositeStrategy' object is not subscriptable

Aniket2002 avatar Nov 08 '22 06:11 Aniket2002

Hi!

I've found a fix for the error, in the test you pass in a dtype argument to helpers.dtype_and_values, change that to available_dtypes=helpers.get_dtypes(...) and it will work. The dtype argument is expecting a pure dtype, and the available_dtypes argument expects a strategy to generate a dtype.

JamieLine avatar Nov 09 '22 05:11 JamieLine

Hi Jamie I am still encountering an error. Could you please help me

Aniket2002 avatar Nov 15 '22 14:11 Aniket2002

Hi!

What error are you getting? What is the full error text?

Also as this is a front-end function, please update your fork to the most recent version of Ivy and replace the handle_cmd_line_args decorator with the handle_frontend_function decorator.

JamieLine avatar Nov 15 '22 15:11 JamieLine

Hi I cannot find any error message pertaining to my function.

Aniket2002 avatar Nov 16 '22 09:11 Aniket2002

Hi! Please update your fork as there have been some bugs that I believe are now fixed (I know most of them have because I fixed them but I don't know if there are some that I missed). If this doesn't fix your error, please let me know and I'll investigate.

JamieLine avatar Nov 17 '22 16:11 JamieLine

hey Jamie! I got a mail saying that #6104 is now closed as completed from Leaves. What does that mean? Also i am getting this error now ModuleNotFoundError: No module named 'spli' but i havent imported any module like this and have also spell checked the code

Aniket2002 avatar Nov 18 '22 15:11 Aniket2002

Hello Aarsh! Can you please help me with this error: I got a mail saying that https://github.com/unifyai/ivy/issues/6104 is now closed as completed from Leaves. What does that mean? Also i am getting this error now ModuleNotFoundError: No module named 'spli' but i havent imported any module like this and have also spell checked the code

Aniket2002 avatar Nov 20 '22 06:11 Aniket2002

Hi @Aniket2002, I have re-opened the issue. It happened because you didn't use a suitable scheme to reference it when you created an issue. Will have a look into the failures asap !

Aarsh2001 avatar Nov 24 '22 07:11 Aarsh2001

Hi @Aniket2002, I have re-opened the issue. It happened because you didn't use a suitable scheme to reference it when you created an issue. Will have a look into the failures asap !

When will you be replying @Aarsh2001. I'm afraid the PR might turn stale

Aniket2002 avatar Nov 26 '22 17:11 Aniket2002

Hi @Aarsh2001, I am getting this error TypeError: handle_frontend_method() missing 3 required keyword-only arguments: 'class_tree', 'init_tree', and 'method_name' but i dont really have an idea about these parameters Please explain

Aniket2002 avatar Dec 03 '22 09:12 Aniket2002

Hey @Aniket2002, kindly have a look at the docs here

Aarsh2001 avatar Dec 05 '22 12:12 Aarsh2001

@Aniket2002 you should be drawing from hypothesis inside the decorator.

Aarsh2001 avatar Dec 10 '22 08:12 Aarsh2001

Hi @Aarsh2001, I am getting this error hypothesis.errors.InvalidArgument: Expected a SearchStrategy but got mapping['indices_or_sections_ary_axis']=<function accept..array_indices_axis at 0x7fe99e416820> (type=function

Aniket2002 avatar Dec 11 '22 15:12 Aniket2002

Hey @Aniket2002, suggest you start testing the function on your local environment first, also have a look at the check suite errors under Run frontend Tests when you click on details on the test-frontend-numpy below. You are not using positional and keyword arguments correctly for the function. The other suggestion I'd like to make here is for you to go through the array_indices_function docstring, and other functions where this has been used. array_dtypes is not the only argument we should be generating. Here you'll have an idea of what precisely the positional and keyword arguments are. Lastly, I'd suggest you look at how positional and keyword arguments should be passed in functions. Thank You !

Aarsh2001 avatar Dec 18 '22 08:12 Aarsh2001