Skip to content

test_NaiveBayes.py fails under PyPy3.5 v5.7 beta #1112

Closed

Description

@peterjc

See #953, on a branch I have modified setup.py to expect NumPy to be present under PyPy. This exposes a problem with hashing NumPy floats under the current latest version of PyPy3.

e.g. https://travis-ci.org/peterjc/biopython/jobs/214366116

======================================================================
ERROR: test_calculate_function_with_scale (test_NaiveBayes.NaiveBayesTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/peterjc/biopython/Tests/test_NaiveBayes.py", line 77, in setUp
    self.model = NaiveBayes.train(self.xs, self.ys)
  File "/home/travis/build/peterjc/biopython/build/lib.linux-x86_64-3.5/Bio/NaiveBayes.py", line 204, in train
    nb.p_conditional[i][j] = _contents(values)
  File "/home/travis/build/peterjc/biopython/build/lib.linux-x86_64-3.5/Bio/NaiveBayes.py", line 38, in _contents
    counts[item] = counts.get(item, 0) + term
TypeError: 'numpy.float64' objects are unhashable
======================================================================
ERROR: test_calculate_function_wrong_dimensionality (test_NaiveBayes.NaiveBayesTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/peterjc/biopython/Tests/test_NaiveBayes.py", line 77, in setUp
    self.model = NaiveBayes.train(self.xs, self.ys)
  File "/home/travis/build/peterjc/biopython/build/lib.linux-x86_64-3.5/Bio/NaiveBayes.py", line 204, in train
    nb.p_conditional[i][j] = _contents(values)
  File "/home/travis/build/peterjc/biopython/build/lib.linux-x86_64-3.5/Bio/NaiveBayes.py", line 38, in _contents
    counts[item] = counts.get(item, 0) + term
TypeError: 'numpy.float64' objects are unhashable
======================================================================
ERROR: test_classify_function (test_NaiveBayes.NaiveBayesTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/peterjc/biopython/Tests/test_NaiveBayes.py", line 77, in setUp
    self.model = NaiveBayes.train(self.xs, self.ys)
  File "/home/travis/build/peterjc/biopython/build/lib.linux-x86_64-3.5/Bio/NaiveBayes.py", line 204, in train
    nb.p_conditional[i][j] = _contents(values)
  File "/home/travis/build/peterjc/biopython/build/lib.linux-x86_64-3.5/Bio/NaiveBayes.py", line 38, in _contents
    counts[item] = counts.get(item, 0) + term
TypeError: 'numpy.float64' objects are unhashable
======================================================================
ERROR: test_train_function_input_lengths (test_NaiveBayes.NaiveBayesTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/peterjc/biopython/Tests/test_NaiveBayes.py", line 77, in setUp
    self.model = NaiveBayes.train(self.xs, self.ys)
  File "/home/travis/build/peterjc/biopython/build/lib.linux-x86_64-3.5/Bio/NaiveBayes.py", line 204, in train
    nb.p_conditional[i][j] = _contents(values)
  File "/home/travis/build/peterjc/biopython/build/lib.linux-x86_64-3.5/Bio/NaiveBayes.py", line 38, in _contents
    counts[item] = counts.get(item, 0) + term
TypeError: 'numpy.float64' objects are unhashable
======================================================================
ERROR: test_train_function_no_training_set (test_NaiveBayes.NaiveBayesTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/peterjc/biopython/Tests/test_NaiveBayes.py", line 77, in setUp
    self.model = NaiveBayes.train(self.xs, self.ys)
  File "/home/travis/build/peterjc/biopython/build/lib.linux-x86_64-3.5/Bio/NaiveBayes.py", line 204, in train
    nb.p_conditional[i][j] = _contents(values)
  File "/home/travis/build/peterjc/biopython/build/lib.linux-x86_64-3.5/Bio/NaiveBayes.py", line 38, in _contents
    counts[item] = counts.get(item, 0) + term
TypeError: 'numpy.float64' objects are unhashable
======================================================================
ERROR: test_train_function_uneven_dimension_of_training_set (test_NaiveBayes.NaiveBayesTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/peterjc/biopython/Tests/test_NaiveBayes.py", line 77, in setUp
    self.model = NaiveBayes.train(self.xs, self.ys)
  File "/home/travis/build/peterjc/biopython/build/lib.linux-x86_64-3.5/Bio/NaiveBayes.py", line 204, in train
    nb.p_conditional[i][j] = _contents(values)
  File "/home/travis/build/peterjc/biopython/build/lib.linux-x86_64-3.5/Bio/NaiveBayes.py", line 38, in _contents
    counts[item] = counts.get(item, 0) + term
TypeError: 'numpy.float64' objects are unhashable
======================================================================
ERROR: test_train_function_with_priors (test_NaiveBayes.NaiveBayesTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/peterjc/biopython/Tests/test_NaiveBayes.py", line 77, in setUp
    self.model = NaiveBayes.train(self.xs, self.ys)
  File "/home/travis/build/peterjc/biopython/build/lib.linux-x86_64-3.5/Bio/NaiveBayes.py", line 204, in train
    nb.p_conditional[i][j] = _contents(values)
  File "/home/travis/build/peterjc/biopython/build/lib.linux-x86_64-3.5/Bio/NaiveBayes.py", line 38, in _contents
    counts[item] = counts.get(item, 0) + term
TypeError: 'numpy.float64' objects are unhashable
----------------------------------------------------------------------

Underlying problem with NumPy under PyPy3.5 v5.7 beta, logged as https://bitbucket.org/pypy/pypy/issues/2518/pypy3-hashing-numpy-float-types which turned out to be a duplicate of https://bitbucket.org/pypy/pypy/issues/2479/numpyfloat64-objects-are-unhashable

This test passes with PyPy2 v5.7

Activity

  1. peterjc commented on Apr 3, 2017

    @peterjc
    MemberAuthor

    Turned out not to be a PyPy3 bug but a NumPy issue. Logged with NumPy as numpy/numpy#8887 which they have fixed with numpy/numpy#8888

  2. peterjc commented on Apr 4, 2017

    @peterjc
    MemberAuthor

    We can get TravisCI to pass by explicitly using the fixed (but unreleased) numpy in our Tox file, but that in turn means adding Cython as a NumPy non-release build dependency:

    pypy3 cython
    pypy3: git+git://github.com/numpy/numpy.git@dda43e50f085222c53ff75619fcff3694c45b740
    

    I think it would be simpler to skip this test if the float64 is unhashable with a message about updating NumPy for use on PyPy3.

  3. peterjc commented on Apr 4, 2017

    @peterjc
    MemberAuthor

    Resolved via c696fb8 - PyPy3 users will need to wait for the next NumPy release to use NaiveBayes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions