-
-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
I made a distribution explorer tool which is based on Annotated type hints which I think would be cool to bring to PyMC eco.
It doesn't have to be done the same way, but Annotated type hints were pretty easy to work and encode arbitrary metadata
from typing import Annotated
Real = Annotated[float, "Real"]
PositiveReal = Annotated[float, "PositiveReal"]
def foo(mu: Real, sigma: PositiveReal):
...
mu_type = foo.__annotations__["mu"] # typing.Annotated[float, 'Real']
mu_type.__metadata__ # ('Real',)In my solution, I didn't tackle different parameterization but I suspect it could be done with a similar approach.
def foo(mu: Real, sigma: Annotated[PositiveReal, 1], tau: Annotated[PositiveReal, 2]):
...
foo.__annotations__
"
{'mu': typing.Annotated[float, 'Real'],
'sigma': typing.Annotated[float, 'PositiveReal', 1],
'tau': typing.Annotated[float, 'PositiveReal', 2]}
"Would love to hear thoughts on this idea!
Metadata
Metadata
Assignees
Labels
No labels