HARK icon indicating copy to clipboard operation
HARK copied to clipboard

labels argument doesn't work for distribution.expected

Open sbenthall opened this issue 6 months ago • 0 comments

This code:

from HARK.distribution import expected, Normal, DiscreteDistributionLabeled

gamma = DiscreteDistributionLabeled.from_unlabeled(
    Normal(mu= 0, sigma = 1).discretize(**{"N" : 7}), var_names=["gamma"]
)

expected(func=lambda x: x, dist=gamma, labels=True)

Gets this error:

TypeError: <lambda>() got an unexpected keyword argument 'labels'

Even though the labels keyword argument to expected is explicitly supported in the documentation.

    labels : bool
        If True, the function should use labeled indexing instead of integer
        indexing using the distribution's underlying rv coordinates. For example,
        if `dims = ('rv', 'x')` and `coords = {'rv': ['a', 'b'], }`, then
        the function can be `lambda x: x["a"] + x["b"]`.

https://github.com/econ-ark/HARK/blob/master/HARK/distribution.py#L2422

sbenthall avatar Aug 16 '24 21:08 sbenthall