Skip to content

Commit

Permalink
Merge branch 'master' of [email protected]:pybrain/pybrain.git
Browse files Browse the repository at this point in the history
  • Loading branch information
schaul committed Mar 14, 2013
2 parents a3bfe01 + de5bfc8 commit 6e1bd1e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pybrain/structure/modules/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, indim, outdim, name=None, **args):
dimension of outdim."""
self.setArgs(name=name, **args)

# Make sure that it does not matter wether Module.__init__ is called
# Make sure that it does not matter whether Module.__init__ is called
# before or after adding elements to bufferlist in subclasses.
# TODO: it should be possible to use less than these buffers. For some
# methods, an error is not completely necessary. (e.g. evolution)
Expand Down
2 changes: 1 addition & 1 deletion pybrain/tests/unittests/datasets/test_datasets_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
>>> d = datasets.dataset.DataSet()
>>> d.addField('input', 2)
>>> d.data['input']
array([], shape=(0, 2), dtype=...)
array([], shape=(0..., 2...), dtype=...)
Build up a DataSet for testing:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
Internal Tests:
====================
>>> from pybrain.supervised.knn.lsh import nearoptimal
Let's make a hypercube for 2 dimensions.
>>> dim = 2
Expand All @@ -21,7 +19,7 @@
>>> m = nearoptimal.MultiDimHash(dim=dim, omega=omega, prob=0.8)
>>> m.radius
1.189207115002721
1.189207115002...
>>> m.radiusSquared
1.41421356237309...
Expand Down Expand Up @@ -118,6 +116,7 @@
"""

from pybrain.tests import runModuleTestSuite
from pybrain.supervised.knn.lsh import nearoptimal

if __name__ == "__main__":
runModuleTestSuite(__import__('__main__'))
19 changes: 12 additions & 7 deletions pybrain/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,22 +456,27 @@ def flood(stepFunction, fullSet, initSet, relevant=None):
:key relevant: (optional) list of relevant elements: stop once all relevant elements are found.
"""
full = set(fullSet)
flooded = full.intersection(set(initSet))

if relevant is None:
relevant = full.copy()
if fullSet is None:
flooded = set(initSet)
else:
full = set(fullSet)
flooded = full.intersection(set(initSet))
if relevant is None:
relevant = full.copy()
if relevant:
relevant = set(relevant)

change = flooded.copy()
while len(change)>0:
new = set()
for m in change:
new.update(full.intersection(stepFunction(m)))
if fullSet is None:
new.update(stepFunction(m))
else:
new.update(full.intersection(stepFunction(m)))
change = new.difference(flooded)
flooded.update(change)
if relevant.issubset(flooded):
if relevant is not None and relevant.issubset(flooded):
break
return list(flooded)

Expand Down

0 comments on commit 6e1bd1e

Please sign in to comment.