sktime/sktime

[ENH] Refactor multiplication of classifier tests

Open

#2,255 opened on Mar 19, 2022

View on GitHub
 (8 comments) (0 reactions) (0 assignees)Python (1,192 forks)batch import
enhancementgood first issuemodule:classificationmodule:testsrefactor

Repository metrics

Stars
 (7,162 stars)
PR merge metrics
 (Avg merge 26d 10h) (86 merged PRs in 30d)

Description

Looking through the tests, I found that every classifier has a test file, and in it there is test_[classifiername]_on_unit_test_data and test_[classifiername]_on_basic_motions, with hundreds of lines of copy/paste. This is highly redundant and should be moved to a single file, using pytest.mark.parametrize and all_estimators.

#2257 makes a start how this could look like in the context of a classifier test suite refactor. I would suggest to branch off #2257 and follow the pattern. (assumes #2257 is merged. Until then, branch off #2257)

The recipe is as follows, for a given classifier:

  1. find the file test_[classifier] or similar, containing tests test_[classifier]_on_unit_test_data and possibly test_[classifier]_on_basic_motions or similar.
  2. move the parameter settings for the classifier into get_test_params, of the classifier class. Ensure it is the first element of the list returned. (also ensure there is no duplication with tests/_config, if there are still parameters there, also move them to get_test_params)
  3. add the "expected outputs" from the test_[classifier] file to classification/tests/_expected_outputs (follow the pattern)
  4. delete the file test_[classifier]
  5. ensure the unit tests pass. They should, if this has been done 1:1

Classifiers to refactor:

  • cboss
  • muse
  • tde
  • weasel
  • elastic_ensemble
  • shape_dtw
  • time_series_neighbors
  • probability_threshold
  • teaser
  • catch22_classifier
  • fresh_prince
  • matrix_profile_classifier
  • random_interval_classifier
  • signature_classifier
  • summary_classifier
  • tsfresh_classifier
  • hivecote_v1
  • hivecote_v2
  • cif
  • dtc
  • drcif
  • rise
  • stsf
  • tsf
  • arsenal
  • rocket_classifier
  • stc

Contributor guide