-
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
refactor(All APIs): Added new pre-commit hook for ordering functions #22830
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 🤗 |
…nctions" This reverts commit 6515e43.
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.
Just came across a few issues while going through the initial files, the same also apply to all files changed. Given that this modifies quite a lot of files, we should take our time and go through all changes made step by step before merging. For a start, could you please try and get the formatter updated according to the suggestions below? Thanks for diving into this @NripeshN, let's see what @KareemMAX thinks 😄
@@ -9,6 +9,26 @@ | |||
from ivy.functional.backends.jax import JaxArray | |||
from ivy.functional.ivy.data_type import _handle_nestable_dtype_info | |||
|
|||
char_rep_dtype_dict = { |
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 think char_rep_dtype_dict
is better placed after ivy_dtype_dict
and native_dtype_dict
@@ -245,6 +180,45 @@ def as_native_dtype( | |||
) | |||
|
|||
|
|||
# Array API Standard # |
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.
The Array API Standard
section should be present before the Extra
section
@@ -15,54 +15,44 @@ | |||
) | |||
|
|||
|
|||
# Helpers # |
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.
Private helpers should always be at the start of the file
@@ -76,6 +66,10 @@ def _to_device(x, device=None): | |||
return x | |||
|
|||
|
|||
# --- Main --- # |
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.
we should rename this section to Extra
if it isn't a part of the Array API Standard
def clear_cached_mem_on_dev(device: str, /): | ||
return None | ||
|
||
|
||
def _dev_is_available(base_dev): | ||
# API # |
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.
API should instead be Array API Standard
return jnp.where(x != 0, x / jnp.abs(x), 0) | ||
|
||
|
||
# --- Main --- # |
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.
Main
should be replaced by Array API Standard
@vedpatwardhan, The formator segregates the file into 2 halves. The first half is helpers and the other half would be Main functions. The headers are |
I couldn't fully follow actually, but the "Array API Standard" header and the "Extras" header are important for us to segregate between functions that are and are not present in the standard as new functions not present in the standard get added on a daily basis. Ideally we shouldn't remove these headers, we should leave them unchanged. So in case we want to sort functions alphabetically, I think we should sort them separately for the functions in the Array API Standard and the Extras sections which would make the structure organized while also retaining the array api and extras distinction. And the Array API Standard header is just an example, we also have different section names like The overall structure I think should be treated as the template while updating the formatter,
Happy to know what you think @NripeshN @KareemMAX, thanks 😄 |
This would mean this ivy-llc/lint-hook#4 is successful