Skip to content

Commit

Permalink
Modified logic while inserting batch dimensions to parametrization
Browse files Browse the repository at this point in the history
  • Loading branch information
Sayam753 committed Nov 21, 2020
1 parent d168d21 commit ae9dd49
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pymc3/distributions/multivariate.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,9 @@ def random(self, point=None, size=None):
param_attribute = getattr(self, "chol_cov" if self._cov_type == "chol" else self._cov_type)
mu, param = draw_values([self.mu, param_attribute], point=point, size=size)
check_fast_drawable_or_point = lambda param, point: is_fast_drawable(param) or (
point and hasattr(param, "model") and param.name in point
point and param.name in point
)

if tuple(self.shape):
dist_shape = tuple(self.shape)
batch_shape = dist_shape[:-1]
Expand All @@ -288,7 +289,7 @@ def random(self, point=None, size=None):
mu = mu.reshape(size + (1,) * extra_dims + mu.shape[len(size) :])

# Adding batch dimensions to parametrization
if not check_fast_drawable_or_point(param_attribute, point):
if size and param.shape[:-2] == size:
param = param.reshape(size + (1,) * len(batch_shape) + param.shape[-2:])

mu = np.broadcast_to(mu, output_shape)
Expand Down

0 comments on commit ae9dd49

Please sign in to comment.