From 1383860a21a274ab65ce3674d09059d68adce603 Mon Sep 17 00:00:00 2001 From: Matt Graham Date: Thu, 20 Aug 2020 17:38:17 +0100 Subject: [PATCH] Bumping version and regenerating HTML docs --- docs/docs/adapters.html | 56 +++--- docs/docs/autodiff.html | 4 +- docs/docs/autograd_wrapper.html | 12 +- docs/docs/errors.html | 18 +- docs/docs/index.html | 2 +- docs/docs/integrators.html | 12 +- docs/docs/matrices.html | 328 +++++++++++++------------------- docs/docs/progressbars.html | 88 ++++----- docs/docs/samplers.html | 326 +++++++++++++++++++++++++++---- docs/docs/solvers.html | 14 +- docs/docs/stagers.html | 14 +- docs/docs/states.html | 50 ++--- docs/docs/systems.html | 128 ++++++------- docs/docs/transitions.html | 48 ++--- docs/docs/utils.html | 16 +- docs/index.html | 63 ++++++ setup.py | 2 +- 17 files changed, 725 insertions(+), 456 deletions(-) diff --git a/docs/docs/adapters.html b/docs/docs/adapters.html index 2107d49..a7ef924 100644 --- a/docs/docs/adapters.html +++ b/docs/docs/adapters.html @@ -102,7 +102,7 @@

Module mici.adapters

Expand source code -Browse git +Browse git
"""Methods for adaptively setting algorithmic parameters of transitions."""
 
@@ -276,7 +276,7 @@ 

Module mici.adapters

} init_step_size = ( self._find_and_set_init_step_size(chain_state, system, integrator) - if integrator.step_size is None else integrator.step_size) + ) if self.log_step_size_reg_target is None: adapt_state['log_step_size_reg_target'] = log(10 * init_step_size) else: @@ -317,14 +317,17 @@

Module mici.adapters

""" init_state = state.copy() h_init = system.h(init_state) + if np.isnan(h_init): + raise AdaptationError('Hamiltonian evaluating to NaN at initial state.') integrator.step_size = 1 delta_h_threshold = log(2) for s in range(self.max_init_step_size_iters): try: state = integrator.step(init_state) delta_h = abs(h_init - system.h(state)) - if s == 0: - step_size_too_big = delta_h > delta_h_threshold + if s == 0 or np.isnan(delta_h): + step_size_too_big = ( + np.isnan(delta_h) or delta_h > delta_h_threshold) if (step_size_too_big and delta_h <= delta_h_threshold) or ( not step_size_too_big and delta_h > delta_h_threshold): return integrator.step_size @@ -606,7 +609,7 @@

Classes

Expand source code -Browse git +Browse git
class Adapter(ABC):
     """Abstract adapter for implementing schemes to adapt transition parameters.
@@ -706,7 +709,7 @@ 

Instance variables

Expand source code -Browse git +Browse git
@property
 @abstractmethod
@@ -747,7 +750,7 @@ 

Returns

Expand source code -Browse git +Browse git
@abstractmethod
 def initialize(self, chain_state, transition):
@@ -793,7 +796,7 @@ 

Args

Expand source code -Browse git +Browse git
@abstractmethod
 def update(self, adapt_state, chain_state, trans_stats, transition):
@@ -839,7 +842,7 @@ 

Args

Expand source code -Browse git +Browse git
@abstractmethod
 def finalize(self, adapt_state, transition):
@@ -932,7 +935,7 @@ 

Args

Expand source code -Browse git +Browse git
class DualAveragingStepSizeAdapter(Adapter):
     """Dual averaging integrator step size adapter.
@@ -1019,7 +1022,7 @@ 

Args

} init_step_size = ( self._find_and_set_init_step_size(chain_state, system, integrator) - if integrator.step_size is None else integrator.step_size) + ) if self.log_step_size_reg_target is None: adapt_state['log_step_size_reg_target'] = log(10 * init_step_size) else: @@ -1060,14 +1063,17 @@

Args

""" init_state = state.copy() h_init = system.h(init_state) + if np.isnan(h_init): + raise AdaptationError('Hamiltonian evaluating to NaN at initial state.') integrator.step_size = 1 delta_h_threshold = log(2) for s in range(self.max_init_step_size_iters): try: state = integrator.step(init_state) delta_h = abs(h_init - system.h(state)) - if s == 0: - step_size_too_big = delta_h > delta_h_threshold + if s == 0 or np.isnan(delta_h): + step_size_too_big = ( + np.isnan(delta_h) or delta_h > delta_h_threshold) if (step_size_too_big and delta_h <= delta_h_threshold) or ( not step_size_too_big and delta_h > delta_h_threshold): return integrator.step_size @@ -1152,7 +1158,7 @@

Returns

Expand source code -Browse git +Browse git
def initialize(self, chain_state, transition):
     integrator = transition.integrator
@@ -1164,7 +1170,7 @@ 

Returns

} init_step_size = ( self._find_and_set_init_step_size(chain_state, system, integrator) - if integrator.step_size is None else integrator.step_size) + ) if self.log_step_size_reg_target is None: adapt_state['log_step_size_reg_target'] = log(10 * init_step_size) else: @@ -1200,7 +1206,7 @@

Args

Expand source code -Browse git +Browse git
def update(self, adapt_state, chain_state, trans_stats, transition):
     adapt_state['iter'] += 1
@@ -1242,7 +1248,7 @@ 

Args

Expand source code -Browse git +Browse git
def finalize(self, adapt_state, transition):
     if isinstance(adapt_state, dict):
@@ -1301,7 +1307,7 @@ 

Args

Expand source code -Browse git +Browse git
class OnlineVarianceMetricAdapter(Adapter):
     """Diagonal metric adapter using online variance estimates.
@@ -1448,7 +1454,7 @@ 

Returns

Expand source code -Browse git +Browse git
def initialize(self, chain_state, transition):
     return {
@@ -1485,7 +1491,7 @@ 

Args

Expand source code -Browse git +Browse git
def update(self, adapt_state, chain_state, trans_stats, transition):
     # Use Welford (1962) incremental algorithm to update statistics to
@@ -1523,7 +1529,7 @@ 

Args

Expand source code -Browse git +Browse git
def finalize(self, adapt_state, transition):
     if isinstance(adapt_state, dict):
@@ -1605,7 +1611,7 @@ 

Args

Expand source code -Browse git +Browse git
class OnlineCovarianceMetricAdapter(Adapter):
     """Dense metric adapter using online covariance estimates.
@@ -1755,7 +1761,7 @@ 

Returns

Expand source code -Browse git +Browse git
def initialize(self, chain_state, transition):
     dim_pos = chain_state.pos.shape[0]
@@ -1794,7 +1800,7 @@ 

Args

Expand source code -Browse git +Browse git
def update(self, adapt_state, chain_state, trans_stats, transition):
     # Use Welford (1962) incremental algorithm to update statistics to
@@ -1832,7 +1838,7 @@ 

Args

Expand source code -Browse git +Browse git
def finalize(self, adapt_state, transition):
     if isinstance(adapt_state, dict):
diff --git a/docs/docs/autodiff.html b/docs/docs/autodiff.html
index 37b4e1d..4be6cab 100644
--- a/docs/docs/autodiff.html
+++ b/docs/docs/autodiff.html
@@ -47,7 +47,7 @@ 

Module mici.autodiff

Expand source code -Browse git +Browse git
"""Automatic differentation fallback for constructing derivative functions."""
 
@@ -148,7 +148,7 @@ 

Returns

Expand source code -Browse git +Browse git
def autodiff_fallback(diff_func, func, diff_op_name, name):
     """Generate derivative function automatically if not provided.
diff --git a/docs/docs/autograd_wrapper.html b/docs/docs/autograd_wrapper.html
index a186f16..a4b98d8 100644
--- a/docs/docs/autograd_wrapper.html
+++ b/docs/docs/autograd_wrapper.html
@@ -51,7 +51,7 @@ 

Module mici.autograd_wrapper

Expand source code -Browse git +Browse git
"""Additional autograd differential operators."""
 
@@ -195,7 +195,7 @@ 

Functions

Expand source code -Browse git +Browse git
@_wrapped_unary_to_nary
 def grad_and_value(fun, x):
@@ -220,7 +220,7 @@ 

Functions

Expand source code -Browse git +Browse git
@_wrapped_unary_to_nary
 def jacobian_and_value(fun, x):
@@ -262,7 +262,7 @@ 

Functions

Expand source code -Browse git +Browse git
@_wrapped_unary_to_nary
 def mhp_jacobian_and_value(fun, x):
@@ -300,7 +300,7 @@ 

Functions

Expand source code -Browse git +Browse git
@_wrapped_unary_to_nary
 def hessian_grad_and_value(fun, x):
@@ -342,7 +342,7 @@ 

Functions

Expand source code -Browse git +Browse git
@_wrapped_unary_to_nary
 def mtp_hessian_grad_and_value(fun, x):
diff --git a/docs/docs/errors.html b/docs/docs/errors.html
index 37d2c21..1782a6e 100644
--- a/docs/docs/errors.html
+++ b/docs/docs/errors.html
@@ -70,7 +70,7 @@ 

Module mici.errors

Expand source code -Browse git +Browse git
"""Exception types."""
 
@@ -125,7 +125,7 @@ 

Classes

Expand source code -Browse git +Browse git
class Error(RuntimeError):
     """Base class for errors."""
@@ -153,7 +153,7 @@

Subclasses

Expand source code -Browse git +Browse git
class IntegratorError(Error):
     """Error raised when integrator step fails."""
@@ -181,7 +181,7 @@

Subclasses

Expand source code -Browse git +Browse git
class NonReversibleStepError(IntegratorError):
     """Error raised when integrator step fails reversibility check."""
@@ -204,7 +204,7 @@

Ancestors

Expand source code -Browse git +Browse git
class ConvergenceError(IntegratorError):
     """Error raised when solver fails to converge within allowed iterations."""
@@ -227,7 +227,7 @@

Ancestors

Expand source code -Browse git +Browse git
class LinAlgError(Error):
     """Error raised when a matrix operation raises a linear algebra error."""
@@ -249,7 +249,7 @@

Ancestors

Expand source code -Browse git +Browse git
class HamiltonianDivergenceError(IntegratorError):
     """Error raised when integration of Hamiltonian dynamics diverges."""
@@ -272,7 +272,7 @@

Ancestors

Expand source code -Browse git +Browse git
class AdaptationError(Error):
     """Error raised when adaptation of transition parameters fails."""
@@ -294,7 +294,7 @@

Ancestors

Expand source code -Browse git +Browse git
class ReadOnlyStateError(Error):
     """Error raised when writing to attributes of read-only chain state."""
diff --git a/docs/docs/index.html b/docs/docs/index.html index 5045714..ceec3d1 100644 --- a/docs/docs/index.html +++ b/docs/docs/index.html @@ -55,7 +55,7 @@

Package mici

Expand source code -Browse git +Browse git
# -*- coding: utf-8 -*-
 """ MCMC samplers based on simulating Hamiltonian dynamics on a manifold. """
diff --git a/docs/docs/integrators.html b/docs/docs/integrators.html
index 68e7df4..db41e60 100644
--- a/docs/docs/integrators.html
+++ b/docs/docs/integrators.html
@@ -70,7 +70,7 @@ 

Module mici.integrators

Expand source code -Browse git +Browse git
"""Symplectic integrators for simulation of Hamiltonian dynamics."""
 
@@ -457,7 +457,7 @@ 

Args

Expand source code -Browse git +Browse git
class Integrator(ABC):
     """Base class for integrators."""
@@ -536,7 +536,7 @@ 

Returns

Expand source code -Browse git +Browse git
def step(self, state):
     """Perform a single integrator step from a supplied state.
@@ -588,7 +588,7 @@ 

Args

Expand source code -Browse git +Browse git
class LeapfrogIntegrator(Integrator):
     r"""
@@ -704,7 +704,7 @@ 

Args

Expand source code -Browse git +Browse git
class ImplicitLeapfrogIntegrator(Integrator):
     r"""
@@ -947,7 +947,7 @@ 

Args

Expand source code -Browse git +Browse git
class ConstrainedLeapfrogIntegrator(Integrator):
     r"""
diff --git a/docs/docs/matrices.html b/docs/docs/matrices.html
index 6873140..0de8ec9 100644
--- a/docs/docs/matrices.html
+++ b/docs/docs/matrices.html
@@ -674,6 +674,8 @@
 
  • array
  • transpose
  • T
  • +
  • eigval
  • +
  • eigvec
  • @@ -821,7 +823,7 @@

    Module mici.matrices

    Expand source code -Browse git +Browse git
    """Structured matrix classes implementing basic linear algebra operations."""
     
    @@ -862,12 +864,6 @@ 

    Module mici.matrices

    __array_priority__ = 1 - """Set of attributes required for class to be considered a subclass""" - _required_subclass_attrs = { - 'array', 'shape', 'T', 'diagonal', '__array__', '__mul__', '__rmul__', - '__truediv__', '__neg__', '__matmul__', '__rmatmul__' - } - def __init__(self, shape, **kwargs): """ Args: @@ -1000,25 +996,6 @@

    Module mici.matrices

    def __repr__(self): return type(self).__name__ + str(self) - @classmethod - def _get_required_subclass_attrs(cls): - """Compute set of required subclass attributes.""" - req = set() - for C in cls.__mro__: - if hasattr(C, '_required_subclass_attrs'): - req |= C._required_subclass_attrs - return req - - @classmethod - def __subclasshook__(cls, C): - # Customize isinstance / issubclass behaviour to also return True for - # classes / objects with classes which have all required attributes - # without being direct subclasses - if hasattr(cls, '_get_required_subclass_attrs'): - if all(any(attr in B.__dict__ for B in C.__mro__) - for attr in cls._get_required_subclass_attrs()): - return True - return NotImplemented @abc.abstractmethod def _compute_hash(self): @@ -1162,8 +1139,6 @@

    Module mici.matrices

    class SquareMatrix(Matrix): """Base class for matrices with equal numbers of rows and columns.""" - _required_subclass_attrs = {'log_abs_det'} - def __init__(self, shape, **kwargs): if shape[0] != shape[1]: raise ValueError( @@ -1206,7 +1181,6 @@

    Module mici.matrices

    class InvertibleMatrix(SquareMatrix): """Base class for non-singular square matrices.""" - _required_subclass_attrs = {'inv'} def __init__(self, shape, **kwargs): super().__init__(shape, **kwargs) @@ -1257,8 +1231,6 @@

    Module mici.matrices

    class SymmetricMatrix(SquareMatrix): """Base class for square matrices which are equal to their transpose.""" - _required_subclass_attrs = {'eigval', 'eigvec'} - def __init__(self, shape, **kwargs): self._eigval = None self._eigvec = None @@ -1293,8 +1265,6 @@

    Module mici.matrices

    class PositiveDefiniteMatrix(SymmetricMatrix, InvertibleMatrix): """Base class for positive definite matrices.""" - _required_subclass_attrs = {'sqrt'} - def __init__(self, shape, **kwargs): self._sqrt = None super().__init__(shape, **kwargs) @@ -1411,8 +1381,6 @@

    Module mici.matrices

    same shapes and with the same indices / keys. """ - _required_subclass_attrs = {'grad_log_abs_det', 'grad_quadratic_form_inv'} - @property @abc.abstractmethod def grad_log_abs_det(self): @@ -2503,7 +2471,7 @@

    Module mici.matrices

    return sum(block.log_abs_det for block in self._blocks) -class SymmetricBlockDiagonalMatrix(SquareBlockDiagonalMatrix): +class SymmetricBlockDiagonalMatrix(SquareBlockDiagonalMatrix, SymmetricMatrix): """Symmetric specialisation of `SquareBlockDiagonalMatrix`. All matrix blocks in diagonal are restricted to be symmetric, i.e. @@ -2531,7 +2499,7 @@

    Module mici.matrices

    class PositiveDefiniteBlockDiagonalMatrix( - SymmetricBlockDiagonalMatrix, PositiveDefiniteMatrix, + SquareBlockDiagonalMatrix, PositiveDefiniteMatrix, DifferentiableMatrix): """Positive definite specialisation of `SymmetricBlockDiagonalMatrix`. @@ -2560,6 +2528,9 @@

    Module mici.matrices

    else: return super()._scalar_multiply(scalar) + def _construct_transpose(self): + return self + def _construct_sqrt(self): return SquareBlockDiagonalMatrix( tuple(block.sqrt for block in self._blocks)) @@ -3087,7 +3058,7 @@

    Args

    Expand source code -Browse git +Browse git
    class Matrix(abc.ABC):
         """Base class for matrix-like objects.
    @@ -3099,12 +3070,6 @@ 

    Args

    __array_priority__ = 1 - """Set of attributes required for class to be considered a subclass""" - _required_subclass_attrs = { - 'array', 'shape', 'T', 'diagonal', '__array__', '__mul__', '__rmul__', - '__truediv__', '__neg__', '__matmul__', '__rmatmul__' - } - def __init__(self, shape, **kwargs): """ Args: @@ -3237,25 +3202,6 @@

    Args

    def __repr__(self): return type(self).__name__ + str(self) - @classmethod - def _get_required_subclass_attrs(cls): - """Compute set of required subclass attributes.""" - req = set() - for C in cls.__mro__: - if hasattr(C, '_required_subclass_attrs'): - req |= C._required_subclass_attrs - return req - - @classmethod - def __subclasshook__(cls, C): - # Customize isinstance / issubclass behaviour to also return True for - # classes / objects with classes which have all required attributes - # without being direct subclasses - if hasattr(cls, '_get_required_subclass_attrs'): - if all(any(attr in B.__dict__ for B in C.__mro__) - for attr in cls._get_required_subclass_attrs()): - return True - return NotImplemented @abc.abstractmethod def _compute_hash(self): @@ -3292,7 +3238,7 @@

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def shape(self):
    @@ -3306,7 +3252,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     @abc.abstractmethod
    @@ -3320,7 +3266,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def transpose(self):
    @@ -3336,7 +3282,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def transpose(self):
    @@ -3352,7 +3298,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def diagonal(self):
    @@ -3376,7 +3322,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class ExplicitArrayMatrix(Matrix):
         """Matrix with an explicit array representation."""
    @@ -3426,7 +3372,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def array(self):
    @@ -3465,7 +3411,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class ImplicitArrayMatrix(Matrix):
         """Matrix with an implicit array representation."""
    @@ -3529,7 +3475,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def array(self):
    @@ -3581,7 +3527,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class MatrixProduct(ImplicitArrayMatrix):
         """Matrix implicitly defined as a product of a sequence of matrices.
    @@ -3661,7 +3607,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def matrices(self):
    @@ -3707,13 +3653,11 @@ 

    Args

    Expand source code -Browse git +Browse git
    class SquareMatrix(Matrix):
         """Base class for matrices with equal numbers of rows and columns."""
     
    -    _required_subclass_attrs = {'log_abs_det'}
    -
         def __init__(self, shape, **kwargs):
             if shape[0] != shape[1]:
                 raise ValueError(
    @@ -3752,7 +3696,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     @abc.abstractmethod
    @@ -3806,7 +3750,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class SquareMatrixProduct(MatrixProduct, SquareMatrix):
         """Matrix implicitly defined as a product of a sequence of square matrices.
    @@ -3852,7 +3796,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def log_abs_det(self):
    @@ -3898,12 +3842,11 @@ 

    Args

    Expand source code -Browse git +Browse git
    class InvertibleMatrix(SquareMatrix):
         """Base class for non-singular square matrices."""
     
    -    _required_subclass_attrs = {'inv'}
     
         def __init__(self, shape, **kwargs):
             super().__init__(shape, **kwargs)
    @@ -3968,7 +3911,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def inv(self):
    @@ -4032,7 +3975,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class InvertibleMatrixProduct(SquareMatrixProduct, InvertibleMatrix):
         """Matrix defined as a product of a sequence of invertible matrices.
    @@ -4117,13 +4060,11 @@ 

    Args

    Expand source code -Browse git +Browse git
    class SymmetricMatrix(SquareMatrix):
         """Base class for square matrices which are equal to their transpose."""
     
    -    _required_subclass_attrs = {'eigval', 'eigvec'}
    -
         def __init__(self, shape, **kwargs):
             self._eigval = None
             self._eigvec = None
    @@ -4168,6 +4109,7 @@ 

    Subclasses

  • mici.matrices._BaseTriangularFactoredDefiniteMatrix
  • DenseSymmetricMatrix
  • EigendecomposedSymmetricMatrix
  • +
  • SymmetricBlockDiagonalMatrix
  • SymmetricLowRankUpdateMatrix
  • Instance variables

    @@ -4178,7 +4120,7 @@

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def eigval(self):
    @@ -4194,7 +4136,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def eigvec(self):
    @@ -4213,7 +4155,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def log_abs_det(self):
    @@ -4256,13 +4198,11 @@ 

    Args

    Expand source code -Browse git +Browse git
    class PositiveDefiniteMatrix(SymmetricMatrix, InvertibleMatrix):
         """Base class for positive definite matrices."""
     
    -    _required_subclass_attrs = {'sqrt'}
    -
         def __init__(self, shape, **kwargs):
             self._sqrt = None
             super().__init__(shape, **kwargs)
    @@ -4318,7 +4258,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def sqrt(self):
    @@ -4397,7 +4337,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class IdentityMatrix(PositiveDefiniteMatrix, ImplicitArrayMatrix):
         """Matrix representing identity operator on a vector space.
    @@ -4482,7 +4422,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def eigval(self):
    @@ -4495,7 +4435,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def eigvec(self):
    @@ -4508,7 +4448,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def diagonal(self):
    @@ -4524,7 +4464,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def log_abs_det(self):
    @@ -4594,7 +4534,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class DifferentiableMatrix(InvertibleMatrix):
         """Parameterically defined matrix defining gradient of scalar operations.
    @@ -4620,8 +4560,6 @@ 

    Args

    same shapes and with the same indices / keys. """ - _required_subclass_attrs = {'grad_log_abs_det', 'grad_quadratic_form_inv'} - @property @abc.abstractmethod def grad_log_abs_det(self): @@ -4661,7 +4599,7 @@

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     @abc.abstractmethod
    @@ -4721,7 +4659,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    @abc.abstractmethod
     def grad_quadratic_form_inv(self, vector):
    @@ -4758,7 +4696,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class ScaledIdentityMatrix(
             SymmetricMatrix, DifferentiableMatrix, ImplicitArrayMatrix):
    @@ -4866,7 +4804,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def scalar(self):
    @@ -4880,7 +4818,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def eigval(self):
    @@ -4893,7 +4831,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def eigvec(self):
    @@ -4906,7 +4844,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def diagonal(self):
    @@ -4922,7 +4860,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def log_abs_det(self):
    @@ -4939,7 +4877,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def grad_log_abs_det(self):
    @@ -4987,7 +4925,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    def grad_quadratic_form_inv(self, vector):
         return -np.sum(vector**2) / self._scalar**2
    @@ -5015,7 +4953,7 @@

    Args

    Expand source code -Browse git +Browse git
    class PositiveScaledIdentityMatrix(
             ScaledIdentityMatrix, PositiveDefiniteMatrix):
    @@ -5145,7 +5083,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class DiagonalMatrix(
             SymmetricMatrix, DifferentiableMatrix, ImplicitArrayMatrix):
    @@ -5229,7 +5167,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def diagonal(self):
    @@ -5242,7 +5180,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def eigvec(self):
    @@ -5255,7 +5193,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def eigval(self):
    @@ -5268,7 +5206,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def grad_log_abs_det(self):
    @@ -5323,7 +5261,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    def grad_quadratic_form_inv(self, vector):
         return -(self.inv @ vector)**2
    @@ -5346,7 +5284,7 @@

    Args

    Expand source code -Browse git +Browse git
    class PositiveDiagonalMatrix(DiagonalMatrix, PositiveDefiniteMatrix):
         """Specialisation of `DiagonalMatrix` with positive diagonal parameter.
    @@ -5480,7 +5418,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class TriangularMatrix(InvertibleMatrix, ExplicitArrayMatrix):
         """Matrix with non-zero values only in lower or upper triangle elements."""
    @@ -5542,7 +5480,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def lower(self):
    @@ -5558,7 +5496,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def log_abs_det(self):
    @@ -5620,7 +5558,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class InverseTriangularMatrix(InvertibleMatrix, ImplicitArrayMatrix):
         """Triangular matrix implicitly specified by its inverse."""
    @@ -5709,7 +5647,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def lower(self):
    @@ -5722,7 +5660,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def diagonal(self):
    @@ -5738,7 +5676,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def log_abs_det(self):
    @@ -5807,7 +5745,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class TriangularFactoredDefiniteMatrix(
             _BaseTriangularFactoredDefiniteMatrix, DifferentiableMatrix,
    @@ -5905,7 +5843,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def grad_log_abs_det(self):
    @@ -5972,7 +5910,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    def grad_quadratic_form_inv(self, vector):
         inv_factor_vector = self.factor.inv @ vector
    @@ -6015,7 +5953,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class TriangularFactoredPositiveDefiniteMatrix(
             TriangularFactoredDefiniteMatrix, PositiveDefiniteMatrix):
    @@ -6178,7 +6116,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class DenseDefiniteMatrix(_BaseTriangularFactoredDefiniteMatrix,
                               DifferentiableMatrix, ExplicitArrayMatrix):
    @@ -6266,7 +6204,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def factor(self):
    @@ -6286,7 +6224,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def grad_log_abs_det(self):
    @@ -6353,7 +6291,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    def grad_quadratic_form_inv(self, vector):
         inv_matrix_vector = self.inv @ vector
    @@ -6384,7 +6322,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class DensePositiveDefiniteMatrix(DenseDefiniteMatrix, PositiveDefiniteMatrix):
         """Positive-definite matrix specified by a dense 2D array."""
    @@ -6532,7 +6470,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class DensePositiveDefiniteProductMatrix(DensePositiveDefiniteMatrix):
         """Positive-definite matrix specified as a signed symmetric product.
    @@ -6603,7 +6541,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def grad_log_abs_det(self):
    @@ -6682,7 +6620,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    def grad_quadratic_form_inv(self, vector):
         inv_matrix_vector = self.inv @ vector
    @@ -6718,7 +6656,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class DenseSquareMatrix(InvertibleMatrix, ExplicitArrayMatrix):
         """Dense non-singular square matrix."""
    @@ -6790,7 +6728,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def lu_and_piv(self):
    @@ -6810,7 +6748,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def log_abs_det(self):
    @@ -6873,7 +6811,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class InverseLUFactoredSquareMatrix(InvertibleMatrix, ImplicitArrayMatrix):
         """Square matrix implicitly defined by LU factorisation of inverse."""
    @@ -6956,7 +6894,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def log_abs_det(self):
    @@ -7018,7 +6956,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class DenseSymmetricMatrix(
             SymmetricMatrix, InvertibleMatrix, ExplicitArrayMatrix):
    @@ -7122,7 +7060,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class OrthogonalMatrix(InvertibleMatrix, ExplicitArrayMatrix):
         """Square matrix with columns and rows that are orthogonal unit vectors."""
    @@ -7166,7 +7104,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def log_abs_det(self):
    @@ -7224,7 +7162,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class ScaledOrthogonalMatrix(InvertibleMatrix, ImplicitArrayMatrix):
         """Matrix corresponding to orthogonal matrix multiplied by a scalar.
    @@ -7295,7 +7233,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def diagonal(self):
    @@ -7311,7 +7249,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def log_abs_det(self):
    @@ -7371,7 +7309,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class EigendecomposedSymmetricMatrix(
             SymmetricMatrix, InvertibleMatrix, ImplicitArrayMatrix):
    @@ -7521,7 +7459,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class EigendecomposedPositiveDefiniteMatrix(
             EigendecomposedSymmetricMatrix, PositiveDefiniteMatrix):
    @@ -7650,7 +7588,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class SoftAbsRegularizedPositiveDefiniteMatrix(
             EigendecomposedPositiveDefiniteMatrix, DifferentiableMatrix):
    @@ -7727,7 +7665,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def grad_log_abs_det(self):
    @@ -7796,7 +7734,7 @@ 

    Methods

    Expand source code -Browse git +Browse git
    def softabs(self, x):
         """Smooth approximation to absolute function."""
    @@ -7811,7 +7749,7 @@ 

    Methods

    Expand source code -Browse git +Browse git
    def grad_softabs(self, x):
         """Derivative of smooth approximation to absolute function."""
    @@ -7834,7 +7772,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    def grad_quadratic_form_inv(self, vector):
         num_j_mtx = self.eigval[:, None] - self.eigval[None, :]
    @@ -7863,7 +7801,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class BlockMatrix(ImplicitArrayMatrix):
         """Matrix with non-zero entries defined by a series of submatrix blocks."""
    @@ -7903,7 +7841,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     @abc.abstractmethod
    @@ -7952,7 +7890,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class SquareBlockDiagonalMatrix(InvertibleMatrix, BlockMatrix):
         """Square matrix with non-zero values only in blocks along diagonal."""
    @@ -8039,6 +7977,7 @@ 

    Ancestors

    Subclasses

    Instance variables

    @@ -8048,7 +7987,7 @@

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def blocks(self):
    @@ -8062,7 +8001,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def diagonal(self):
    @@ -8075,7 +8014,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def eigval(self):
    @@ -8088,7 +8027,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def eigvec(self):
    @@ -8105,7 +8044,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def log_abs_det(self):
    @@ -8156,9 +8095,9 @@ 

    Args

    Expand source code -Browse git +Browse git -
    class SymmetricBlockDiagonalMatrix(SquareBlockDiagonalMatrix):
    +
    class SymmetricBlockDiagonalMatrix(SquareBlockDiagonalMatrix, SymmetricMatrix):
         """Symmetric specialisation of `SquareBlockDiagonalMatrix`.
     
         All matrix blocks in diagonal are restricted to be symmetric, i.e.
    @@ -8188,16 +8127,13 @@ 

    Ancestors

    -

    Subclasses

    -

    Instance variables

    var blocks
    @@ -8239,6 +8175,14 @@

    Instance variables

    Transpose of matrix.

    +
    var eigval
    +
    +

    Eigenvalues of matrix as a 1D array.

    +
    +
    var eigvec
    +
    +

    Eigenvectors of matrix stacked as columns of a Matrix object.

    +
    @@ -8258,10 +8202,10 @@

    Args

    Expand source code -Browse git +Browse git
    class PositiveDefiniteBlockDiagonalMatrix(
    -        SymmetricBlockDiagonalMatrix, PositiveDefiniteMatrix,
    +        SquareBlockDiagonalMatrix, PositiveDefiniteMatrix, 
             DifferentiableMatrix):
         """Positive definite specialisation of `SymmetricBlockDiagonalMatrix`.
     
    @@ -8290,6 +8234,9 @@ 

    Args

    else: return super()._scalar_multiply(scalar) + def _construct_transpose(self): + return self + def _construct_sqrt(self): return SquareBlockDiagonalMatrix( tuple(block.sqrt for block in self._blocks)) @@ -8313,7 +8260,6 @@

    Args

    Ancestors

      -
    • SymmetricBlockDiagonalMatrix
    • SquareBlockDiagonalMatrix
    • PositiveDefiniteMatrix
    • SymmetricMatrix
    • @@ -8333,7 +8279,7 @@

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def grad_log_abs_det(self):
      @@ -8415,7 +8361,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      def grad_quadratic_form_inv(self, vector):
           if self.is_differentiable:
      @@ -8443,7 +8389,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class DenseRectangularMatrix(ExplicitArrayMatrix):
           """Dense rectangular matrix."""
      @@ -8507,7 +8453,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class BlockRowMatrix(BlockMatrix):
           """Matrix composed of horizontal concatenation of a series of blocks."""
      @@ -8568,7 +8514,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def blocks(self):
      @@ -8617,7 +8563,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class BlockColumnMatrix(BlockMatrix):
           """Matrix composed of vertical concatenation of a series of blocks."""
      @@ -8678,7 +8624,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def blocks(self):
      @@ -8769,7 +8715,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class SquareLowRankUpdateMatrix(InvertibleMatrix, ImplicitArrayMatrix):
           """Square matrix equal to a low-rank update to a square matrix.
      @@ -8942,7 +8888,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def capacitance_matrix(self):
      @@ -8960,7 +8906,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def diagonal(self):
      @@ -8978,7 +8924,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def log_abs_det(self):
      @@ -9068,7 +9014,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class SymmetricLowRankUpdateMatrix(
               SquareLowRankUpdateMatrix, SymmetricMatrix, InvertibleMatrix):
      @@ -9193,7 +9139,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def capacitance_matrix(self):
      @@ -9306,7 +9252,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class PositiveDefiniteLowRankUpdateMatrix(
               SymmetricLowRankUpdateMatrix, PositiveDefiniteMatrix,
      @@ -9446,7 +9392,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def capacitance_matrix(self):
      @@ -9465,7 +9411,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def grad_log_abs_det(self):
      @@ -9540,7 +9486,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      def grad_quadratic_form_inv(self, vector):
           inv_matrix_vector = self.inv @ vector
      diff --git a/docs/docs/progressbars.html b/docs/docs/progressbars.html
      index 2b3bdcd..b705525 100644
      --- a/docs/docs/progressbars.html
      +++ b/docs/docs/progressbars.html
      @@ -125,7 +125,7 @@ 

      Module mici.progressbars

      Expand source code -Browse git +Browse git
      """Progress bar classes for tracking progress of chains."""
       
      @@ -821,7 +821,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class BaseProgressBar(abc.ABC):
           """Base class defining expected interface for progress bars."""
      @@ -909,7 +909,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def sequence(self):
      @@ -923,7 +923,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def n_iter(self):
      @@ -951,7 +951,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      @abc.abstractmethod
       def update(self, iter_count, iter_dict, refresh=True):
      @@ -990,7 +990,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class DummyProgressBar(BaseProgressBar):
           """Placeholder progress bar which does not display progress updates."""
      @@ -1030,7 +1030,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      def update(self, iter_count, iter_dict, refresh=True):
           pass
      @@ -1077,7 +1077,7 @@

      Args

      Expand source code -Browse git +Browse git
      class ProgressBar(BaseProgressBar):
           """Iterable object for tracking progress of an iterative task.
      @@ -1343,7 +1343,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def description(self):
      @@ -1357,7 +1357,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def counter(self):
      @@ -1371,7 +1371,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def prop_complete(self):
      @@ -1385,7 +1385,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def perc_complete(self):
      @@ -1399,7 +1399,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def elapsed_time(self):
      @@ -1413,7 +1413,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def iter_rate(self):
      @@ -1433,7 +1433,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def est_remaining_time(self):
      @@ -1451,7 +1451,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def n_block_filled(self):
      @@ -1465,7 +1465,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def n_block_empty(self):
      @@ -1479,7 +1479,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def prop_partial_block(self):
      @@ -1493,7 +1493,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def filled_blocks(self):
      @@ -1507,7 +1507,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def empty_blocks(self):
      @@ -1524,7 +1524,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def partial_block(self):
      @@ -1541,7 +1541,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def progress_bar(self):
      @@ -1555,7 +1555,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def bar_color(self):
      @@ -1574,7 +1574,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def stats(self):
      @@ -1588,7 +1588,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def prefix(self):
      @@ -1604,7 +1604,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def postfix(self):
      @@ -1631,7 +1631,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def reset(self):
           """Reset progress bar state."""
      @@ -1659,7 +1659,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      def update(self, iter_count, iter_dict=None, refresh=True):
           """Update progress bar state
      @@ -1692,7 +1692,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      def refresh(self):
           """Refresh visual display(s) of progress bar."""
      @@ -1732,7 +1732,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class LabelledSequenceProgressBar(BaseProgressBar):
           """Iterable object for tracking progress of a sequence of labelled tasks."""
      @@ -1929,7 +1929,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def counter(self):
      @@ -1943,7 +1943,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def description(self):
      @@ -1957,7 +1957,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def stats(self):
      @@ -1971,7 +1971,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def prefix(self):
      @@ -1985,7 +1985,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def postfix(self):
      @@ -1999,7 +1999,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def completed_labels(self):
      @@ -2015,7 +2015,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def current_label(self):
      @@ -2029,7 +2029,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def unstarted_labels(self):
      @@ -2043,7 +2043,7 @@ 

      Instance variables

      Expand source code -Browse git +Browse git
      @property
       def progress_bar(self):
      @@ -2069,7 +2069,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def reset(self):
           """Reset progress bar state."""
      @@ -2097,7 +2097,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      def update(self, iter_count, iter_dict=None, refresh=True):
           """Update progress bar state
      @@ -2129,7 +2129,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      def refresh(self):
           """Refresh visual display(s) of status bar."""
      @@ -2161,7 +2161,7 @@ 

      Args

      Expand source code -Browse git +Browse git
      class FileDisplay:
           """Use file which supports ANSI escape sequences as an updatable display"""
      @@ -2224,7 +2224,7 @@ 

      Methods

      Expand source code -Browse git +Browse git
      def update(self, obj):
           self._move_line(self._position[0] - self._position[1])
      diff --git a/docs/docs/samplers.html b/docs/docs/samplers.html
      index 930a78b..169483a 100644
      --- a/docs/docs/samplers.html
      +++ b/docs/docs/samplers.html
      @@ -130,7 +130,7 @@ 

      Module mici.samplers

      Expand source code -Browse git +Browse git
      """Monte Carlo sampler classes for peforming inference."""
       
      @@ -166,6 +166,21 @@ 

      Module mici.samplers

      from multiprocessing.managers import SyncManager MULTIPROCESS_AVAILABLE = False +try: + from threadpoolctl import threadpool_limits + THREADPOOLCTL_AVAILABLE = True +except ImportError: + THREADPOOLCTL_AVAILABLE = False + +try: + from contextlib import nullcontext +except ImportError: + # Fallback for nullcontext context manager for Python 3.6 + # https://stackoverflow.com/a/55902915 + @contextmanager + def nullcontext(): + yield None + logger = logging.getLogger(__name__) @@ -651,6 +666,7 @@

      Module mici.samplers

      def _sample_chains_sequential(init_states, rngs, chain_iterators, **kwargs): """Sample multiple chains sequentially in a single process.""" chain_outputs = [] + exception = None for chain_index, (init_state, rng, chain_iterator) in enumerate( zip(init_states, rngs, chain_iterators)): *outputs, exception = _sample_chain( @@ -678,11 +694,15 @@

      Module mici.samplers

      try: chain_index, init_state, rng, n_iter, kwargs = chain_queue.get( block=False) - *outputs, exception = _sample_chain( - init_state=init_state, rng=rng, chain_index=chain_index, - chain_iterator=_ProxyProgressBar( - range(n_iter), chain_index, iter_queue), - parallel_chains=True, **kwargs) + max_threads = kwargs.pop('max_threads_per_process', None) + context = (threadpool_limits(limits=max_threads) + if THREADPOOLCTL_AVAILABLE else nullcontext()) + with context: + *outputs, exception = _sample_chain( + init_state=init_state, rng=rng, chain_index=chain_index, + chain_iterator=_ProxyProgressBar( + range(n_iter), chain_index, iter_queue), + parallel_chains=True, **kwargs) # Returned exception being AdaptationError indicates chain # terminated due to adapter initialisation failing therefore do not # store returned chain outputs and put None value on iteration queue @@ -972,6 +992,15 @@

      Module mici.samplers

      output of `os.cpu_count()`. Kwargs: + max_threads_per_process (int or None): If `threadpoolctl` is + available this argument may be used to limit the maximum number + of threads that can be used in thread pools used in libraries + supported by `threadpoolctl`, which include BLAS and OpenMP + implementations. This argument will only have an effect if + `n_process > 1` such that chains are being run on multiple + processes and only if `threadpoolctl` is installed in the + current Python environment. If set to `None` (the default) no + limits are set. memmap_enabled (bool): Whether to memory-map arrays used to store chain data to files on disk to avoid excessive system memory usage for long chains and/or large chain states. The chain data @@ -1039,6 +1068,7 @@

      Module mici.samplers

      n_iter, kwargs.pop('progress_bar_class'), n_chain) if n_process == 1: # Using single process therefore run chains sequentially + kwargs.pop('max_threads_per_process', None) *states_traces_stats, adapter_states, _ = _sample_chains_sequential( init_states=init_states, rngs=rngs, chain_iterators=chain_iterators, transitions=self.transitions, @@ -1072,7 +1102,7 @@

      Module mici.samplers

      Args: n_warm_up_iter (int): Number of adaptive warm up iterations per - chain. Depending on the `mici.stages.Stager` instance specified + chain. Depending on the `mici.stagers.Stager` instance specified by the `stage arguments the warm up iterations may be split between one or more adaptive stages. n_main_iter (int): Number of iterations (samples to draw) per chain @@ -1121,6 +1151,15 @@

      Module mici.samplers

      dynamically assign the chains across multiple processes. If set to `None` then the number of processes will be set to the output of `os.cpu_count()`. Default is `n_process=1`. + max_threads_per_process (int or None): If `threadpoolctl` is + available this argument may be used to limit the maximum number + of threads that can be used in thread pools used in libraries + supported by `threadpoolctl`, which include BLAS and OpenMP + implementations. This argument will only have an effect if + `n_process > 1` such that chains are being run on multiple + processes and only if `threadpoolctl` is installed in the + current Python environment. If set to `None` (the default) no + limits are set. memmap_enabled (bool): Whether to memory-map arrays used to store chain data to files on disk to avoid excessive system memory usage for long chains and/or large chain states. The chain data @@ -1183,6 +1222,7 @@

      Module mici.samplers

      common_sample_chains_kwargs['n_process'] = n_process else: sample_chains_func = _sample_chains_sequential + common_sample_chains_kwargs.pop('max_threads_per_process', None) if stager is None: if all(a.is_fast for a_list in adapters.values() for a in a_list): stager = WarmUpStager() @@ -1423,6 +1463,15 @@

      Module mici.samplers

      dynamically assign the chains across multiple processes. If set to `None` then the number of processes will be set to the output of `os.cpu_count()`. Default is `n_process=1`. + max_threads_per_process (int or None): If `threadpoolctl` is + available this argument may be used to limit the maximum number + of threads that can be used in thread pools used in libraries + supported by `threadpoolctl`, which include BLAS and OpenMP + implementations. This argument will only have an effect if + `n_process > 1` such that chains are being run on multiple + processes and only if `threadpoolctl` is installed in the + current Python environment. If set to `None` (the default) no + limits are set. trace_funcs (Iterable[Callable[[ChainState], Dict[str, array]]]): List of functions which compute the variables to be recorded at each chain iteration, with each trace function being passed the @@ -1516,7 +1565,7 @@

      Module mici.samplers

      Args: n_warm_up_iter (int): Number of adaptive warm up iterations per - chain. Depending on the `mici.stages.Stager` instance specified + chain. Depending on the `mici.stagers.Stager` instance specified by the `stage arguments the warm up iterations may be split between one or more adaptive stages. n_main_iter (int): Number of iterations (samples to draw) per chain @@ -1536,6 +1585,15 @@

      Module mici.samplers

      dynamically assign the chains across multiple processes. If set to `None` then the number of processes will be set to the output of `os.cpu_count()`. Default is `n_process=1`. + max_threads_per_process (int or None): If `threadpoolctl` is + available this argument may be used to limit the maximum number + of threads that can be used in thread pools used in libraries + supported by `threadpoolctl`, which include BLAS and OpenMP + implementations. This argument will only have an effect if + `n_process > 1` such that chains are being run on multiple + processes and only if `threadpoolctl` is installed in the + current Python environment. If set to `None` (the default) no + limits are set. trace_funcs (Iterable[Callable[[ChainState], Dict[str, array]]]): List of functions which compute the variables to be recorded at each chain iteration during the main non-adaptive sampling @@ -1987,7 +2045,7 @@

      Args

      Expand source code -Browse git +Browse git
      class MarkovChainMonteCarloMethod(object):
           """Generic Markov chain Monte Carlo (MCMC) sampler.
      @@ -2153,6 +2211,15 @@ 

      Args

      output of `os.cpu_count()`. Kwargs: + max_threads_per_process (int or None): If `threadpoolctl` is + available this argument may be used to limit the maximum number + of threads that can be used in thread pools used in libraries + supported by `threadpoolctl`, which include BLAS and OpenMP + implementations. This argument will only have an effect if + `n_process > 1` such that chains are being run on multiple + processes and only if `threadpoolctl` is installed in the + current Python environment. If set to `None` (the default) no + limits are set. memmap_enabled (bool): Whether to memory-map arrays used to store chain data to files on disk to avoid excessive system memory usage for long chains and/or large chain states. The chain data @@ -2220,6 +2287,7 @@

      Args

      n_iter, kwargs.pop('progress_bar_class'), n_chain) if n_process == 1: # Using single process therefore run chains sequentially + kwargs.pop('max_threads_per_process', None) *states_traces_stats, adapter_states, _ = _sample_chains_sequential( init_states=init_states, rngs=rngs, chain_iterators=chain_iterators, transitions=self.transitions, @@ -2253,7 +2321,7 @@

      Args

      Args: n_warm_up_iter (int): Number of adaptive warm up iterations per - chain. Depending on the `mici.stages.Stager` instance specified + chain. Depending on the `mici.stagers.Stager` instance specified by the `stage arguments the warm up iterations may be split between one or more adaptive stages. n_main_iter (int): Number of iterations (samples to draw) per chain @@ -2302,6 +2370,15 @@

      Args

      dynamically assign the chains across multiple processes. If set to `None` then the number of processes will be set to the output of `os.cpu_count()`. Default is `n_process=1`. + max_threads_per_process (int or None): If `threadpoolctl` is + available this argument may be used to limit the maximum number + of threads that can be used in thread pools used in libraries + supported by `threadpoolctl`, which include BLAS and OpenMP + implementations. This argument will only have an effect if + `n_process > 1` such that chains are being run on multiple + processes and only if `threadpoolctl` is installed in the + current Python environment. If set to `None` (the default) no + limits are set. memmap_enabled (bool): Whether to memory-map arrays used to store chain data to files on disk to avoid excessive system memory usage for long chains and/or large chain states. The chain data @@ -2364,6 +2441,7 @@

      Args

      common_sample_chains_kwargs['n_process'] = n_process else: sample_chains_func = _sample_chains_sequential + common_sample_chains_kwargs.pop('max_threads_per_process', None) if stager is None: if all(a.is_fast for a_list in adapters.values() for a in a_list): stager = WarmUpStager() @@ -2501,7 +2579,7 @@

      Returns

      Expand source code -Browse git +Browse git
      def sample_chain(self, n_iter, init_state, trace_funcs, **kwargs):
           """Sample a Markov chain from a given initial state.
      @@ -2641,6 +2719,16 @@ 

      Args

    Kwargs

    +
    max_threads_per_process : int or None
    +
    If threadpoolctl is +available this argument may be used to limit the maximum number +of threads that can be used in thread pools used in libraries +supported by threadpoolctl, which include BLAS and OpenMP +implementations. This argument will only have an effect if +n_process > 1 such that chains are being run on multiple +processes and only if threadpoolctl is installed in the +current Python environment. If set to None (the default) no +limits are set.
    memmap_enabled : bool
    Whether to memory-map arrays used to store chain data to files on disk to avoid excessive system memory @@ -2715,7 +2803,7 @@

    Returns

    Expand source code -Browse git +Browse git
    def sample_chains(self, n_iter, init_states, trace_funcs, n_process=1,
                       **kwargs):
    @@ -2751,6 +2839,15 @@ 

    Returns

    output of `os.cpu_count()`. Kwargs: + max_threads_per_process (int or None): If `threadpoolctl` is + available this argument may be used to limit the maximum number + of threads that can be used in thread pools used in libraries + supported by `threadpoolctl`, which include BLAS and OpenMP + implementations. This argument will only have an effect if + `n_process > 1` such that chains are being run on multiple + processes and only if `threadpoolctl` is installed in the + current Python environment. If set to `None` (the default) no + limits are set. memmap_enabled (bool): Whether to memory-map arrays used to store chain data to files on disk to avoid excessive system memory usage for long chains and/or large chain states. The chain data @@ -2818,6 +2915,7 @@

    Returns

    n_iter, kwargs.pop('progress_bar_class'), n_chain) if n_process == 1: # Using single process therefore run chains sequentially + kwargs.pop('max_threads_per_process', None) *states_traces_stats, adapter_states, _ = _sample_chains_sequential( init_states=init_states, rngs=rngs, chain_iterators=chain_iterators, transitions=self.transitions, @@ -2852,7 +2950,7 @@

    Args

    n_warm_up_iter : int
    Number of adaptive warm up iterations per -chain. Depending on the mici.stages.Stager instance specified +chain. Depending on the Stager instance specified by the `stage arguments the warm up iterations may be split between one or more adaptive stages.
    n_main_iter : int
    @@ -2911,6 +3009,16 @@

    Kwargs

    dynamically assign the chains across multiple processes. If set to None then the number of processes will be set to the output of os.cpu_count(). Default is n_process=1.
    +
    max_threads_per_process : int or None
    +
    If threadpoolctl is +available this argument may be used to limit the maximum number +of threads that can be used in thread pools used in libraries +supported by threadpoolctl, which include BLAS and OpenMP +implementations. This argument will only have an effect if +n_process > 1 such that chains are being run on multiple +processes and only if threadpoolctl is installed in the +current Python environment. If set to None (the default) no +limits are set.
    memmap_enabled : bool
    Whether to memory-map arrays used to store chain data to files on disk to avoid excessive system memory @@ -2975,7 +3083,7 @@

    Returns

    Expand source code -Browse git +Browse git
    def sample_chains_with_adaptive_warm_up(
             self, n_warm_up_iter, n_main_iter, init_states, trace_funcs,
    @@ -2995,7 +3103,7 @@ 

    Returns

    Args: n_warm_up_iter (int): Number of adaptive warm up iterations per - chain. Depending on the `mici.stages.Stager` instance specified + chain. Depending on the `mici.stagers.Stager` instance specified by the `stage arguments the warm up iterations may be split between one or more adaptive stages. n_main_iter (int): Number of iterations (samples to draw) per chain @@ -3044,6 +3152,15 @@

    Returns

    dynamically assign the chains across multiple processes. If set to `None` then the number of processes will be set to the output of `os.cpu_count()`. Default is `n_process=1`. + max_threads_per_process (int or None): If `threadpoolctl` is + available this argument may be used to limit the maximum number + of threads that can be used in thread pools used in libraries + supported by `threadpoolctl`, which include BLAS and OpenMP + implementations. This argument will only have an effect if + `n_process > 1` such that chains are being run on multiple + processes and only if `threadpoolctl` is installed in the + current Python environment. If set to `None` (the default) no + limits are set. memmap_enabled (bool): Whether to memory-map arrays used to store chain data to files on disk to avoid excessive system memory usage for long chains and/or large chain states. The chain data @@ -3106,6 +3223,7 @@

    Returns

    common_sample_chains_kwargs['n_process'] = n_process else: sample_chains_func = _sample_chains_sequential + common_sample_chains_kwargs.pop('max_threads_per_process', None) if stager is None: if all(a.is_fast for a_list in adapters.values() for a in a_list): stager = WarmUpStager() @@ -3196,7 +3314,7 @@

    Args

    Expand source code -Browse git +Browse git
    class HamiltonianMCMC(MarkovChainMonteCarloMethod):
         """Wrapper class for Hamiltonian Markov chain Monte Carlo (H-MCMC) methods.
    @@ -3408,6 +3526,15 @@ 

    Args

    dynamically assign the chains across multiple processes. If set to `None` then the number of processes will be set to the output of `os.cpu_count()`. Default is `n_process=1`. + max_threads_per_process (int or None): If `threadpoolctl` is + available this argument may be used to limit the maximum number + of threads that can be used in thread pools used in libraries + supported by `threadpoolctl`, which include BLAS and OpenMP + implementations. This argument will only have an effect if + `n_process > 1` such that chains are being run on multiple + processes and only if `threadpoolctl` is installed in the + current Python environment. If set to `None` (the default) no + limits are set. trace_funcs (Iterable[Callable[[ChainState], Dict[str, array]]]): List of functions which compute the variables to be recorded at each chain iteration, with each trace function being passed the @@ -3501,7 +3628,7 @@

    Args

    Args: n_warm_up_iter (int): Number of adaptive warm up iterations per - chain. Depending on the `mici.stages.Stager` instance specified + chain. Depending on the `mici.stagers.Stager` instance specified by the `stage arguments the warm up iterations may be split between one or more adaptive stages. n_main_iter (int): Number of iterations (samples to draw) per chain @@ -3521,6 +3648,15 @@

    Args

    dynamically assign the chains across multiple processes. If set to `None` then the number of processes will be set to the output of `os.cpu_count()`. Default is `n_process=1`. + max_threads_per_process (int or None): If `threadpoolctl` is + available this argument may be used to limit the maximum number + of threads that can be used in thread pools used in libraries + supported by `threadpoolctl`, which include BLAS and OpenMP + implementations. This argument will only have an effect if + `n_process > 1` such that chains are being run on multiple + processes and only if `threadpoolctl` is installed in the + current Python environment. If set to `None` (the default) no + limits are set. trace_funcs (Iterable[Callable[[ChainState], Dict[str, array]]]): List of functions which compute the variables to be recorded at each chain iteration during the main non-adaptive sampling @@ -3722,7 +3858,7 @@

    Returns

    Expand source code -Browse git +Browse git
    def sample_chain(self, n_iter, init_state, **kwargs):
         """Sample a Markov chain from a given initial state.
    @@ -3843,6 +3979,16 @@ 

    Kwargs

    dynamically assign the chains across multiple processes. If set to None then the number of processes will be set to the output of os.cpu_count(). Default is n_process=1.
    +
    max_threads_per_process : int or None
    +
    If threadpoolctl is +available this argument may be used to limit the maximum number +of threads that can be used in thread pools used in libraries +supported by threadpoolctl, which include BLAS and OpenMP +implementations. This argument will only have an effect if +n_process > 1 such that chains are being run on multiple +processes and only if threadpoolctl is installed in the +current Python environment. If set to None (the default) no +limits are set.
    trace_funcs : Iterable[Callable[[ChainState], Dict[str, array]]]

    List of functions which compute the variables to be recorded at @@ -3923,7 +4069,7 @@

    Returns

    Expand source code -Browse git +Browse git
    def sample_chains(self, n_iter, init_states, **kwargs):
         """Sample one or more Markov chains from given initial states.
    @@ -3951,6 +4097,15 @@ 

    Returns

    dynamically assign the chains across multiple processes. If set to `None` then the number of processes will be set to the output of `os.cpu_count()`. Default is `n_process=1`. + max_threads_per_process (int or None): If `threadpoolctl` is + available this argument may be used to limit the maximum number + of threads that can be used in thread pools used in libraries + supported by `threadpoolctl`, which include BLAS and OpenMP + implementations. This argument will only have an effect if + `n_process > 1` such that chains are being run on multiple + processes and only if `threadpoolctl` is installed in the + current Python environment. If set to `None` (the default) no + limits are set. trace_funcs (Iterable[Callable[[ChainState], Dict[str, array]]]): List of functions which compute the variables to be recorded at each chain iteration, with each trace function being passed the @@ -4045,7 +4200,7 @@

    Args

    n_warm_up_iter : int
    Number of adaptive warm up iterations per -chain. Depending on the mici.stages.Stager instance specified +chain. Depending on the Stager instance specified by the `stage arguments the warm up iterations may be split between one or more adaptive stages.
    n_main_iter : int
    @@ -4069,6 +4224,16 @@

    Kwargs

    dynamically assign the chains across multiple processes. If set to None then the number of processes will be set to the output of os.cpu_count(). Default is n_process=1.
    +
    max_threads_per_process : int or None
    +
    If threadpoolctl is +available this argument may be used to limit the maximum number +of threads that can be used in thread pools used in libraries +supported by threadpoolctl, which include BLAS and OpenMP +implementations. This argument will only have an effect if +n_process > 1 such that chains are being run on multiple +processes and only if threadpoolctl is installed in the +current Python environment. If set to None (the default) no +limits are set.
    trace_funcs : Iterable[Callable[[ChainState], Dict[str, array]]]

    List of functions which compute the variables to be recorded at @@ -4165,7 +4330,7 @@

    Returns

    Expand source code -Browse git +Browse git
    def sample_chains_with_adaptive_warm_up(
             self, n_warm_up_iter, n_main_iter, init_states, **kwargs):
    @@ -4189,7 +4354,7 @@ 

    Returns

    Args: n_warm_up_iter (int): Number of adaptive warm up iterations per - chain. Depending on the `mici.stages.Stager` instance specified + chain. Depending on the `mici.stagers.Stager` instance specified by the `stage arguments the warm up iterations may be split between one or more adaptive stages. n_main_iter (int): Number of iterations (samples to draw) per chain @@ -4209,6 +4374,15 @@

    Returns

    dynamically assign the chains across multiple processes. If set to `None` then the number of processes will be set to the output of `os.cpu_count()`. Default is `n_process=1`. + max_threads_per_process (int or None): If `threadpoolctl` is + available this argument may be used to limit the maximum number + of threads that can be used in thread pools used in libraries + supported by `threadpoolctl`, which include BLAS and OpenMP + implementations. This argument will only have an effect if + `n_process > 1` such that chains are being run on multiple + processes and only if `threadpoolctl` is installed in the + current Python environment. If set to `None` (the default) no + limits are set. trace_funcs (Iterable[Callable[[ChainState], Dict[str, array]]]): List of functions which compute the variables to be recorded at each chain iteration during the main non-adaptive sampling @@ -4352,7 +4526,7 @@

    Args

    Expand source code -Browse git +Browse git
    class StaticMetropolisHMC(HamiltonianMCMC):
         """Static integration time H-MCMC implementation with Metropolis sampling.
    @@ -4427,7 +4601,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def n_step(self):
    @@ -4567,6 +4741,16 @@ 

    Kwargs

    dynamically assign the chains across multiple processes. If set to None then the number of processes will be set to the output of os.cpu_count(). Default is n_process=1.
    +
    max_threads_per_process : int or None
    +
    If threadpoolctl is +available this argument may be used to limit the maximum number +of threads that can be used in thread pools used in libraries +supported by threadpoolctl, which include BLAS and OpenMP +implementations. This argument will only have an effect if +n_process > 1 such that chains are being run on multiple +processes and only if threadpoolctl is installed in the +current Python environment. If set to None (the default) no +limits are set.
    trace_funcs : Iterable[Callable[[ChainState], Dict[str, array]]]

    List of functions which compute the variables to be recorded at @@ -4667,7 +4851,7 @@

    Args

    n_warm_up_iter : int
    Number of adaptive warm up iterations per -chain. Depending on the mici.stages.Stager instance specified +chain. Depending on the Stager instance specified by the `stage arguments the warm up iterations may be split between one or more adaptive stages.
    n_main_iter : int
    @@ -4691,6 +4875,16 @@

    Kwargs

    dynamically assign the chains across multiple processes. If set to None then the number of processes will be set to the output of os.cpu_count(). Default is n_process=1.
    +
    max_threads_per_process : int or None
    +
    If threadpoolctl is +available this argument may be used to limit the maximum number +of threads that can be used in thread pools used in libraries +supported by threadpoolctl, which include BLAS and OpenMP +implementations. This argument will only have an effect if +n_process > 1 such that chains are being run on multiple +processes and only if threadpoolctl is installed in the +current Python environment. If set to None (the default) no +limits are set.
    trace_funcs : Iterable[Callable[[ChainState], Dict[str, array]]]

    List of functions which compute the variables to be recorded at @@ -4844,7 +5038,7 @@

    Args

    Expand source code -Browse git +Browse git
    class RandomMetropolisHMC(HamiltonianMCMC):
         """Random integration time H-MCMC with Metropolis sampling of new state.
    @@ -4927,7 +5121,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def n_step_range(self):
    @@ -5067,6 +5261,16 @@ 

    Kwargs

    dynamically assign the chains across multiple processes. If set to None then the number of processes will be set to the output of os.cpu_count(). Default is n_process=1.
    +
    max_threads_per_process : int or None
    +
    If threadpoolctl is +available this argument may be used to limit the maximum number +of threads that can be used in thread pools used in libraries +supported by threadpoolctl, which include BLAS and OpenMP +implementations. This argument will only have an effect if +n_process > 1 such that chains are being run on multiple +processes and only if threadpoolctl is installed in the +current Python environment. If set to None (the default) no +limits are set.
    trace_funcs : Iterable[Callable[[ChainState], Dict[str, array]]]

    List of functions which compute the variables to be recorded at @@ -5167,7 +5371,7 @@

    Args

    n_warm_up_iter : int
    Number of adaptive warm up iterations per -chain. Depending on the mici.stages.Stager instance specified +chain. Depending on the Stager instance specified by the `stage arguments the warm up iterations may be split between one or more adaptive stages.
    n_main_iter : int
    @@ -5191,6 +5395,16 @@

    Kwargs

    dynamically assign the chains across multiple processes. If set to None then the number of processes will be set to the output of os.cpu_count(). Default is n_process=1.
    +
    max_threads_per_process : int or None
    +
    If threadpoolctl is +available this argument may be used to limit the maximum number +of threads that can be used in thread pools used in libraries +supported by threadpoolctl, which include BLAS and OpenMP +implementations. This argument will only have an effect if +n_process > 1 such that chains are being run on multiple +processes and only if threadpoolctl is installed in the +current Python environment. If set to None (the default) no +limits are set.
    trace_funcs : Iterable[Callable[[ChainState], Dict[str, array]]]

    List of functions which compute the variables to be recorded at @@ -5372,7 +5586,7 @@

    Args

    Expand source code -Browse git +Browse git
    class DynamicMultinomialHMC(HamiltonianMCMC):
         """Dynamic integration time H-MCMC with multinomial sampling of new state.
    @@ -5488,7 +5702,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def max_tree_depth(self):
    @@ -5502,7 +5716,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def max_delta_h(self):
    @@ -5642,6 +5856,16 @@ 

    Kwargs

    dynamically assign the chains across multiple processes. If set to None then the number of processes will be set to the output of os.cpu_count(). Default is n_process=1.
    +
    max_threads_per_process : int or None
    +
    If threadpoolctl is +available this argument may be used to limit the maximum number +of threads that can be used in thread pools used in libraries +supported by threadpoolctl, which include BLAS and OpenMP +implementations. This argument will only have an effect if +n_process > 1 such that chains are being run on multiple +processes and only if threadpoolctl is installed in the +current Python environment. If set to None (the default) no +limits are set.
    trace_funcs : Iterable[Callable[[ChainState], Dict[str, array]]]

    List of functions which compute the variables to be recorded at @@ -5742,7 +5966,7 @@

    Args

    n_warm_up_iter : int
    Number of adaptive warm up iterations per -chain. Depending on the mici.stages.Stager instance specified +chain. Depending on the Stager instance specified by the `stage arguments the warm up iterations may be split between one or more adaptive stages.
    n_main_iter : int
    @@ -5766,6 +5990,16 @@

    Kwargs

    dynamically assign the chains across multiple processes. If set to None then the number of processes will be set to the output of os.cpu_count(). Default is n_process=1.
    +
    max_threads_per_process : int or None
    +
    If threadpoolctl is +available this argument may be used to limit the maximum number +of threads that can be used in thread pools used in libraries +supported by threadpoolctl, which include BLAS and OpenMP +implementations. This argument will only have an effect if +n_process > 1 such that chains are being run on multiple +processes and only if threadpoolctl is installed in the +current Python environment. If set to None (the default) no +limits are set.
    trace_funcs : Iterable[Callable[[ChainState], Dict[str, array]]]

    List of functions which compute the variables to be recorded at @@ -5945,7 +6179,7 @@

    Args

    Expand source code -Browse git +Browse git
    class DynamicSliceHMC(HamiltonianMCMC):
         """Dynamic integration time H-MCMC with slice sampling of new state.
    @@ -6059,7 +6293,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def max_tree_depth(self):
    @@ -6073,7 +6307,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def max_delta_h(self):
    @@ -6213,6 +6447,16 @@ 

    Kwargs

    dynamically assign the chains across multiple processes. If set to None then the number of processes will be set to the output of os.cpu_count(). Default is n_process=1.
    +
    max_threads_per_process : int or None
    +
    If threadpoolctl is +available this argument may be used to limit the maximum number +of threads that can be used in thread pools used in libraries +supported by threadpoolctl, which include BLAS and OpenMP +implementations. This argument will only have an effect if +n_process > 1 such that chains are being run on multiple +processes and only if threadpoolctl is installed in the +current Python environment. If set to None (the default) no +limits are set.
    trace_funcs : Iterable[Callable[[ChainState], Dict[str, array]]]

    List of functions which compute the variables to be recorded at @@ -6313,7 +6557,7 @@

    Args

    n_warm_up_iter : int
    Number of adaptive warm up iterations per -chain. Depending on the mici.stages.Stager instance specified +chain. Depending on the Stager instance specified by the `stage arguments the warm up iterations may be split between one or more adaptive stages.
    n_main_iter : int
    @@ -6337,6 +6581,16 @@

    Kwargs

    dynamically assign the chains across multiple processes. If set to None then the number of processes will be set to the output of os.cpu_count(). Default is n_process=1.
    +
    max_threads_per_process : int or None
    +
    If threadpoolctl is +available this argument may be used to limit the maximum number +of threads that can be used in thread pools used in libraries +supported by threadpoolctl, which include BLAS and OpenMP +implementations. This argument will only have an effect if +n_process > 1 such that chains are being run on multiple +processes and only if threadpoolctl is installed in the +current Python environment. If set to None (the default) no +limits are set.
    trace_funcs : Iterable[Callable[[ChainState], Dict[str, array]]]

    List of functions which compute the variables to be recorded at diff --git a/docs/docs/solvers.html b/docs/docs/solvers.html index cdfdb04..157f024 100644 --- a/docs/docs/solvers.html +++ b/docs/docs/solvers.html @@ -52,7 +52,7 @@

    Module mici.solvers

    Expand source code -Browse git +Browse git
    """Solvers for non-linear systems of equations for implicit integrators."""
     
    @@ -363,7 +363,7 @@ 

    Functions

    Expand source code -Browse git +Browse git
    def euclidean_norm(vct):
         """Calculate the Euclidean (L-2) norm of a vector."""
    @@ -378,7 +378,7 @@ 

    Functions

    Expand source code -Browse git +Browse git
    def maximum_norm(vct):
         """Calculate the maximum (L-infinity) norm of a vector."""
    @@ -420,7 +420,7 @@ 

    Raises

    Expand source code -Browse git +Browse git
    def solve_fixed_point_direct(
             func, x0, convergence_tol=1e-9, divergence_tol=1e10, max_iters=100,
    @@ -505,7 +505,7 @@ 

    Raises

    Expand source code -Browse git +Browse git
    def solve_fixed_point_steffensen(
             func, x0, convergence_tol=1e-9, divergence_tol=1e10, max_iters=100,
    @@ -628,7 +628,7 @@ 

    Raises

    Expand source code -Browse git +Browse git
    def solve_projection_onto_manifold_quasi_newton(
             state, state_prev, dt, system, constraint_tol=1e-9, position_tol=1e-8,
    @@ -784,7 +784,7 @@ 

    Raises

    Expand source code -Browse git +Browse git
    def solve_projection_onto_manifold_newton(
             state, state_prev, dt, system, constraint_tol=1e-9, position_tol=1e-8,
    diff --git a/docs/docs/stagers.html b/docs/docs/stagers.html
    index 31ca3e9..3885d10 100644
    --- a/docs/docs/stagers.html
    +++ b/docs/docs/stagers.html
    @@ -72,7 +72,7 @@ 

    Module mici.stagers

    Expand source code -Browse git +Browse git
    """Classes for controlling sampling of Markov chains split into stages."""
     
    @@ -317,7 +317,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    class Stager(abc.ABC):
         """Abstract chain iteration stager."""
    @@ -432,7 +432,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @abc.abstractmethod
     def stages(self, n_warm_up_iter, n_main_iter, adapters, trace_funcs):
    @@ -499,7 +499,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    class WarmUpStager(Stager):
         """Chain iteration stager with a single adaptive warm up stage.
    @@ -584,7 +584,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def stages(self, n_warm_up_iter, n_main_iter, adapters, trace_funcs):
         # adaptive warm up stage
    @@ -660,7 +660,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class WindowedWarmUpStager(Stager):
         """Chain iteration stager with a hierarchy of adaptive warm up stages.
    @@ -840,7 +840,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def stages(self, n_warm_up_iter, n_main_iter, adapters, trace_funcs):
         fast_adapters = {
    diff --git a/docs/docs/states.html b/docs/docs/states.html
    index 32417d7..472f722 100644
    --- a/docs/docs/states.html
    +++ b/docs/docs/states.html
    @@ -58,7 +58,7 @@ 

    Module mici.states

    Expand source code -Browse git +Browse git
    """Objects for recording state of a Markov chain and caching computations."""
     
    @@ -78,7 +78,7 @@ 

    Module mici.states

    def cache_in_state(*depends_on): """Memoizing decorator for system methods. - Used to decorate `mici.system.System` methods which compute a function of + Used to decorate `mici.systems.System` methods which compute a function of one or more chain state variable(s), with the decorated method caching the value returned by the method being wrapped in the `ChainState` object to prevent the need for recomputation on future calls if the state variables @@ -86,8 +86,8 @@

    Module mici.states

    Additionally for `ChainState` instances initialized with a `_call_counts` argument, the memoized method will update a counter for the method in the - `ChainState._call_counts` attribute every time the method being decorated is - called (i.e. when there isn't a valid cached value available). + `_call_counts` attribute every time the method being decorated is called + (i.e. when there isn't a valid cached value available). Args: *depends_on: One or more strings corresponding to the names of any state @@ -115,7 +115,7 @@

    Module mici.states

    def cache_in_state_with_aux(depends_on, auxiliary_outputs): """Memoizing decorator for system methods with possible auxiliary outputs. - Used to decorate `mici.system.System` methods which compute a function of + Used to decorate `mici.systems.System` methods which compute a function of one or more chain state variable(s), with the decorated method caching the value or values returned by the method being wrapped in the `ChainState` object to prevent the need for recomputation on future calls if the state @@ -142,8 +142,8 @@

    Module mici.states

    Additionally for `ChainState` instances initialized with a `_call_counts` argument, the memoized method will update a counter for the method in the - `ChainState._call_counts` attribute every time the method being decorated is - called (i.e. when there isn't a valid cached value available). + `_call_counts` attribute every time the method being decorated is called + (i.e. when there isn't a valid cached value available). Args: depends_on (str or Tuple[str]): A string or tuple of strings, with each @@ -265,7 +265,7 @@

    Module mici.states

    _cache = {} self.__dict__['_cache'] = _cache self.__dict__['_call_counts'] = ( - Counter(_call_counts) if isinstance(_call_counts, dict) + Counter(_call_counts) if not isinstance(_call_counts, Counter) else _call_counts) self.__dict__['_read_only'] = _read_only @@ -346,15 +346,15 @@

    Functions

    Memoizing decorator for system methods.

    -

    Used to decorate mici.system.System methods which compute a function of +

    Used to decorate System methods which compute a function of one or more chain state variable(s), with the decorated method caching the value returned by the method being wrapped in the ChainState object to prevent the need for recomputation on future calls if the state variables the returned value depends on have not been changed in between the calls.

    Additionally for ChainState instances initialized with a _call_counts argument, the memoized method will update a counter for the method in the -ChainState._call_counts attribute every time the method being decorated is -called (i.e. when there isn't a valid cached value available).

    +_call_counts attribute every time the method being decorated is called +(i.e. when there isn't a valid cached value available).

    Args

    *depends_on
    @@ -367,12 +367,12 @@

    Args

    Expand source code -Browse git +Browse git
    def cache_in_state(*depends_on):
         """Memoizing decorator for system methods.
     
    -    Used to decorate `mici.system.System` methods which compute a function of
    +    Used to decorate `mici.systems.System` methods which compute a function of
         one or more chain state variable(s), with the decorated method caching the
         value returned by the method being wrapped in the `ChainState` object to
         prevent the need for recomputation on future calls if the state variables
    @@ -380,8 +380,8 @@ 

    Args

    Additionally for `ChainState` instances initialized with a `_call_counts` argument, the memoized method will update a counter for the method in the - `ChainState._call_counts` attribute every time the method being decorated is - called (i.e. when there isn't a valid cached value available). + `_call_counts` attribute every time the method being decorated is called + (i.e. when there isn't a valid cached value available). Args: *depends_on: One or more strings corresponding to the names of any state @@ -411,7 +411,7 @@

    Args

    Memoizing decorator for system methods with possible auxiliary outputs.

    -

    Used to decorate mici.system.System methods which compute a function of +

    Used to decorate System methods which compute a function of one or more chain state variable(s), with the decorated method caching the value or values returned by the method being wrapped in the ChainState object to prevent the need for recomputation on future calls if the state @@ -436,8 +436,8 @@

    Args

    depend on have not been changed in between.

    Additionally for ChainState instances initialized with a _call_counts argument, the memoized method will update a counter for the method in the -ChainState._call_counts attribute every time the method being decorated is -called (i.e. when there isn't a valid cached value available).

    +_call_counts attribute every time the method being decorated is called +(i.e. when there isn't a valid cached value available).

    Args

    depends_on : str or Tuple[str]
    @@ -461,12 +461,12 @@

    Args

    Expand source code -Browse git +Browse git
    def cache_in_state_with_aux(depends_on, auxiliary_outputs):
         """Memoizing decorator for system methods with possible auxiliary outputs.
     
    -    Used to decorate `mici.system.System` methods which compute a function of
    +    Used to decorate `mici.systems.System` methods which compute a function of
         one or more chain state variable(s), with the decorated method caching the
         value or values returned by the method being wrapped in the `ChainState`
         object to prevent the need for recomputation on future calls if the state
    @@ -493,8 +493,8 @@ 

    Args

    Additionally for `ChainState` instances initialized with a `_call_counts` argument, the memoized method will update a counter for the method in the - `ChainState._call_counts` attribute every time the method being decorated is - called (i.e. when there isn't a valid cached value available). + `_call_counts` attribute every time the method being decorated is called + (i.e. when there isn't a valid cached value available). Args: depends_on (str or Tuple[str]): A string or tuple of strings, with each @@ -614,7 +614,7 @@

    Kwargs

    Expand source code -Browse git +Browse git
    class ChainState(object):
         """Markov chain state.
    @@ -689,7 +689,7 @@ 

    Kwargs

    _cache = {} self.__dict__['_cache'] = _cache self.__dict__['_call_counts'] = ( - Counter(_call_counts) if isinstance(_call_counts, dict) + Counter(_call_counts) if not isinstance(_call_counts, Counter) else _call_counts) self.__dict__['_read_only'] = _read_only @@ -779,7 +779,7 @@

    Returns

    Expand source code -Browse git +Browse git
    def copy(self, read_only=False):
         """Create a deep copy of the state object.
    diff --git a/docs/docs/systems.html b/docs/docs/systems.html
    index 7f71344..cacd524 100644
    --- a/docs/docs/systems.html
    +++ b/docs/docs/systems.html
    @@ -355,7 +355,7 @@ 

    Module mici.systems

    Expand source code -Browse git +Browse git
    """Hamiltonian systems encapsulating energy functions and their derivatives."""
     
    @@ -2017,7 +2017,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class System(ABC):
         r"""Base class for Hamiltonian systems.
    @@ -2222,7 +2222,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @cache_in_state('pos')
     def neg_log_dens(self, state):
    @@ -2256,7 +2256,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @cache_in_state_with_aux('pos', 'neg_log_dens')
     def grad_neg_log_dens(self, state):
    @@ -2290,7 +2290,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def h1(self, state):
         """Hamiltonian component depending only on position.
    @@ -2322,7 +2322,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def dh1_dpos(self, state):
         """Derivative of `h1` Hamiltonian component with respect to position.
    @@ -2352,7 +2352,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    def h1_flow(self, state, dt):
         """Apply exact flow map corresponding to `h1` Hamiltonian component.
    @@ -2384,7 +2384,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @abstractmethod
     def h2(self, state):
    @@ -2416,7 +2416,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @abstractmethod
     def dh2_dmom(self, state):
    @@ -2448,7 +2448,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def h(self, state):
         """Hamiltonian function for system.
    @@ -2480,7 +2480,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def dh_dpos(self, state):
         """Derivative of Hamiltonian with respect to position.
    @@ -2515,7 +2515,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def dh_dmom(self, state):
         """Derivative of Hamiltonian with respect to momentum.
    @@ -2548,7 +2548,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @abstractmethod
     def sample_momentum(self, state, rng):
    @@ -2621,7 +2621,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class EuclideanMetricSystem(System):
         r"""Hamiltonian system with a Euclidean metric on the position space.
    @@ -2760,7 +2760,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @cache_in_state('mom')
     def h2(self, state):
    @@ -2785,7 +2785,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @cache_in_state('mom')
     def dh2_dmom(self, state):
    @@ -2808,7 +2808,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    def h2_flow(self, state, dt):
         """Apply exact flow map corresponding to `h2` Hamiltonian component.
    @@ -2846,7 +2846,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def dh2_flow_dmom(self, dt):
         """Derivatives of `h2_flow` flow map with respect to input momentum.
    @@ -2885,7 +2885,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def sample_momentum(self, state, rng):
         return self.metric.sqrt @ rng.standard_normal(state.pos.shape)
    @@ -3091,7 +3091,7 @@

    Args

    Expand source code -Browse git +Browse git
    class GaussianEuclideanMetricSystem(EuclideanMetricSystem):
         r"""Euclidean Hamiltonian system with a tractable Gaussian component.
    @@ -3225,7 +3225,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def h2(self, state):
         return (0.5 * state.pos @ state.pos +
    @@ -3250,7 +3250,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @cache_in_state('mom')
     def dh2_dmom(self, state):
    @@ -3265,7 +3265,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @cache_in_state('mom')
     def dh2_dpos(self, state):
    @@ -3288,7 +3288,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    def h2_flow(self, state, dt):
         omega = 1. / self.metric.eigval**0.5
    @@ -3327,7 +3327,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def dh2_flow_dmom(self, dt):
         omega = 1. / self.metric.eigval**0.5
    @@ -3636,7 +3636,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class ConstrainedEuclideanMetricSystem(EuclideanMetricSystem):
         r"""Base class for Euclidean Hamiltonian systems subject to constraints.
    @@ -3955,7 +3955,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @cache_in_state('pos')
     def constr(self, state):
    @@ -3988,7 +3988,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @cache_in_state_with_aux('pos', 'constr')
     def jacob_constr(self, state):
    @@ -4028,7 +4028,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    @abstractmethod
     def jacob_constr_inner_product(
    @@ -4073,7 +4073,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @cache_in_state('pos')
     def gram(self, state):
    @@ -4115,7 +4115,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def inv_gram(self, state):
         """Inverse of Gram matrix at current position.
    @@ -4138,7 +4138,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def log_det_sqrt_gram(self, state):
         """Value of (half of) log-determinant of Gram matrix."""
    @@ -4164,7 +4164,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @abstractmethod
     def grad_log_det_sqrt_gram(self, state):
    @@ -4197,7 +4197,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def h1(self, state):
         if self.dens_wrt_hausdorff:
    @@ -4224,7 +4224,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def dh1_dpos(self, state):
         if self.dens_wrt_hausdorff:
    @@ -4256,7 +4256,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def project_onto_cotangent_space(self, mom, state):
         """Project a momentum on to the co-tangent space at a position.
    @@ -4297,7 +4297,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def sample_momentum(self, state, rng):
         mom = super().sample_momentum(state, rng)
    @@ -4602,7 +4602,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class DenseConstrainedEuclideanMetricSystem(ConstrainedEuclideanMetricSystem):
         r"""Euclidean Hamiltonian system subject to a dense set of constraints.
    @@ -4777,7 +4777,7 @@ 

    Methods

    Expand source code -Browse git +Browse git
    @cache_in_state_with_aux('pos', ('jacob_constr', 'constr'))
     def mhp_constr(self, state):
    @@ -4809,7 +4809,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    def jacob_constr_inner_product(
             self, jacob_constr_1, inner_product_matrix, jacob_constr_2=None):
    @@ -4840,7 +4840,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @cache_in_state('pos')
     def grad_log_det_sqrt_gram(self, state):
    @@ -5270,7 +5270,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class GaussianDenseConstrainedEuclideanMetricSystem(
             GaussianEuclideanMetricSystem, DenseConstrainedEuclideanMetricSystem):
    @@ -5427,7 +5427,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    def jacob_constr_inner_product(
             self, jacob_constr_1, inner_product_matrix, jacob_constr_2=None):
    @@ -5880,7 +5880,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class RiemannianMetricSystem(System):
         r"""Riemannian Hamiltonian system with a position-dependent metric.
    @@ -6119,7 +6119,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @cache_in_state('pos')
     def metric_func(self, state):
    @@ -6158,7 +6158,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @cache_in_state_with_aux('pos', 'metric_func')
     def vjp_metric_func(self, state):
    @@ -6201,7 +6201,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @cache_in_state('pos')
     def metric(self, state):
    @@ -6239,7 +6239,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def h(self, state):
         return self.h1(state) + self.h2(state)
    @@ -6263,7 +6263,7 @@

    Returns

    Expand source code -Browse git +Browse git
    def h1(self, state):
         return self.neg_log_dens(state) + 0.5 * self.metric(state).log_abs_det
    @@ -6287,7 +6287,7 @@

    Returns

    Expand source code -Browse git +Browse git
    def dh1_dpos(self, state):
         # Evaluate VJP of metric function before metric as metric value will
    @@ -6315,7 +6315,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def h2(self, state):
         return 0.5 * state.mom @ self.metric(state).inv @ state.mom
    @@ -6329,7 +6329,7 @@

    Returns

    Expand source code -Browse git +Browse git
    def dh2_dpos(self, state):
         # Evaluate VJP of metric function before metric as metric value will
    @@ -6357,7 +6357,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def dh2_dmom(self, state):
         return self.metric(state).inv @ state.mom
    @@ -6382,7 +6382,7 @@

    Returns

    Expand source code -Browse git +Browse git
    def sample_momentum(self, state, rng):
         return self.metric(state).sqrt @ rng.normal(size=state.pos.shape)
    @@ -6537,7 +6537,7 @@

    Args

    Expand source code -Browse git +Browse git
    class ScalarRiemannianMetricSystem(RiemannianMetricSystem):
         """Riemannian-metric system with scaled identity matrix representation.
    @@ -6637,7 +6637,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @cache_in_state('pos')
     def metric(self, state):
    @@ -6928,7 +6928,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class DiagonalRiemannianMetricSystem(RiemannianMetricSystem):
         """Riemannian-metric system with diagonal matrix representation.
    @@ -7304,7 +7304,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class CholeskyFactoredRiemannianMetricSystem(RiemannianMetricSystem):
         """Riemannian-metric system with Cholesky-factored matrix representation.
    @@ -7681,7 +7681,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class DenseRiemannianMetricSystem(RiemannianMetricSystem):
         """Riemannian-metric system with dense matrix representation.
    @@ -8098,7 +8098,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class SoftAbsRiemannianMetricSystem(RiemannianMetricSystem):
         """SoftAbs Riemmanian metric Hamiltonian system.
    @@ -8292,7 +8292,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def metric_func(self, state):
         return self.hess_neg_log_dens(state)
    @@ -8321,7 +8321,7 @@

    Returns

    Expand source code -Browse git +Browse git
    def vjp_metric_func(self, state):
         return self.mtp_neg_log_dens(state)
    @@ -8348,7 +8348,7 @@

    Returns

    Expand source code -Browse git +Browse git
    @cache_in_state_with_aux('pos', ('grad_neg_log_dens', 'neg_log_dens'))
     def hess_neg_log_dens(self, state):
    @@ -8396,7 +8396,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @cache_in_state_with_aux(
         'pos', ('hess_neg_log_dens', 'grad_neg_log_dens', 'neg_log_dens'))
    diff --git a/docs/docs/transitions.html b/docs/docs/transitions.html
    index a038d15..ff0ba9c 100644
    --- a/docs/docs/transitions.html
    +++ b/docs/docs/transitions.html
    @@ -195,7 +195,7 @@ 

    Module mici.transitions

    Expand source code -Browse git +Browse git
    """Markov transition kernels."""
     
    @@ -932,7 +932,7 @@ 

    References

    Expand source code -Browse git +Browse git
    def euclidean_no_u_turn_criterion(system, state_1, state_2, sum_mom):
         """No-U-turn termination criterion for Euclidean manifolds [1].
    @@ -1002,7 +1002,7 @@ 

    References

    Expand source code -Browse git +Browse git
    def riemannian_no_u_turn_criterion(system, state_1, state_2, sum_mom):
         """Generalized no-U-turn termination criterion on Riemannian manifolds [2].
    @@ -1052,7 +1052,7 @@ 

    Classes

    Expand source code -Browse git +Browse git
    class Transition(ABC):
         """Base class for Markov transition kernels.
    @@ -1109,7 +1109,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @abstractproperty
     def state_variables(self):
    @@ -1129,7 +1129,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @abstractproperty
     def statistic_types(self):
    @@ -1172,7 +1172,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @abstractmethod
     def sample(self, state, rng):
    @@ -1211,7 +1211,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class MomentumTransition(Transition):
         """Base class for momentum transitions.
    @@ -1312,7 +1312,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @abstractmethod
     def sample(self, state, rng):
    @@ -1354,7 +1354,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class IndependentMomentumTransition(MomentumTransition):
         """Independent momentum transition.
    @@ -1426,7 +1426,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def sample(self, state, rng):
         state.mom = self.system.sample_momentum(state, rng)
    @@ -1477,7 +1477,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class CorrelatedMomentumTransition(MomentumTransition):
         """Correlated (partial) momentum transition.
    @@ -1590,7 +1590,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def sample(self, state, rng):
         if self.mom_resample_coeff == 1:
    @@ -1625,7 +1625,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class IntegrationTransition(Transition):
         """Base class for integration transtions.
    @@ -1733,7 +1733,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    @abstractmethod
     def sample(self, state, rng):
    @@ -1783,7 +1783,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class MetropolisIntegrationTransition(IntegrationTransition):
         """Base for HMC methods using a Metropolis accept step to sample new state.
    @@ -1929,7 +1929,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class MetropolisStaticIntegrationTransition(MetropolisIntegrationTransition):
         """Static integration transition with Metropolis sampling of new state.
    @@ -2021,7 +2021,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def sample(self, state, rng):
         return self._sample_n_step(state, self.n_step, rng)
    @@ -2065,7 +2065,7 @@

    Args

    Expand source code -Browse git +Browse git
    class MetropolisRandomIntegrationTransition(MetropolisIntegrationTransition):
         """Random integration transition with Metropolis sampling of new state.
    @@ -2165,7 +2165,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def sample(self, state, rng):
         n_step = rng.integers(*self.n_step_range)
    @@ -2242,7 +2242,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class DynamicIntegrationTransition(IntegrationTransition):
         """Base class for dynamic integration transitions.
    @@ -2517,7 +2517,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def sample(self, state, rng):
         stats = {'n_step': 0, 'sum_metrop_accept_prob': 0., 'reject_prob': 1.}
    @@ -2636,7 +2636,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class MultinomialDynamicIntegrationTransition(DynamicIntegrationTransition):
         """Dynamic integration transition with multinomial sampling of new state.
    @@ -2796,7 +2796,7 @@ 

    Args

    Expand source code -Browse git +Browse git
    class SliceDynamicIntegrationTransition(DynamicIntegrationTransition):
         """Dynamic integration transition with slice sampling of new state.
    diff --git a/docs/docs/utils.html b/docs/docs/utils.html
    index 2b6a530..2184250 100644
    --- a/docs/docs/utils.html
    +++ b/docs/docs/utils.html
    @@ -61,7 +61,7 @@ 

    Module mici.utils

    Expand source code -Browse git +Browse git
    """Utility functions and classes."""
     
    @@ -292,7 +292,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def hash_array(array):
         """Compute hash of a NumPy array by hashing data as a byte sequence.
    @@ -326,7 +326,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def log1p_exp(val):
         """Numerically stable implementation of `log(1 + exp(val))`."""
    @@ -344,7 +344,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def log1m_exp(val):
         """Numerically stable implementation of `log(1 - exp(val))`."""
    @@ -364,7 +364,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def log_sum_exp(val1, val2):
         """Numerically stable implementation of `log(exp(val1) + exp(val2))`."""
    @@ -384,7 +384,7 @@ 

    Returns

    Expand source code -Browse git +Browse git
    def log_diff_exp(val1, val2):
         """Numerically stable implementation of `log(exp(val1) - exp(val2))`."""
    @@ -414,7 +414,7 @@ 

    Classes

    Expand source code -Browse git +Browse git
    class LogRepFloat(object):
         """Numerically stable logarithmic representation of positive float values.
    @@ -549,7 +549,7 @@ 

    Instance variables

    Expand source code -Browse git +Browse git
    @property
     def val(self):
    diff --git a/docs/index.html b/docs/index.html
    index bc0173c..477e32e 100644
    --- a/docs/index.html
    +++ b/docs/index.html
    @@ -88,6 +88,7 @@
     
  • Why Mici?
  • Related projects
  • Overview of package
  • +
  • Notebooks
  • Example: sampling on a torus
  • References
  • @@ -158,6 +159,68 @@

    Overview of package

  • DynamicSliceHMC - dynamic integration time Hamiltonian Monte Carlo with slice sampling from trajectory, equivalent to the original 'NUTS' algorithm (Hoffman and Gelman, 2014).
  • DynamicMultinomialHMC - dynamic integration time Hamiltonian Monte Carlo with multinomial sampling from trajectory, equivalent to the current default MCMC algorithm in Stan (Hoffman and Gelman, 2014; Betancourt, 2017).
  • +

    Notebooks

    +

    The manifold MCMC methods implemented in Mici have been used in several research projects. Below links are provided to a selection of Jupyter notebooks associated with these projects as demonstrations of how to use Mici and to illustrate some of the settings in which manifold MCMC methods can be computationally advantageous.

    + + + + + + + + + + + + + + + + +
    Manifold lifting: MCMC in the vanishing noise regime
    Open non-interactive version with nbviewer + + Render with nbviewer + +
    Open interactive version with Binder + + Launch with Binder + +
    Open interactive version with Google Colab + + Open in Colab + +
    + + + + + + + + + + + + + + + + + +
    Manifold MCMC methods for inference in diffusion models
    Open non-interactive version with nbviewer + + Render with nbviewer + +
    Open interactive version with Binder + + Launch with Binder + +
    Open interactive version with Google Colab + + Open in Colab + +
    +

    Example: sampling on a torus

    diff --git a/setup.py b/setup.py index 2f60a58..a3cf39e 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setuptools.setup( name='mici', - version='0.1.8', + version='0.1.9', author='Matt Graham', description=( 'MCMC samplers based on simulating Hamiltonian dynamics on a manifold'