Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Enable classification tests #5168

Merged
merged 3 commits into from
Jan 18, 2021

Conversation

JakaKokosar
Copy link
Member

Issue

Classification tests did not run.

@JakaKokosar JakaKokosar changed the title Enable classification tests [FIX] Enable classification tests Jan 8, 2021
@JakaKokosar
Copy link
Member Author

Tests fail with:

======================================================================
ERROR: test_larger_model (test_base.TestModelMapping)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/orange3/orange3/.tox/coverage/lib/python3.6/site-packages/Orange/classification/tests/test_base.py", line 48, in test_larger_model
    vale[vale != 0] - 1)
  File "/home/runner/work/orange3/orange3/.tox/coverage/lib/python3.6/site-packages/numpy/testing/_private/utils.py", line 931, in assert_array_equal
    verbose=verbose, header='Arrays are not equal')
  File "/home/runner/work/orange3/orange3/.tox/coverage/lib/python3.6/site-packages/numpy/testing/_private/utils.py", line 840, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Arrays are not equal

Mismatched elements: 100 / 100 (100%)
Max absolute difference: 1
Max relative difference: 1.
 x: array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1,
       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
       1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2,...
 y: array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,...

======================================================================
ERROR: test_model_different (test_base.TestModelMapping)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/orange3/orange3/.tox/coverage/lib/python3.6/site-packages/Orange/classification/tests/test_base.py", line 138, in test_model_different
    np.testing.assert_array_equal(prob1[valp0 == 1, 1], 1)
  File "/home/runner/work/orange3/orange3/.tox/coverage/lib/python3.6/site-packages/numpy/testing/_private/utils.py", line 931, in assert_array_equal
    verbose=verbose, header='Arrays are not equal')
  File "/home/runner/work/orange3/orange3/.tox/coverage/lib/python3.6/site-packages/numpy/testing/_private/utils.py", line 840, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Arrays are not equal

Mismatched elements: 48 / 48 (100%)
Max absolute difference: 0.41354173
Max relative difference: 0.41354173
 x: array([0.999999, 0.999998, 0.999999, 0.999998, 0.999999, 0.999997,
       0.999998, 0.999998, 0.999998, 0.999998, 0.999999, 0.999997,
       0.999999, 0.999999, 1.      , 0.999999, 0.999999, 0.999999,...
 y: array(1)

======================================================================
ERROR: test_smaller_model (test_base.TestModelMapping)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/orange3/orange3/.tox/coverage/lib/python3.6/site-packages/Orange/classification/tests/test_base.py", line 89, in test_smaller_model
    np.testing.assert_array_equal(val0, val[50:] - 1)
  File "/home/runner/work/orange3/orange3/.tox/coverage/lib/python3.6/site-packages/numpy/testing/_private/utils.py", line 931, in assert_array_equal
    verbose=verbose, header='Arrays are not equal')
  File "/home/runner/work/orange3/orange3/.tox/coverage/lib/python3.6/site-packages/numpy/testing/_private/utils.py", line 840, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Arrays are not equal

Mismatched elements: 100 / 100 (100%)
Max absolute difference: 1.
Max relative difference: 1.
 x: array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
       1., 1., 1., 2., 1., 1., 1., 1., 1., 1., 2., 1., 1., 1., 1., 1., 2.,
       1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 2.,...
 y: array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 1.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.,...

======================================================================
ERROR: test_fit_storage (test_calibration.TestCalibratedLearner)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.6.12/x64/lib/python3.6/unittest/mock.py", line 1183, in patched
    return func(*args, **keywargs)
  File "/home/runner/work/orange3/orange3/.tox/coverage/lib/python3.6/site-packages/Orange/classification/tests/test_calibration.py", line 190, in test_fit_storage
    cal_model = cal_learner(data)
  File "/home/runner/work/orange3/orange3/.tox/coverage/lib/python3.6/site-packages/Orange/base.py", line 136, in __call__
    model = self._fit_model(data)
  File "/home/runner/work/orange3/orange3/.tox/coverage/lib/python3.6/site-packages/Orange/base.py", line 148, in _fit_model
    return self.fit_storage(data)
  File "/home/runner/work/orange3/orange3/.tox/coverage/lib/python3.6/site-packages/Orange/classification/calibration.py", line 164, in fit_storage
    model = res.models[0, 0]
TypeError: 'Mock' object is not subscriptable

======================================================================
ERROR: test_fit_storage (test_calibration.TestThresholdLearner)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.6.12/x64/lib/python3.6/unittest/mock.py", line 1183, in patched
    return func(*args, **keywargs)
  File "/home/runner/work/orange3/orange3/.tox/coverage/lib/python3.6/site-packages/Orange/classification/tests/test_calibration.py", line 89, in test_fit_storage
    thresh_model = thresh_learner(data)
  File "/home/runner/work/orange3/orange3/.tox/coverage/lib/python3.6/site-packages/Orange/base.py", line 136, in __call__
    model = self._fit_model(data)
  File "/home/runner/work/orange3/orange3/.tox/coverage/lib/python3.6/site-packages/Orange/base.py", line 148, in _fit_model
    return self.fit_storage(data)
  File "/home/runner/work/orange3/orange3/.tox/coverage/lib/python3.6/site-packages/Orange/classification/calibration.py", line 78, in fit_storage
    model = res.models[0, 0]
TypeError: 'Mock' object is not subscriptable

@codecov
Copy link

codecov bot commented Jan 15, 2021

Codecov Report

Merging #5168 (458e866) into master (f7fd48c) will increase coverage by 0.28%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #5168      +/-   ##
==========================================
+ Coverage   84.77%   85.06%   +0.28%     
==========================================
  Files         286      298      +12     
  Lines       60106    60813     +707     
==========================================
+ Hits        50957    51728     +771     
+ Misses       9149     9085      -64     

ix[:100]]):
class_var = DiscreteVariable(
"iris",
values=tuple(n for j, n in enumerate(classes) if n != i))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be j != i

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is fixed the other functions do not need changes. I added a fixup commit which returns them into their original state. @janezd, could you confirm if that makes sense?

@markotoplak
Copy link
Member

@janezd, I simplified test changes: only the function generating test tables needed changes; I left the others as they were in master.

@markotoplak markotoplak merged commit fd59605 into biolab:master Jan 18, 2021
@janezd
Copy link
Contributor

janezd commented Jan 19, 2021

@markotoplak, thanks, your fix is the correct one.

I identified the problem in the setup, incorrectly fixed it, and then looked at failing tests for long enough to convince myself that this is how backmapping works like. :(

@JakaKokosar JakaKokosar deleted the enable_classification_tests branch April 1, 2022 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants