Skip to content

Commit

Permalink
forced derived shape components to be tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonwillard committed Jan 2, 2017
1 parent 9563d8a commit e6e1b4a
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions pymc3/distributions/multivariate.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def __init__(self, mu, tau, ndim=None, size=None, dtype=None, *args,

self.median = self.mode = self.mean = self.mu
# TODO: How do we want to use ndim?
shape_supp = self.mu.shape[-1]
shape_ind = self.mu.shape[:-1]
shape_supp = (self.mu.shape[-1],)
shape_ind = tuple(self.mu.shape[:-1])

if self.mu.ndim > 0:
bcast = (False,) * (1 + tt.get_vector_length(shape_ind))
Expand Down Expand Up @@ -261,8 +261,8 @@ def __init__(self, a, transform=transforms.stick_breaking, ndim=None, size=None,
self.dist_params = (self.a,)

# TODO: How do we want to use ndim?
shape_supp = self.a.shape[-1]
shape_ind = self.a.shape[:-1]
shape_supp = (self.a.shape[-1],)
shape_ind = tuple(self.a.shape[:-1])

# FIXME: this isn't correct/ideal
if self.a.ndim > 0:
Expand Down Expand Up @@ -358,7 +358,7 @@ def __init__(self, n, p, ndim=None, size=None, dtype=None, *args,

# TODO: check that n == len(p)?
# TODO: How do we want to use ndim?
shape_supp = self.n
shape_supp = (self.n,)
shape_ind = ()

# FIXME: this isn't correct/ideal
Expand Down Expand Up @@ -500,12 +500,11 @@ def __init__(self, n, V, ndim=None, size=None, dtype=None, *args,
self.dist_params = (self.n, self.V)

# TODO: How do we want to use ndim?
shape_supp = self.V.shape[-1]
shape_supp = (self.V.shape[-1],)
shape_ind = ()

self.mode = tt.switch(1 * (self.n >= shape_supp + 1), (self.n -
shape_supp - 1)
* self.V, np.nan)
self.mode = tt.switch(1 * (self.n >= shape_supp + 1),
(self.n - shape_supp - 1) * self.V, np.nan)
self.mean = self.n * self.V

# FIXME: this isn't correct/ideal
Expand Down Expand Up @@ -662,19 +661,18 @@ def __init__(self, n, p, ndim=None, size=None, dtype=None, *args, **kwargs):
self.n = tt.as_tensor_variable(n, ndim=0)
self.p = tt.as_tensor_variable(p, ndim=0)

self.dist_params = (self.n, self.p)

# TODO: How do we want to use ndim?
n_elem = (self.p * (self.p - 1) / 2)
shape_supp = n_elem
shape_supp = (n_elem,)
self.mean = tt.zeros(n_elem)

# FIXME: triu, bcast, etc.
self.tri_index = tt.zeros((self.p, self.p), dtype=int)
self.tri_index[tt.triu(self.p, k=1)] = tt.arange(n_elem)
self.tri_index[tt.triu(self.p, k=1)[::-1]] = tt.arange(n_elem)

self.dist_params = (self.n, self.p)

# TODO: do this correctly; what about replications?
shape_ind = ()

# FIXME: this isn't correct/ideal
Expand Down

0 comments on commit e6e1b4a

Please sign in to comment.