Skip to content

Future-proof helper function with zero handling.#107798

Merged
rhettinger merged 1 commit intopython:mainfrom
rhettinger:sqrtprod_zero
Aug 9, 2023
Merged

Future-proof helper function with zero handling.#107798
rhettinger merged 1 commit intopython:mainfrom
rhettinger:sqrtprod_zero

Conversation

@rhettinger
Copy link
Copy Markdown
Contributor

The ZeroDivisionError was already being caught in correlation(), but it is nicer to handle the zero case inside the helper function.

The ZeroDivisionError was already being caught in correlation(),
but it is nicer to handle the zero case inside the helper function.
@serhiy-storchaka
Copy link
Copy Markdown
Member

Any tests?

What about _sqrtprod(1e-200, 1e-200)? Can an underflow be avoided?

@rhettinger rhettinger merged commit 2fb484e into python:main Aug 9, 2023
@rhettinger rhettinger deleted the sqrtprod_zero branch August 9, 2023 07:44
@rhettinger
Copy link
Copy Markdown
Contributor Author

Any tests?

In the previous PR, there was a script to demonstrate that the results are generally improved. Otherwise, I'm relying on the existing tests for correlation() which does not make any particular promises about accuracy.

What about _sqrtprod(1e-200, 1e-200)? Can an underflow be avoided?

This could be a future improvement. Off-hand I don't see an elegant way to do this without a bunch of conditional logic and rescaling, but I'll put some thought into it. For now, it is on the bottom of my priority list.

@serhiy-storchaka
Copy link
Copy Markdown
Member

I see. Thank you for details.

Could you please include issue number in future PRs title. I sometimes dig through the history of the code and find changes that do not have references to issue. It's very hard to understand the context without it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants