Skip to content

MAINT Parameters validation for utils.safe_sqr #26833

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

Closed
wants to merge 4 commits into from

Conversation

max-drexler
Copy link

Reference Issues/PRs

Towards #24862

What does this implement/fix? Explain your changes.

  • Added parameter validation to utils.safe_sqr using the validate_params decorator.

@github-actions
Copy link

github-actions bot commented Jul 13, 2023

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 3efa8ca. Link to the linter CI: here

@Micky774 Micky774 added No Changelog Needed Validation related to input validation labels Jul 13, 2023
@adrinjalali
Copy link
Member

I really think for our math functions this is too much of an overhead @jeremiedbb

@Micky774
Copy link
Contributor

Micky774 commented Jul 15, 2023

I really think for our math functions this is too much of an overhead @jeremiedbb

Okay so it looks like it takes about ~100ns to validate if we do an early return with no further computation. For reference, computing safe_sqr for a one-element array runs around (after putting back in the check_array call) ~185ns. The overhead is much less impactful when applying the function for larger arrays.

I think this is an acceptable overhead for where this is used. Is there a particular use case where this results in a meaningful regression? I'm not sure about other math functions though.

@jeremiedbb
Copy link
Member

To me it's not a matter of overhead which is very low even on math functions, but more about functions that are de facto public but should have been made private in the first place. @max-drexler here's a list of the remaining functions to add validation for #24862 (comment). We kind of agreed that we should not add validation for a bunch of function like this one.

@max-drexler
Copy link
Author

Thanks for the feedback. I'll check out one of the remaining functions and open a new request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants