Is it worthwhile to alter the module structure to make writing easier like bf.benchmarks._____?

Hi,

I am trying to use the benchmarks submodule but only importing Bayesflow does not call the benchmarks submodule, instead, it has to be imported explicitly. Is it worth changing the structure so that this submodule can be called by just importing Bayesflow?

Code:

import numpy as np
import bayesflow as bf
RNG = np.random.default_rng(2023)
prior_glm = bf.benchmarks.bernoulli_glm.prior(rng=RNG)

Error:

prior_glm = bf.benchmarks.bernoulli_glm.prior(rng=RNG)
^^^^^^^^^^^^^
AttributeError: module ‘bayesflow’ has no attribute ‘benchmarks’

Corrected code:

from bayesflow.benchmarks import bernoulli_glm
import numpy as np

RNG = np.random.default_rng(2023)
prior_glm = bernoulli_glm.prior(rng=RNG)

2 Likes

Good idea, I second it.

Let’s aim to include this (or some equally convenient variation) in the next BayesFlow version.

1 Like