def instantiate_from_specs()

in vihds/parameters.py [0:0]


def instantiate_from_specs(name, specs, cond):
    if "distribution" not in specs:
        print("instantiate_from_specs:: skip instantiate")
        return None

    sd = specs["distribution"]
    if sd == "Normal":
        mu = default_get_value(specs, "mu", 0.0)
        sigma = default_get_value(specs, "sigma", None)
        prec = default_get_value(specs, "prec", None)
        s = {"mu": mu, "sigma": sigma, "prec": prec}
        return DistributionDescription(name, TfNormal, s, conditioning=cond)  # TfNormal(**s)
    if sd == "LogNormal":
        mu = default_get_value(specs, "mu", 0.0)
        sigma = default_get_value(specs, "sigma", None)
        prec = default_get_value(specs, "prec", None)
        s = {"mu": mu, "sigma": sigma, "prec": prec}
        return DistributionDescription(
            name, TfLogNormal, s, conditioning=cond
        )  # TfLogNormal(**s) #mu=float(specs['mu']), scale=float(specs['scale']))
    if sd == "TruncNormal":
        mu = default_get_value(specs, "mu", 0.0)
        sigma = default_get_value(specs, "sigma", None)
        prec = default_get_value(specs, "prec", None)
        a = default_get_value(specs, "a", -np.inf)
        b = default_get_value(specs, "b", np.inf)
        s = {"mu": mu, "sigma": sigma, "prec": prec, "a": a, "b": b}
        return DistributionDescription(
            name, TfTruncatedNormal, s, conditioning=cond
        )  # TfLogNormal(**s) #mu=float(specs['mu']), scale=float(specs['scale']))
    if sd == "Kumaraswamy":
        a = default_get_value(specs, "a", None)
        b = default_get_value(specs, "b", None)
        zmin = default_get_value(specs, "zmin", 0.0)
        zmax = default_get_value(specs, "zmax", 1.0)
        s = {"a": a, "b": b, "zmin": zmin, "zmax": zmax}
        return DistributionDescription(
            name, TfKumaraswamy, s, conditioning=cond
        )  # TfLogNormal(**s) #mu=float(specs['mu']), scale=float(specs['scale']))
    if sd == "Constant":
        value = default_get_value(specs, "value", 0.0)
        s = {"value": value}
        return DistributionDescription(name, TfConstant, s)
    print("instantiate_from_specs:: cannot instantiate %s" % sd)
    return None