Skip to content
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

Replace "validate" functions with nan for distributions #9

Open
berkay-yalin opened this issue Mar 1, 2024 · 0 comments
Open

Replace "validate" functions with nan for distributions #9

berkay-yalin opened this issue Mar 1, 2024 · 0 comments

Comments

@berkay-yalin
Copy link
Owner

Instead of raising exceptions within the "validate" functions when invalid arguments are used with the distribution functions, the nan value should be returned.

The reasoning behind this decision is to support large scale operations on arrays.

This makes identifying invalid arguments much more difficult, as the current "validate" functions provide detailed descriptions for why the arguments are rejected, so a more effective solution is welcome for discussion.

Example "validate" function, where each distribution function has its separate "validate" function:

def pmf_validate(x: Any, n: Any, p: Any) -> None:
if not isinstance(x, int):
raise TypeError("x must be a non-negative integer")
if x < 0:
raise ValueError("x value out of domain")
if not isinstance(n, int):
raise TypeError("n must be a non-negative integer")
if n < 0:
raise ValueError("n value out of domain")
if not isinstance(p, float):
raise TypeError("p must be non-negative float")
if not 0 <= p <= 1:
raise ValueError("p value out of domain")

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

No branches or pull requests

1 participant