Skip to content

Commit

Permalink
Make it so pipeline operations on empty time series objects return a …
Browse files Browse the repository at this point in the history
…series with a collection instead of having code unceremoniously wipe out.
  • Loading branch information
montegoode committed Aug 18, 2016
1 parent c62eb17 commit 113cceb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
9 changes: 8 additions & 1 deletion pypond/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,14 @@ def to_keyed_collections(self):
Returns the _results attribute from a Pipeline object after processing.
Will contain Collection objects.
"""
return self.to(CollectionOut)
ret = self.to(CollectionOut)

if ret is not None:
return ret
else:
# return an empty dict so any calls to collection.get() won't cause
# things to unceremoniously blow up and just return None instead.
return dict()

def to(self, out, observer=None, options=Options()): # pylint: disable=invalid-name
"""
Expand Down
13 changes: 8 additions & 5 deletions pypond/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,14 @@ def set_collection(self, coll):
New TimeSeries with Collection coll
"""
res = TimeSeries(self)
res._collection = coll # pylint: disable=protected-access

# pylint: disable=protected-access

if coll is not None:
res._collection = coll
else:
res._collection = Collection()

return res

def bisect(self, dtime, b=0): # pylint: disable=invalid-name
Expand Down Expand Up @@ -1042,10 +1049,6 @@ def fill(self, field_spec=None, method='zero', fill_limit=None):
the fill operation.
"""

# if there is nothing to fill, then just bail
if self.size() == 0:
return self

pip = self.pipeline()

if method in ('zero', 'pad') or \
Expand Down

0 comments on commit 113cceb

Please sign in to comment.