Skip to content

nosetest failed in hyperstream/utils/containers.py", line 288 #9

@perellonieto

Description

@perellonieto

For some reason when running two consecutive tests that load the iris data in a stream an exception is raised:

First test issolated OK

$ nosetests tests/test_anomalies.py
.
----------------------------------------------------------------------
Ran 1 test in 0.655s

OK

Second test issolated OK

$ nosetests tests/test_datasets.py
.
----------------------------------------------------------------------
Ran 1 test in 0.479s

OK

All the tests FAIL

$ nosetests
.E
======================================================================
ERROR: test_iris (tests.test_datasets.TestDatasets)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/maikel/git/uob/SklearnHyperStream/tests/test_datasets.py", line 54, in test_iris
    data_tool.execute(sources=[], sink=data_stream, interval=ti)
  File "/home/maikel/git/uob/SklearnHyperStream/venv/local/lib/python2.7/site-packages/hyperstream/tool/tool.py", line 79, in execute
    sink.writer(stream_instance)
  File "/home/maikel/git/uob/SklearnHyperStream/venv/local/lib/python2.7/site-packages/hyperstream/channels/memory_channel.py", line 115, in writer
    self.data[stream.stream_id].append(document_collection)
  File "/home/maikel/git/uob/SklearnHyperStream/venv/local/lib/python2.7/site-packages/hyperstream/stream/stream_collections.py", line 42, in append
    self[instance.timestamp] = instance.value
  File "/home/maikel/git/uob/SklearnHyperStream/venv/local/lib/python2.7/site-packages/hyperstream/utils/containers.py", line 287, in __setitem__
    if not all(map(lambda a, b: a == b, zip(value[k], old[k]))):
TypeError: <lambda>() takes exactly 2 arguments (1 given)
-------------------- >> begin captured logging << --------------------
 # long logging removed by myself
root: DEBUG: found dataset
--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------
Ran 2 tests in 1.046s

FAILED (errors=1)

This is because the zip creates a structure with two components (a,b) and not two values a, b.

However, the problem comes from above in line 281 as it is trying to compare two arrays old[key] and value[key] and the result is an array with 3 trues.

In [9]: value[k]
Out[9]: array([[0, 0, 1]])

In [10]: old[k]
Out[10]: array([[0, 0, 1]])

In [11]: value[k] == old[k]
Out[11]: array([[ True,  True,  True]], dtype=bool)

I am not sure why is this comparison being done. I assume that it is because the stream with the same name is called in sequence during the tests and HyperStream looks if the streams are the same. However, do we need to extend the comparison to arrays? Or is there some proper way to do this?

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions