Skip to content

Commit

Permalink
Make database implementations iterable
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnVinyard committed May 13, 2016
1 parent eb8d54d commit 1f85a9f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion featureflow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.7.9'
__version__ = '0.8.9'

from model import BaseModel

Expand Down
3 changes: 3 additions & 0 deletions featureflow/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ def size(self, key):
def iter_ids(self):
raise NotImplementedError()

def __iter__(self):
return self.iter_ids()

def __contains__(self, key):
raise NotImplementedError()

Expand Down
13 changes: 13 additions & 0 deletions featureflow/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,19 @@ class MultipleRoots(BaseModel):


class BaseTest(object):

def test_can_iterate_over_database(self):
class D(BaseModel, self.Settings):
stream = Feature(TextStream, store=True)
words = Feature(Tokenizer, needs=stream, store=False)
count = JSONFeature(WordCount, needs=words, store=True)

D.process(stream='mary')
D.process(stream='humpty')
D.process(stream='cased')

self.assertEqual(3, len(list(self.Settings.database)))

def test_can_use_iterator_node(self):
iterable = chunked(StringIO(data_source['mary']), chunksize=3)

Expand Down

0 comments on commit 1f85a9f

Please sign in to comment.