Skip to content

Support Fraction probabilities and fix chart rendering for non-float values#15

Merged
koaning merged 1 commit into
mainfrom
koaning/fractions-support
Jun 17, 2026
Merged

Support Fraction probabilities and fix chart rendering for non-float values#15
koaning merged 1 commit into
mainfrom
koaning/fractions-support

Conversation

@koaning

@koaning koaning commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Widens Weight to int | float | Fraction so dice accept exact rational probability weights, and propagates the type through exp/var/p and the internal probability containers (passing basedpyright). A new _plot_value boundary cast lets prob_chart/cdf_chart render Fraction/Decimal outcomes that previously crashed with "not JSON serializable", while leaving Vase string keys untouched. ordered now seeds its accumulators with ints instead of floats so exact Fraction results are preserved (identical math for the float path). Adds a notebook example demonstrating exact probabilities plus tests covering exact arithmetic, Fraction outcomes, ordered exactness, and chart rendering.

🤖 Generated with Claude Code

…values

Widen Weight to int | float | Fraction so dice accept exact rational
probability weights, propagate the type through exp/var/p and the
internal probability containers, and add a _plot_value boundary cast so
prob_chart/cdf_chart render Fraction/Decimal outcomes (string Vase keys
untouched). ordered now seeds its accumulators with ints so exact
Fraction results are preserved. Adds a notebook example and tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@koaning
koaning merged commit beee5a8 into main Jun 17, 2026
2 checks passed
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

Successfully merging this pull request may close these issues.

1 participant