Skip to content

dyce release notes

0.7.0

Breaking changes

Some of the following changes are not backward compatible. Please review before upgrading.

  • Drops support for 3.9 and 3.10 and extends support to 3.14
  • Fixes embarrassingly long-running logical error in 4d6 variants example
  • Removes dyce.r altogether (pending rewrite of an alternative).
  • Adds H.from_counts class method constructs an H from multiple sources.
  • Removes H.map, H.rmap, and H.umap in favor of H.apply.
  • Removes H.is_even and H.is_odd, whose functionality can be trivially reintroduced using H.apply.
  • Removes H.__reversed__.
  • Removes H.vs and H.within.
  • Renames H.accumulate to H.merge.
  • Renames H.distribution to H.probability_items and removes H.distribution_xy.
  • Removes P.map, P.rmap, and P.umap in favor of P.apply_to_each_h.
  • Removes P.is_homogeneous.
  • Adds optional preserve_zero_counts parameter to H.lowest_terms.
  • Adds experimental (and somewhat inefficient) H.replace method.
  • Adds experimental P.apply_to_each_roll method.
  • Simplifies and consolidates dyce.evaluation.expandable and dyce.evaluation.foreach into expand (still experimental).
  • Renames explode to explode_n to be more explicit about the exit criteria.
  • Moves HableOpsMixin to its own module.
  • (Finally!) removes deprecated interfaces
    • H.explode
    • H.foreach
    • H.substitute
    • P.foreach
    • dyce.h.coalesce_replace
    • dyce.h.resolve_dependent_probability
    • dyce.h.sum_h (not previously deprecated, but to-date unused)
  • Modernizes use of beartype with pytest-beartype
  • Completely eliminates dependency on numerary (which was flawed since conception), and instead relies on optype for mathematical operator typing. (H and P still largely assume that outcome types won’t be mixed, but doing so will still probably work in most contexts, so FAAFO.)
  • Re-introduces low-level Matplotlib plotting functions in dyce.viz. (High-level, interactive visualization functionality still lives in anydyce.)
  • Stabilizes Jupyter Lite installation
  • Defaults to collapsed installation cells in notebooks
  • Modernizes setup.cfg -> pyproject.toml (and tox.ini)
  • Updates CI workflow
  • Who let the dogs out? We let dogs out.
  • Migrates to ruff for linting

0.6.2

  • Adds the H.draw convenience method for treating a histogram as a deck rather than a die.

0.6.1

  • Fixes P.total to return 1 for empty pools, consistent with the empty product. (See this explanation).
  • Renames dyce.evaluation._LimitT to dyce.evaluation.LimitT.
  • Fixes issues pertaining to histograms with zero totals after allowing outcomes with zero counts in non-normalized H objects.
  • Fixes issue that would lead to incorrect results when making certain arbitrary selections with heterogeneous pools (e.g., with P.rolls_with_counts).

0.6.0

  • Now requires numerary~=0.4.3.
  • Adds the expandable decorator as well as the foreach and explode convenience functions.
  • Deprecates P.foreach, H.foreach, and H.substitute.
  • Allows outcomes with zero counts in non-normalized H objects. Outcomes with zero counts are dropped when calling H.lowest_terms. Adds the H.zero_fill convenience method.
  • Fixes memoization in Risus multi-round combat translation.
  • Migrates from setuptools_scm to versioningit for more flexible version number formatting.
  • Allows deployments to PyPI from CI based on tags.
  • Uses JupyterLite instead of Binder for examples.
  • Refactors P.is_homogeneous property into a similarly-named method and adds the P.total method property.
  • Removes H.order_stat_func_for_n and instead caches order stat functions for n inside H.order_stat_for_n_at_pos.

0.5.2

  • Updates binder links that fix requirements ranges.

0.5.1

  • Fixes broken binder links in docs.
  • Adds the precision_limit argument to H.substitute and H.explode.

0.5.0

  • Breaks dyce.viz out into anydyce.
  • Removes use of numerary.types.SCU types.
  • Adds the H.foreach and P.foreach class methods.
  • Migrates resolve_dependent_probability to the H.foreach class method.

0.4.5

  • Fixes this bullshit (no, really, I’m serious this time).
  • Adds dyce.r.FilterRoller.
  • Adds dyce.r.SubstitutionRoller.

0.4.4

  • Removes …_gh.png hack now that this dumpster fire is at least partially resolved.
  • Refines Tension Pool example.
  • Adds Ironsworn example.
  • Removes faulty (correctly-derived, but misapplied) math in Risus “Evens Up” example.
  • Adds detail around dependent probabilities.
  • Adds experimental dyce.h.resolve_dependent_probability function.

0.4.3

0.4.2

  • Removes calls to os.get_terminal_size to retain utility in environments without terminals. Fixes #5. Thanks @sudo-simon!!

0.4.1

  • Splits out protocol checking into its own fancy library: numerary!
  • Is now available on PyPI as dyce_, thanks to the generosity of David Eyk!
  • Introduces experimental generic dyce.r.walk function and supporting visitor data structures.
  • Uses pygraphviz to automate class diagram generation. (See the note on special considerations for regenerating class diagrams in the hacking quick start.)
  • Introduces experimental use of numpy for RNG, if present.
  • Migrates to using pyproject.toml and setup.cfg.
  • Adds missing py.typed to ensure clients get type checking. (Whoops.)

0.4.0

Breaking changes

The following changes are not backward compatible. Please review before upgrading.

  • Renames HAbleT and HAbleOpsMixin to HableT and HableOpsMixin. Uses alternate spellings.
  • Removes deprecated non-flattening unary operation methods P.__neg__ and P.__pos__. Uses, e.g., P.umap(operator.__neg__) or P(-h for h in p) instead.
  • Removes deprecated synonym methods H.even and H.odd. Uses H.is_even and H.is_odd instead.
  • Removes deprecated synonym package dyce.plt. Uses dyce.viz instead.
  • Removes special case handling of H({}) for addition and subtraction. Check for code that relied on, e.g., h + H({}) resolving to h. It is probably not correct. If the behavior is desired, consider eliminating empty histograms before performing calculations. E.G., h1 + h2 if h2 else h1.

    See also the sum_h function, which ensures the result is always a histogram:

    1
    2
    3
    4
    5
    >>> from dyce.h import sum_h  # doctest: +SKIP
    >>> sum(())
    0
    >>> sum_h(())  # doctest: +SKIP
    H({})
    

    Note, however, that sums including empty histograms will be always result in empty histograms:

    1
    2
    3
    4
    >>> from dyce import H
    >>> hs = [H(6), H(6), H(6), H({})]
    >>> sum_h(hs)  # doctest: +SKIP
    H({})
    

    If a different result was desired, adapting our advice from above would yield something like:

    1
    2
    >>> sum_h(h for h in hs if h)  # doctest: +SKIP
    H({3: 1, 4: 3, 5: 6, 6: 10, ..., 16: 6, 17: 3, 18: 1})
    

Other changes

  • Documentation overhaul including augmented examples and reorganized images and JavaScript.
  • Fixes H({}).format(width=65) bug.
  • Adds beartype runtime type checking.
  • Maintains support for Python 3.7 (for now).

0.3.2

0.3.1

  • Adds these release notes.
  • Boosts isinstance performance with dyce’s proprietary numeric Protocols.
  • Reinstates support for Python 3.7 (for now).
  • Adds H.is_even and H.is_odd.
  • Deprecates synonym methods H.even and H.odd.
  • Introduces experimental H.total property.
  • Removes incorrectly non-flattening unary operation methods P.__abs__ and P.__invert__.
  • Deprecates non-flattening unary operation methods P.__neg__ and P.__pos__.
  • Renames experimental P.homogeneous property to P.is_homogeneous.
  • Introduces experimental dyce.r.R and dyce.r.Roll primitives.
  • Removes coerce parameter from H.map, H.rmap, and H.umap.
  • Renames dyce.plt to dyce.viz.
  • Deprecates synonym package dyce.plt.

0.3.0

dyce goes beta! Non-experimental features should be considered stable.