Skip to content

Commit

Permalink
Update for failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
justinGilmer committed May 18, 2023
1 parent 82bcf5e commit d5ff32d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
10 changes: 7 additions & 3 deletions btrdb/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import re
import json
import uuid as uuidlib
import warnings
from copy import deepcopy
from collections.abc import Sequence

Expand Down Expand Up @@ -841,7 +842,10 @@ class StreamSetBase(Sequence):

def __init__(self, streams):
self._streams = streams
self._btrdb = self._streams[0]._btrdb
try:
self._btrdb = self._streams[0]._btrdb
except Exception as e:
warnings.warn(f"Issue setting btrdb object from stream: {e}")
self._pinned_versions = None

self.filters = []
Expand Down Expand Up @@ -967,7 +971,7 @@ def earliest(self):
lambda s: s.nearest(start, version=versions.get(s.uuid, 0), backward=False),
self._streams,
)
for point in earliest_points_gen:
for point, _ in earliest_points_gen:
earliest.append(point)

return tuple(earliest)
Expand All @@ -994,7 +998,7 @@ def latest(self):
lambda s: s.nearest(start, version=versions.get(s.uuid, 0), backward=True),
self._streams,
)
for point in latest_points_gen:
for point, _ in latest_points_gen:
latest.append(point)

return tuple(latest)
Expand Down
5 changes: 3 additions & 2 deletions btrdb/transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,9 @@ def to_array(streamset, agg="mean"):
segment.append(point.value)
else:
segment.append(getattr(point, agg))
results.append(segment)
return np.array(results)
results.append(np.array(segment))
print(results)
return np.array(results, dtype=object)


def to_dict(streamset, agg="mean", name_callable=None):
Expand Down
8 changes: 6 additions & 2 deletions tests/btrdb/test_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"""
Testing package for the btrdb stream module
"""

import concurrent.futures
##########################################################################
## Imports
##########################################################################
Expand Down Expand Up @@ -58,6 +58,8 @@ def stream1():
type(stream).name = PropertyMock(return_value="gala")
stream.tags = Mock(return_value={"name": "gala", "unit": "volts"})
stream.annotations = Mock(return_value=({"owner": "ABC", "color": "red"}, 11))
stream._btrdb = Mock()
stream._btrdb._executor = concurrent.futures.ThreadPoolExecutor()
return stream


Expand All @@ -72,6 +74,8 @@ def stream2():
type(stream).name = PropertyMock(return_value="blood")
stream.tags = Mock(return_value={"name": "blood", "unit": "amps"})
stream.annotations = Mock(return_value=({"owner": "ABC", "color": "orange"}, 22))
stream._btrdb = Mock()
stream._btrdb._executor = Mock()
return stream


Expand Down Expand Up @@ -1181,7 +1185,7 @@ def test_earliest(self, stream1, stream2):
Assert earliest returns correct time code
"""
streams = StreamSet([stream1, stream2])
assert streams.latest() == (RawPoint(time=10, value=1), RawPoint(time=20, value=1))
assert streams.earliest() == (RawPoint(time=10, value=1), RawPoint(time=20, value=1))


def test_latest(self, stream1, stream2):
Expand Down

0 comments on commit d5ff32d

Please sign in to comment.