Skip to content

Commit

Permalink
fixup! Added Tile distribution to tile samples
Browse files Browse the repository at this point in the history
  • Loading branch information
hunse committed Oct 28, 2016
1 parent 1a4222a commit a6bf9f1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions nengo_extras/dists.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import absolute_import

import numpy as np

from nengo.dists import Distribution
Expand Down Expand Up @@ -76,12 +78,16 @@ class Tile(Distribution):

def __init__(self, values):
super(Tile, self).__init__()
self.values = values

values = np.asarray(values)
self.values = values.reshape(-1, 1) if values.ndim < 2 else values

def __repr__(self):
return "Tile(values=%s)" % (self.values)

def sample(self, n, d=None, rng=np.random):
out1 = d is None
d = 1 if d is None else d
nv, dv = self.values.shape

if n > nv or d > dv:
Expand All @@ -90,4 +96,5 @@ def sample(self, n, d=None, rng=np.random):
else:
values = self.values

return values[:n, :d]
values = values[:n, :d]
return values[:, 0] if out1 else values

0 comments on commit a6bf9f1

Please sign in to comment.