-
Notifications
You must be signed in to change notification settings - Fork 1
Add CI #19
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?
Add CI #19
Conversation
|
@aloctavodia you can see the CI running on my fork juanitorduz#1 The tests |
|
Actually, the changes proposed ensure the test run and they are all green 🟢 🙌 juanitorduz@89581c0 |
| pt.floor((n + 1) * ((alpha - 1) / (alpha + beta - 2))), | ||
| 0, | ||
| n, | ||
| # The standard formula only applies when alpha > 1 and beta > 1 |
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.
In preliz we always return a number for mode. But here, so far, we have been using nan if the value is not unique. Like for uniform distributions. While returning a number can me more convenient it could also be misleading.
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.
ok, reverting in 4e11dc9
| q = pt.as_tensor_variable(q) | ||
|
|
||
| # Create array of all possible values in support | ||
| k_vals = pt.arange(lower, upper + 1) |
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 range is too wide (not sure what is that) we should use bisection.
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.
Btw, no need to decide this one now. We can open an issue and solve it later
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.
ok, this could be an alternative because the original tests were simply not running (not even locally for me)
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.
Here is an alternative (b5352bb)
Summary of changes:
The _should_use_bisection function now checks two conditions:
- Infinite bounds - uses
math.isfinite()on the evaluated values - Range too wide - if
(upper - lower) > 10_000, uses bisection to avoid creating huge arrays
This means:
- BetaBinomial with n=100 → range is 101, uses direct search (fast ✓)
- BetaBinomial with n=100,000 → range is 100,001, uses bisection (avoids memory issues ✓)
- Poisson (unbounded) → uses bisection ✓
The threshold of 10,000 is a reasonable default - large enough for most practical bounded discrete distributions, but small enough to avoid performance/memory issues.
distributions/optimization.py
Outdated
| try: | ||
| lower_t = pt.as_tensor_variable(lower) | ||
| upper_t = pt.as_tensor_variable(upper) | ||
| lower_val = float(lower_t.eval()) |
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 keep everything symbolic.
distributions/optimization.py
Outdated
| Evaluates bounds at graph-build time for constants. | ||
| """ | ||
| try: | ||
| lower_t = pt.as_tensor_variable(lower) |
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 we can safely assume everything is a tensor here, and then other libraries than depend on this one could make other assumptions
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.
So far I have c78a16c . If I do pure symbolic the test keep being stuck ¯\(ツ)/¯
Add CI and some cleaning :)