acerbilab / pyvbmc

PyVBMC: Variational Bayesian Monte Carlo algorithm for posterior and model inference in Python
https://acerbilab.github.io/pyvbmc/
BSD 3-Clause "New" or "Revised" License
114 stars 6 forks source link

Spring cleaning #93

Closed Bobby-Huggins closed 2 years ago

Bobby-Huggins commented 2 years ago

This branch introduces some small changes for tidiness and ease-of-use.

  1. Bounds and starting positions passed as 1-D arrays are now coerced to 2-D row vectors (with a warning message), and an error is raised if they cannot be coerced.
  2. Bounds and starting positions are cast to floating point, in case they are passed as integers.
    1. This doesn't effect explicit integer variables (integer_vars), which are represented as floats anyway, but handled separately. It only avoids some erroneous rounding in ParameterTransformer in case something like lb = [1, 2, 3] is passed as input instead of lb = [1., 2., 3.].
  3. Adds timing to active sampling.
    1. Because some timings are repeated at different points in the same iteration, the timer is now cumulative: additional calls to start_timer(key)/stop_timer(key) beyond the first will add to the existing duration of key.
    2. The timer is still manually reset after each iteration, so that iteration_history["timer"][i] contains only the timings for the i^th iteration, as before.
    3. The timer is now shared globally, and can be accessed with from pyvbmc.timer import main_timer. So the timings can be started/stopped from any module without explicitly passing the timer object around.
  4. Replace flatten() with ravel() where there is no danger of reference issues. (flatten always returns a copy, but ravel returns a view in most cases).
  5. Changes assert statements to raise Error.
  6. Tweaks test_viqr and test_vp_optimize to be less prone to fail. Makes noisy_likelihood test faster (by choosing a lower-dimensional problem).
  7. Fixes some minor formatting typos in logging.
  8. Fixes a couple minor TODO's. Most still require further review.
  9. Adds documentation of attributes to VP class.