-
-
Notifications
You must be signed in to change notification settings - Fork 132
Implementing repeat
function
#875
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
@hameerabbasi Will add tests after your reviews |
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.
Adding tests might reveal some bugs here.
Co-authored-by: Hameer Abbasi <2190658+hameerabbasi@users.noreply.github.com>
CodSpeed Performance ReportMerging #875 will degrade performances by 30.62%Comparing Summary
Benchmarks breakdown
|
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Yes, there were a few bugs, mostly with reshaping. I've removed them and added the tests. Hopefully, this is a correct implementation. The function still doesn't account for uneven repeats. |
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
sparse/numba_backend/_common.py
Outdated
raise TypeError("`a` must be a SparseArray.") | ||
|
||
if not isinstance(repeats, int): | ||
raise Exception("`repeats` must be an integer, uneven repeats are not yet Implemented.") |
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.
raise Exception("`repeats` must be an integer, uneven repeats are not yet Implemented.") | |
raise ValueError("`repeats` must be an integer, uneven repeats are not supported.") |
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.
Is it not possible to implement uneven repeats for sparse arrays? It's not possible via broadcasting, we might have to find a different way.
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.
If it's required by the Array API standard, I'd implement it as follows: Take the ceiling; use the current implementation then truncate to the desired length.
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.
Yes, the standard specifies this: https://data-apis.org/array-api/2024.12/API_specification/generated/array_api.repeat.html#repeat
Should I modify the behaviour in this PR or in future(keeping it as not implemented)?
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 PR is good as the change is related.
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
What type of PR is this? (check all applicable)
Related issues
Checklist
Part of the effort to adhere to array API standards. Similar to np.repeat but for sparse arrays.