IRC-SPHERE / HyperStreamOnlineLearning

Plugins for Online Learning (supervised or unsupervised) in HyperStream
MIT License
3 stars 1 forks source link

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

Open perellonieto opened 6 years ago

perellonieto commented 6 years ago

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?

tdiethe commented 6 years ago

Looks like a bug, I'll investigate

tdiethe commented 6 years ago

Ok I think this was a python 2/3 change, should now be fixed. I also had to change the name of the plugin directory so that it doesn't conflict with the main one.

perellonieto commented 6 years ago

@tdiethe what is the change that should fix the problem? Is it n the last commit to the change of folders? Or is it some change in the main HyperStream? Maybe I have still the error because I am using Python2.7? If that is the case and it is complicated to solve we could move to Python3 as a workaround.

tdiethe commented 6 years ago

Change is in main hyperstream

On 1 Dec 2017, at 17:27, Miquel Perelló Nieto notifications@github.com<mailto:notifications@github.com> wrote:

@tdiethehttps://github.com/tdiethe what is the change that should fix the problem? Is it n the last commit to the change of folders? Or is it some change in the main HyperStream? Maybe I have still the error because I am using Python2.7? If that is the case and it is complicated to solve we could move to Python3 as a workaround.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/IRC-SPHERE/HyperStreamOnlineLearning/issues/9#issuecomment-348556323, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABDyIFpdcT6xVh1qvzRsm89f0p2AjEPPks5s8DbxgaJpZM4QyhQe.

tdiethe commented 6 years ago

Thinking that the time has come to start dropping py2 support anyway:

http://www.python3statement.org/ https://github.com/numpy/numpy/blob/master/doc/neps/dropping-python2.7-proposal.rst