Skip to content

dyce.h package reference

HableT

Bases: Protocol

A protocol whose implementer can be expressed as (or reduced to) an H object by calling its h method. Currently, only the P class implements this protocol, but this affords an integration point for dyce users.

Info

The intended pronunciation of Hable is AYCH-uh-BUL1 (i.e., H-able). Yes, that is a clumsy attempt at verbing. (You could totally H that, dude!) However, if you prefer something else (e.g. HAY-bul or AYCH-AY-bul), no one is going to judge you. (Well, they might, but they shouldn’t.) We all know what you mean.


  1. World Book Online (WBO) style pronunciation respelling

Source code in dyce/h.py
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
@runtime_checkable
class HableT(Protocol, metaclass=CachingProtocolMeta):
    r"""
    A protocol whose implementer can be expressed as (or reduced to) an
    [``H`` object][dyce.h.H] by calling its [``h`` method][dyce.h.HableT.h]. Currently,
    only the [``P`` class][dyce.p.P] implements this protocol, but this affords an
    integration point for ``#!python dyce`` users.

    !!! info

        The intended pronunciation of ``Hable`` is *AYCH-uh-BUL*[^1] (i.e.,
        [``H``][dyce.h.H]-able). Yes, that is a clumsy attempt at
        [verbing](https://www.gocomics.com/calvinandhobbes/1993/01/25). (You could
        *totally* [``H``][dyce.h.H] that, dude!) However, if you prefer something else
        (e.g. *HAY-bul* or *AYCH-AY-bul*), no one is going to judge you. (Well, they
        *might*, but they *shouldn’t*.) We all know what you mean.

    [^1]:

        World Book Online (WBO) style [pronunciation
        respelling](https://en.wikipedia.org/wiki/Pronunciation_respelling_for_English#Traditional_respelling_systems).
    """
    __slots__: Any = ()

    @abstractmethod
    def h(self) -> H:
        r"""
        Express its implementer as an [``H`` object][dyce.h.H].
        """
        pass

__slots__: Any = () class-attribute instance-attribute

h() -> H abstractmethod

Express its implementer as an H object.

Source code in dyce/h.py
1904
1905
1906
1907
1908
1909
@abstractmethod
def h(self) -> H:
    r"""
    Express its implementer as an [``H`` object][dyce.h.H].
    """
    pass

HableOpsMixin

Bases: HableT

A “mix-in” class providing arithmetic operations for implementers of the HableT protocol. The P class derives from this class.

Info

See HableT for notes on pronunciation.

Source code in dyce/h.py
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
class HableOpsMixin(HableT):
    r"""
    A “mix-in” class providing arithmetic operations for implementers of the
    [``HableT`` protocol][dyce.h.HableT]. The [``P`` class][dyce.p.P] derives from this
    class.

    !!! info

        See [``HableT``][dyce.h.HableT] for notes on pronunciation.
    """
    __slots__: Any = ()

    def __init__(self):
        object.__init__(self)

    @beartype
    def __add__(self: HableT, other: _OperandT) -> H:
        r"""
        Shorthand for ``#!python operator.__add__(self.h(), other)``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __add__(self.h(), other)

    @beartype
    def __radd__(self: HableT, other: RealLike) -> H:
        r"""
        Shorthand for ``#!python operator.__add__(other, self.h())``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __add__(other, self.h())

    @beartype
    def __sub__(self: HableT, other: _OperandT) -> H:
        r"""
        Shorthand for ``#!python operator.__sub__(self.h(), other)``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __sub__(self.h(), other)

    @beartype
    def __rsub__(self: HableT, other: RealLike) -> H:
        r"""
        Shorthand for ``#!python operator.__sub__(other, self.h())``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __sub__(other, self.h())

    @beartype
    def __mul__(self: HableT, other: _OperandT) -> H:
        r"""
        Shorthand for ``#!python operator.__mul__(self.h(), other)``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __mul__(self.h(), other)

    @beartype
    def __rmul__(self: HableT, other: RealLike) -> H:
        r"""
        Shorthand for ``#!python operator.__mul__(other, self.h())``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __mul__(other, self.h())

    @beartype
    def __truediv__(self: HableT, other: _OperandT) -> H:
        r"""
        Shorthand for ``#!python operator.__truediv__(self.h(), other)``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __truediv__(self.h(), other)

    @beartype
    def __rtruediv__(self: HableT, other: RealLike) -> H:
        r"""
        Shorthand for ``#!python operator.__truediv__(other, self.h())``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __truediv__(other, self.h())

    @beartype
    def __floordiv__(self: HableT, other: _OperandT) -> H:
        r"""
        Shorthand for ``#!python operator.__floordiv__(self.h(), other)``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __floordiv__(self.h(), other)

    @beartype
    def __rfloordiv__(self: HableT, other: RealLike) -> H:
        r"""
        Shorthand for ``#!python operator.__floordiv__(other, self.h())``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __floordiv__(other, self.h())

    @beartype
    def __mod__(self: HableT, other: _OperandT) -> H:
        r"""
        Shorthand for ``#!python operator.__mod__(self.h(), other)``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __mod__(self.h(), other)

    @beartype
    def __rmod__(self: HableT, other: RealLike) -> H:
        r"""
        Shorthand for ``#!python operator.__mod__(other, self.h())``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __mod__(other, self.h())

    @beartype
    def __pow__(self: HableT, other: _OperandT) -> H:
        r"""
        Shorthand for ``#!python operator.__pow__(self.h(), other)``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __pow__(self.h(), other)

    @beartype
    def __rpow__(self: HableT, other: RealLike) -> H:
        r"""
        Shorthand for ``#!python operator.__pow__(other, self.h())``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __pow__(other, self.h())

    @beartype
    def __and__(self: HableT, other: Union[SupportsInt, H, HableT]) -> H:
        r"""
        Shorthand for ``#!python operator.__and__(self.h(), other)``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __and__(self.h(), other)

    @beartype
    def __rand__(self: HableT, other: SupportsInt) -> H:
        r"""
        Shorthand for ``#!python operator.__and__(other, self.h())``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __and__(other, self.h())

    @beartype
    def __xor__(self: HableT, other: Union[SupportsInt, H, HableT]) -> H:
        r"""
        Shorthand for ``#!python operator.__xor__(self.h(), other)``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __xor__(self.h(), other)

    @beartype
    def __rxor__(self: HableT, other: SupportsInt) -> H:
        r"""
        Shorthand for ``#!python operator.__xor__(other, self.h())``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __xor__(other, self.h())

    @beartype
    def __or__(self: HableT, other: Union[SupportsInt, H, HableT]) -> H:
        r"""
        Shorthand for ``#!python operator.__or__(self.h(), other)``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __or__(self.h(), other)

    @beartype
    def __ror__(self: HableT, other: SupportsInt) -> H:
        r"""
        Shorthand for ``#!python operator.__or__(other, self.h())``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __or__(other, self.h())

    @beartype
    def __neg__(self: HableT) -> H:
        r"""
        Shorthand for ``#!python operator.__neg__(self.h())``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __neg__(self.h())

    @beartype
    def __pos__(self: HableT) -> H:
        r"""
        Shorthand for ``#!python operator.__pos__(self.h())``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __pos__(self.h())

    @beartype
    def __abs__(self: HableT) -> H:
        r"""
        Shorthand for ``#!python operator.__abs__(self.h())``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __abs__(self.h())

    @beartype
    def __invert__(self: HableT) -> H:
        r"""
        Shorthand for ``#!python operator.__invert__(self.h())``. See the
        [``h`` method][dyce.h.HableT.h].
        """
        return __invert__(self.h())

    @beartype
    def lt(self: HableT, other: _OperandT) -> H:
        r"""
        Shorthand for ``#!python self.h().lt(other)``. See the
        [``h`` method][dyce.h.HableT.h] and [``H.lt``][dyce.h.H.lt].
        """
        return self.h().lt(other)

    @beartype
    def le(self: HableT, other: _OperandT) -> H:
        r"""
        Shorthand for ``#!python self.h().le(other)``. See the
        [``h`` method][dyce.h.HableT.h] and [``H.le``][dyce.h.H.le].
        """
        return self.h().le(other)

    @beartype
    def eq(self: HableT, other: _OperandT) -> H:
        r"""
        Shorthand for ``#!python self.h().eq(other)``. See the
        [``h`` method][dyce.h.HableT.h] and [``H.eq``][dyce.h.H.eq].
        """
        return self.h().eq(other)

    @beartype
    def ne(self: HableT, other: _OperandT) -> H:
        r"""
        Shorthand for ``#!python self.h().ne(other)``. See the
        [``h`` method][dyce.h.HableT.h] and [``H.ne``][dyce.h.H.ne].
        """
        return self.h().ne(other)

    @beartype
    def gt(self: HableT, other: _OperandT) -> H:
        r"""
        Shorthand for ``#!python self.h().gt(other)``. See the
        [``h`` method][dyce.h.HableT.h] and [``H.gt``][dyce.h.H.gt].
        """
        return self.h().gt(other)

    @beartype
    def ge(self: HableT, other: _OperandT) -> H:
        r"""
        Shorthand for ``#!python self.h().ge(other)``. See the
        [``h`` method][dyce.h.HableT.h] and [``H.ge``][dyce.h.H.ge].
        """
        return self.h().ge(other)

    @beartype
    def is_even(self: HableT) -> H:
        r"""
        Shorthand for ``#!python self.h().is_even()``. See the
        [``h`` method][dyce.h.HableT.h] and [``H.is_even``][dyce.h.H.is_even].
        """
        return self.h().is_even()

    @beartype
    def is_odd(self: HableT) -> H:
        r"""
        Shorthand for ``#!python self.h().is_odd()``. See the
        [``h`` method][dyce.h.HableT.h] and [``H.is_odd``][dyce.h.H.is_odd].
        """
        return self.h().is_odd()

    @overload
    def explode(
        self: HableT,
        max_depth: IntegralLike,
        precision_limit: None = None,
    ) -> H:
        ...

    @overload
    def explode(
        self: HableT,
        max_depth: None,
        precision_limit: Union[RationalLikeMixedU, RealLike],
    ) -> H:
        ...

    @overload
    def explode(
        self: HableT,
        max_depth: None = None,
        *,
        precision_limit: Union[RationalLikeMixedU, RealLike],
    ) -> H:
        ...

    @overload
    def explode(
        self: HableT,
        max_depth: None = None,
        precision_limit: None = None,
    ) -> H:
        ...

    @beartype
    def explode(
        self: HableT,
        max_depth: Optional[IntegralLike] = None,
        precision_limit: Optional[Union[RationalLikeMixedU, RealLike]] = None,
    ) -> H:
        r"""
        Shorthand for ``#!python self.h().explode(max_depth, precision_limit)``. See the
        [``h`` method][dyce.h.HableT.h] and [``H.explode``][dyce.h.H.explode].
        """
        if max_depth is not None and precision_limit is not None:
            raise ValueError("only one of max_depth and precision_limit is allowed")
        elif max_depth is not None:
            return self.h().explode(max_depth)
        elif precision_limit is not None:
            return self.h().explode(precision_limit=precision_limit)
        else:
            return self.h().explode()

    @overload
    def substitute(
        self: HableT,
        expand: _SubstituteExpandCallbackT,
        coalesce: _SubstituteCoalesceCallbackT = coalesce_replace,
        *,
        max_depth: IntegralLike,
        precision_limit: None = None,
    ) -> H:
        ...

    @overload
    def substitute(
        self: HableT,
        expand: _SubstituteExpandCallbackT,
        coalesce: _SubstituteCoalesceCallbackT,
        max_depth: IntegralLike,
        precision_limit: None = None,
    ) -> H:
        ...

    @overload
    def substitute(
        self: HableT,
        expand: _SubstituteExpandCallbackT,
        coalesce: _SubstituteCoalesceCallbackT = coalesce_replace,
        *,
        max_depth: None,
        precision_limit: Union[RationalLikeMixedU, RealLike],
    ) -> H:
        ...

    @overload
    def substitute(
        self: HableT,
        expand: _SubstituteExpandCallbackT,
        coalesce: _SubstituteCoalesceCallbackT,
        max_depth: None,
        precision_limit: Union[RationalLikeMixedU, RealLike],
    ) -> H:
        ...

    @overload
    def substitute(
        self: HableT,
        expand: _SubstituteExpandCallbackT,
        coalesce: _SubstituteCoalesceCallbackT = coalesce_replace,
        max_depth: None = None,
        *,
        precision_limit: Union[RationalLikeMixedU, RealLike],
    ) -> H:
        ...

    @overload
    def substitute(
        self: HableT,
        expand: _SubstituteExpandCallbackT,
        coalesce: _SubstituteCoalesceCallbackT = coalesce_replace,
        max_depth: None = None,
        precision_limit: None = None,
    ) -> H:
        ...

    @deprecated
    @beartype
    def substitute(
        self: HableT,
        expand: _SubstituteExpandCallbackT,
        coalesce: _SubstituteCoalesceCallbackT = coalesce_replace,
        max_depth: Optional[IntegralLike] = None,
        precision_limit: Optional[Union[RationalLikeMixedU, RealLike]] = None,
    ) -> H:
        r"""
        !!! warning "Deprecated"

            This method has been deprecated and will be removed in a future release. See
            the [``expandable`` decorator][dyce.evaluation.expandable] and
            [``foreach`` function][dyce.evaluation.foreach] for more flexible
            alternatives.

        Shorthand for ``#!python self.h().substitute(expand, coalesce, max_depth)``. See the
        [``h`` method][dyce.h.HableT.h] and [``H.substitute``][dyce.h.H.substitute].
        """
        if max_depth is not None and precision_limit is not None:
            raise ValueError("only one of max_depth and precision_limit is allowed")
        elif max_depth is not None:
            return self.h().substitute(expand, coalesce, max_depth)
        elif precision_limit is not None:
            return self.h().substitute(
                expand, coalesce, precision_limit=precision_limit
            )
        else:
            return self.h().substitute(expand, coalesce)

    @beartype
    def within(self: HableT, lo: RealLike, hi: RealLike, other: _OperandT = 0) -> H:
        r"""
        Shorthand for ``#!python self.h().within(lo, hi, other)``. See the
        [``h`` method][dyce.h.HableT.h] and [``H.within``][dyce.h.H.within].
        """
        return self.h().within(lo, hi, other)

__slots__: Any = () class-attribute instance-attribute

__abs__() -> H

Shorthand for operator.__abs__(self.h()). See the h method.

Source code in dyce/h.py
2103
2104
2105
2106
2107
2108
2109
@beartype
def __abs__(self: HableT) -> H:
    r"""
    Shorthand for ``#!python operator.__abs__(self.h())``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __abs__(self.h())

__add__(other: _OperandT) -> H

Shorthand for operator.__add__(self.h(), other). See the h method.

Source code in dyce/h.py
1927
1928
1929
1930
1931
1932
1933
@beartype
def __add__(self: HableT, other: _OperandT) -> H:
    r"""
    Shorthand for ``#!python operator.__add__(self.h(), other)``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __add__(self.h(), other)

__and__(other: Union[SupportsInt, H, HableT]) -> H

Shorthand for operator.__and__(self.h(), other). See the h method.

Source code in dyce/h.py
2039
2040
2041
2042
2043
2044
2045
@beartype
def __and__(self: HableT, other: Union[SupportsInt, H, HableT]) -> H:
    r"""
    Shorthand for ``#!python operator.__and__(self.h(), other)``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __and__(self.h(), other)

__floordiv__(other: _OperandT) -> H

Shorthand for operator.__floordiv__(self.h(), other). See the h method.

Source code in dyce/h.py
1991
1992
1993
1994
1995
1996
1997
@beartype
def __floordiv__(self: HableT, other: _OperandT) -> H:
    r"""
    Shorthand for ``#!python operator.__floordiv__(self.h(), other)``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __floordiv__(self.h(), other)

__init__()

Source code in dyce/h.py
1924
1925
def __init__(self):
    object.__init__(self)

__invert__() -> H

Shorthand for operator.__invert__(self.h()). See the h method.

Source code in dyce/h.py
2111
2112
2113
2114
2115
2116
2117
@beartype
def __invert__(self: HableT) -> H:
    r"""
    Shorthand for ``#!python operator.__invert__(self.h())``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __invert__(self.h())

__mod__(other: _OperandT) -> H

Shorthand for operator.__mod__(self.h(), other). See the h method.

Source code in dyce/h.py
2007
2008
2009
2010
2011
2012
2013
@beartype
def __mod__(self: HableT, other: _OperandT) -> H:
    r"""
    Shorthand for ``#!python operator.__mod__(self.h(), other)``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __mod__(self.h(), other)

__mul__(other: _OperandT) -> H

Shorthand for operator.__mul__(self.h(), other). See the h method.

Source code in dyce/h.py
1959
1960
1961
1962
1963
1964
1965
@beartype
def __mul__(self: HableT, other: _OperandT) -> H:
    r"""
    Shorthand for ``#!python operator.__mul__(self.h(), other)``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __mul__(self.h(), other)

__neg__() -> H

Shorthand for operator.__neg__(self.h()). See the h method.

Source code in dyce/h.py
2087
2088
2089
2090
2091
2092
2093
@beartype
def __neg__(self: HableT) -> H:
    r"""
    Shorthand for ``#!python operator.__neg__(self.h())``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __neg__(self.h())

__or__(other: Union[SupportsInt, H, HableT]) -> H

Shorthand for operator.__or__(self.h(), other). See the h method.

Source code in dyce/h.py
2071
2072
2073
2074
2075
2076
2077
@beartype
def __or__(self: HableT, other: Union[SupportsInt, H, HableT]) -> H:
    r"""
    Shorthand for ``#!python operator.__or__(self.h(), other)``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __or__(self.h(), other)

__pos__() -> H

Shorthand for operator.__pos__(self.h()). See the h method.

Source code in dyce/h.py
2095
2096
2097
2098
2099
2100
2101
@beartype
def __pos__(self: HableT) -> H:
    r"""
    Shorthand for ``#!python operator.__pos__(self.h())``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __pos__(self.h())

__pow__(other: _OperandT) -> H

Shorthand for operator.__pow__(self.h(), other). See the h method.

Source code in dyce/h.py
2023
2024
2025
2026
2027
2028
2029
@beartype
def __pow__(self: HableT, other: _OperandT) -> H:
    r"""
    Shorthand for ``#!python operator.__pow__(self.h(), other)``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __pow__(self.h(), other)

__radd__(other: RealLike) -> H

Shorthand for operator.__add__(other, self.h()). See the h method.

Source code in dyce/h.py
1935
1936
1937
1938
1939
1940
1941
@beartype
def __radd__(self: HableT, other: RealLike) -> H:
    r"""
    Shorthand for ``#!python operator.__add__(other, self.h())``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __add__(other, self.h())

__rand__(other: SupportsInt) -> H

Shorthand for operator.__and__(other, self.h()). See the h method.

Source code in dyce/h.py
2047
2048
2049
2050
2051
2052
2053
@beartype
def __rand__(self: HableT, other: SupportsInt) -> H:
    r"""
    Shorthand for ``#!python operator.__and__(other, self.h())``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __and__(other, self.h())

__rfloordiv__(other: RealLike) -> H

Shorthand for operator.__floordiv__(other, self.h()). See the h method.

Source code in dyce/h.py
1999
2000
2001
2002
2003
2004
2005
@beartype
def __rfloordiv__(self: HableT, other: RealLike) -> H:
    r"""
    Shorthand for ``#!python operator.__floordiv__(other, self.h())``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __floordiv__(other, self.h())

__rmod__(other: RealLike) -> H

Shorthand for operator.__mod__(other, self.h()). See the h method.

Source code in dyce/h.py
2015
2016
2017
2018
2019
2020
2021
@beartype
def __rmod__(self: HableT, other: RealLike) -> H:
    r"""
    Shorthand for ``#!python operator.__mod__(other, self.h())``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __mod__(other, self.h())

__rmul__(other: RealLike) -> H

Shorthand for operator.__mul__(other, self.h()). See the h method.

Source code in dyce/h.py
1967
1968
1969
1970
1971
1972
1973
@beartype
def __rmul__(self: HableT, other: RealLike) -> H:
    r"""
    Shorthand for ``#!python operator.__mul__(other, self.h())``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __mul__(other, self.h())

__ror__(other: SupportsInt) -> H

Shorthand for operator.__or__(other, self.h()). See the h method.

Source code in dyce/h.py
2079
2080
2081
2082
2083
2084
2085
@beartype
def __ror__(self: HableT, other: SupportsInt) -> H:
    r"""
    Shorthand for ``#!python operator.__or__(other, self.h())``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __or__(other, self.h())

__rpow__(other: RealLike) -> H

Shorthand for operator.__pow__(other, self.h()). See the h method.

Source code in dyce/h.py
2031
2032
2033
2034
2035
2036
2037
@beartype
def __rpow__(self: HableT, other: RealLike) -> H:
    r"""
    Shorthand for ``#!python operator.__pow__(other, self.h())``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __pow__(other, self.h())

__rsub__(other: RealLike) -> H

Shorthand for operator.__sub__(other, self.h()). See the h method.

Source code in dyce/h.py
1951
1952
1953
1954
1955
1956
1957
@beartype
def __rsub__(self: HableT, other: RealLike) -> H:
    r"""
    Shorthand for ``#!python operator.__sub__(other, self.h())``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __sub__(other, self.h())

__rtruediv__(other: RealLike) -> H

Shorthand for operator.__truediv__(other, self.h()). See the h method.

Source code in dyce/h.py
1983
1984
1985
1986
1987
1988
1989
@beartype
def __rtruediv__(self: HableT, other: RealLike) -> H:
    r"""
    Shorthand for ``#!python operator.__truediv__(other, self.h())``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __truediv__(other, self.h())

__rxor__(other: SupportsInt) -> H

Shorthand for operator.__xor__(other, self.h()). See the h method.

Source code in dyce/h.py
2063
2064
2065
2066
2067
2068
2069
@beartype
def __rxor__(self: HableT, other: SupportsInt) -> H:
    r"""
    Shorthand for ``#!python operator.__xor__(other, self.h())``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __xor__(other, self.h())

__sub__(other: _OperandT) -> H

Shorthand for operator.__sub__(self.h(), other). See the h method.

Source code in dyce/h.py
1943
1944
1945
1946
1947
1948
1949
@beartype
def __sub__(self: HableT, other: _OperandT) -> H:
    r"""
    Shorthand for ``#!python operator.__sub__(self.h(), other)``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __sub__(self.h(), other)

__truediv__(other: _OperandT) -> H

Shorthand for operator.__truediv__(self.h(), other). See the h method.

Source code in dyce/h.py
1975
1976
1977
1978
1979
1980
1981
@beartype
def __truediv__(self: HableT, other: _OperandT) -> H:
    r"""
    Shorthand for ``#!python operator.__truediv__(self.h(), other)``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __truediv__(self.h(), other)

__xor__(other: Union[SupportsInt, H, HableT]) -> H

Shorthand for operator.__xor__(self.h(), other). See the h method.

Source code in dyce/h.py
2055
2056
2057
2058
2059
2060
2061
@beartype
def __xor__(self: HableT, other: Union[SupportsInt, H, HableT]) -> H:
    r"""
    Shorthand for ``#!python operator.__xor__(self.h(), other)``. See the
    [``h`` method][dyce.h.HableT.h].
    """
    return __xor__(self.h(), other)

eq(other: _OperandT) -> H

Shorthand for self.h().eq(other). See the h method and H.eq.

Source code in dyce/h.py
2135
2136
2137
2138
2139
2140
2141
@beartype
def eq(self: HableT, other: _OperandT) -> H:
    r"""
    Shorthand for ``#!python self.h().eq(other)``. See the
    [``h`` method][dyce.h.HableT.h] and [``H.eq``][dyce.h.H.eq].
    """
    return self.h().eq(other)

explode(max_depth: Optional[IntegralLike] = None, precision_limit: Optional[Union[RationalLikeMixedU, RealLike]] = None) -> H

Shorthand for self.h().explode(max_depth, precision_limit). See the h method and H.explode.

Source code in dyce/h.py
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
@beartype
def explode(
    self: HableT,
    max_depth: Optional[IntegralLike] = None,
    precision_limit: Optional[Union[RationalLikeMixedU, RealLike]] = None,
) -> H:
    r"""
    Shorthand for ``#!python self.h().explode(max_depth, precision_limit)``. See the
    [``h`` method][dyce.h.HableT.h] and [``H.explode``][dyce.h.H.explode].
    """
    if max_depth is not None and precision_limit is not None:
        raise ValueError("only one of max_depth and precision_limit is allowed")
    elif max_depth is not None:
        return self.h().explode(max_depth)
    elif precision_limit is not None:
        return self.h().explode(precision_limit=precision_limit)
    else:
        return self.h().explode()

ge(other: _OperandT) -> H

Shorthand for self.h().ge(other). See the h method and H.ge.

Source code in dyce/h.py
2159
2160
2161
2162
2163
2164
2165
@beartype
def ge(self: HableT, other: _OperandT) -> H:
    r"""
    Shorthand for ``#!python self.h().ge(other)``. See the
    [``h`` method][dyce.h.HableT.h] and [``H.ge``][dyce.h.H.ge].
    """
    return self.h().ge(other)

gt(other: _OperandT) -> H

Shorthand for self.h().gt(other). See the h method and H.gt.

Source code in dyce/h.py
2151
2152
2153
2154
2155
2156
2157
@beartype
def gt(self: HableT, other: _OperandT) -> H:
    r"""
    Shorthand for ``#!python self.h().gt(other)``. See the
    [``h`` method][dyce.h.HableT.h] and [``H.gt``][dyce.h.H.gt].
    """
    return self.h().gt(other)

is_even() -> H

Shorthand for self.h().is_even(). See the h method and H.is_even.

Source code in dyce/h.py
2167
2168
2169
2170
2171
2172
2173
@beartype
def is_even(self: HableT) -> H:
    r"""
    Shorthand for ``#!python self.h().is_even()``. See the
    [``h`` method][dyce.h.HableT.h] and [``H.is_even``][dyce.h.H.is_even].
    """
    return self.h().is_even()

is_odd() -> H

Shorthand for self.h().is_odd(). See the h method and H.is_odd.

Source code in dyce/h.py
2175
2176
2177
2178
2179
2180
2181
@beartype
def is_odd(self: HableT) -> H:
    r"""
    Shorthand for ``#!python self.h().is_odd()``. See the
    [``h`` method][dyce.h.HableT.h] and [``H.is_odd``][dyce.h.H.is_odd].
    """
    return self.h().is_odd()

le(other: _OperandT) -> H

Shorthand for self.h().le(other). See the h method and H.le.

Source code in dyce/h.py
2127
2128
2129
2130
2131
2132
2133
@beartype
def le(self: HableT, other: _OperandT) -> H:
    r"""
    Shorthand for ``#!python self.h().le(other)``. See the
    [``h`` method][dyce.h.HableT.h] and [``H.le``][dyce.h.H.le].
    """
    return self.h().le(other)

lt(other: _OperandT) -> H

Shorthand for self.h().lt(other). See the h method and H.lt.

Source code in dyce/h.py
2119
2120
2121
2122
2123
2124
2125
@beartype
def lt(self: HableT, other: _OperandT) -> H:
    r"""
    Shorthand for ``#!python self.h().lt(other)``. See the
    [``h`` method][dyce.h.HableT.h] and [``H.lt``][dyce.h.H.lt].
    """
    return self.h().lt(other)

ne(other: _OperandT) -> H

Shorthand for self.h().ne(other). See the h method and H.ne.

Source code in dyce/h.py
2143
2144
2145
2146
2147
2148
2149
@beartype
def ne(self: HableT, other: _OperandT) -> H:
    r"""
    Shorthand for ``#!python self.h().ne(other)``. See the
    [``h`` method][dyce.h.HableT.h] and [``H.ne``][dyce.h.H.ne].
    """
    return self.h().ne(other)

substitute(expand: _SubstituteExpandCallbackT, coalesce: _SubstituteCoalesceCallbackT = coalesce_replace, max_depth: Optional[IntegralLike] = None, precision_limit: Optional[Union[RationalLikeMixedU, RealLike]] = None) -> H

Deprecated

This method has been deprecated and will be removed in a future release. See the expandable decorator and foreach function for more flexible alternatives.

Shorthand for self.h().substitute(expand, coalesce, max_depth). See the h method and H.substitute.

Source code in dyce/h.py
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
@deprecated
@beartype
def substitute(
    self: HableT,
    expand: _SubstituteExpandCallbackT,
    coalesce: _SubstituteCoalesceCallbackT = coalesce_replace,
    max_depth: Optional[IntegralLike] = None,
    precision_limit: Optional[Union[RationalLikeMixedU, RealLike]] = None,
) -> H:
    r"""
    !!! warning "Deprecated"

        This method has been deprecated and will be removed in a future release. See
        the [``expandable`` decorator][dyce.evaluation.expandable] and
        [``foreach`` function][dyce.evaluation.foreach] for more flexible
        alternatives.

    Shorthand for ``#!python self.h().substitute(expand, coalesce, max_depth)``. See the
    [``h`` method][dyce.h.HableT.h] and [``H.substitute``][dyce.h.H.substitute].
    """
    if max_depth is not None and precision_limit is not None:
        raise ValueError("only one of max_depth and precision_limit is allowed")
    elif max_depth is not None:
        return self.h().substitute(expand, coalesce, max_depth)
    elif precision_limit is not None:
        return self.h().substitute(
            expand, coalesce, precision_limit=precision_limit
        )
    else:
        return self.h().substitute(expand, coalesce)

within(lo: RealLike, hi: RealLike, other: _OperandT = 0) -> H

Shorthand for self.h().within(lo, hi, other). See the h method and H.within.

Source code in dyce/h.py
2329
2330
2331
2332
2333
2334
2335
@beartype
def within(self: HableT, lo: RealLike, hi: RealLike, other: _OperandT = 0) -> H:
    r"""
    Shorthand for ``#!python self.h().within(lo, hi, other)``. See the
    [``h`` method][dyce.h.HableT.h] and [``H.within``][dyce.h.H.within].
    """
    return self.h().within(lo, hi, other)

coalesce_replace(h: H, outcome: RealLike) -> H

Deprecated

This function has been deprecated and will be removed in a future release. See the expandable decorator and foreach function for more flexible alternatives.

Default behavior for H.substitute. Returns h unmodified (outcome is ignored).

Source code in dyce/h.py
107
108
109
110
111
112
113
114
115
116
117
118
119
@deprecated
def coalesce_replace(h: "H", outcome: RealLike) -> "H":
    r"""
    !!! warning "Deprecated"

        This function has been deprecated and will be removed in a future release. See
        the [``expandable`` decorator][dyce.evaluation.expandable] and
        [``foreach`` function][dyce.evaluation.foreach] for more flexible alternatives.

    Default behavior for [``H.substitute``][dyce.h.H.substitute]. Returns *h* unmodified
    (*outcome* is ignored).
    """
    return h

resolve_dependent_probability(dependent_term: Callable[..., HOrOutcomeT], **independent_sources: _SourceT) -> H

Deprecated

This function has been moved to the H.foreach class method. This alias will be removed in a future release.

Shorthand for H.foreach(dependent_term, **independent_sources).

Source code in dyce/h.py
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
@deprecated
def resolve_dependent_probability(
    dependent_term: Callable[..., HOrOutcomeT],
    **independent_sources: _SourceT,
) -> H:
    r"""
    !!! warning "Deprecated"

        This function has been moved to the [``H.foreach``][dyce.h.H.foreach] class
        method. This alias will be removed in a future release.

    Shorthand for ``#!python H.foreach(dependent_term, **independent_sources)``.
    """
    return H.foreach(dependent_term, **independent_sources)

sum_h(hs: Iterable[H])

Shorthand for H({}) if h_sum == 0 else sum(hs).

This is to ensure that summing zero or more histograms always returns a histogram.

Source code in dyce/h.py
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
@beartype
def sum_h(hs: Iterable[H]):
    """
    Shorthand for ``#!python H({}) if h_sum == 0 else sum(hs)``.

    This is to ensure that summing zero or more histograms always returns a histogram.
    """
    h_sum = sum(hs)

    return H({}) if h_sum == 0 else h_sum