Skip to content

Remove assert_equal and co. from the tests #14215

Closed

Description

@NicolasHug

(Saving this for the upcoming sprints, ideally)

Let's remove the use of assert_equal, assert_greater, and assert_greater_equal in our tests.

These should be changed to simply assert a == b, assert a > b or assert a >= b.

For contributors: pick one of the modules below, and please comment on this issue saying e.g. "I'm working on cluster/tests", to avoid other contributors choosing the same modules.

You can see all the occurrences of the entries that need to be removed with e.g. git grep "assert_equal" sklearn/ensemble/tests/.

Modules that need cleaning

  • sklearn/cluster/tests/
  • sklearn/compose/tests/
  • sklearn/covariance/tests/
  • sklearn/cross_decomposition/tests/
  • sklearn/datasets/tests/
  • sklearn/decomposition/tests/
  • sklearn/ensemble/tests/
  • sklearn/feature_extraction/tests/
  • sklearn/feature_selection/tests/
  • sklearn/gaussian_process/tests/
  • sklearn/linear_model/tests/
  • sklearn/manifold/tests/
  • sklearn/metrics/cluster/tests/
  • sklearn/metrics/tests/
  • sklearn/mixture/tests/
  • sklearn/model_selection/tests/
  • sklearn/neighbors/tests/
  • sklearn/neural_network/tests/
  • sklearn/preprocessing/tests/
  • sklearn/random_projection.py
  • sklearn/semi_supervised/tests/
  • sklearn/svm/tests/
  • sklearn/tests/
  • sklearn/tree/tests/
  • sklearn/utils/estimator_checks.py
  • sklearn/utils/tests/

Activity

  1. changed the title [-]Remove assert_equal from tests[/-] [+]Remove assert_equal and co. from the tests[/+] on Jun 28, 2019
  2. rth commented on Jun 28, 2019

    @rth
    Member

    I agree that we need good issues for sprints, but I'm not sure this one is it.

    IMO it would be much preferable to use an automated tool (such as nose2pytest) to do this conversion in one go (or a few PRs). It would save time both for contributors and reviewers. There are 1700 occurrences of assert_equal, as a reviewer I would rather not wonder if there is a typo in one of them. At least with automated tools, if there are errors they would be more systematic and easier to detect.

  3. rth commented on Jul 1, 2019

    @rth
    Member

    With #14222 merged, there is only a few occurrences left (e.g. np.testing.assert_equal) those can probably be done manually. Also it would be nice to deprecate utils.assert_equal & co. so that they are not re-introduced in new PRs (there is still CI that fails on deprecation warnings right?)

  4. NicolasHug commented on Jul 1, 2019

    @NicolasHug
    MemberAuthor

    @adrinjalali are you working on it? Else I'll finish

  5. adrinjalali commented on Jul 1, 2019

    @adrinjalali
    Member

    No go ahead, thanks :)

  6. rth commented on Jul 2, 2019

    @rth
    Member

    I double checked that non of assert_equal etc are left in tests.

    Closing as resolved. Thanks @NicolasHug and @adrinjalali !

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions