Skip to content

TST Extend tests for scipy.sparse.*array #27090

Closed

Description

@jjerphan

SciPy sparse matrices (i.e. scipy.sparse.*matrix) are tested but their sparse arrays counterpart (i.e. scipy.sparse.*array) aren't yet will become ubiquitous (see #26418).

Tests and their parameterizations (when they exist) must be adapted to include scipy.sparse.*array conditionally to versions of SciPy that support them (i.e. scipy>=1.8).

Steps

ℹ️ You can take #27095 as an example for your PRs.

1. Choose one of the files to adapt

  • Indicate the file you are adapting (later referred to as <filename>) on this issue so no-one ends up duplicating work. E.g.
Hi, I am starting working on `<filename>`.

Please double check as this list might be outdated, but candidate files might be:

2. Perform the following (non-exhaustive) changes for <filename>

  • Add test parametrization for tests using *_matrix (for instance see eda7b16)
  • Adapt existing test parametrization to test against sparse array (for instance see 6717f99)
  • Extend or add test checking that type of sparse containers are preserve by functions. E.g. adding tests like (as proposed by TST Extend tests for scipy.sparse.*array #27090 (comment)):
    sparse_input = sparse_container(...)
    sparse_output = process_sparse_container(sparse_input)
    
    assert isinstance(sparse_output, type(sparse_input))
  • Run tests for this file:
    # Run all the test in <filename>
    pytest <filename> -k test_to_run
    
    # Run a specific test in this file
    pytest <filename> -k test_to_run
    
  • If tests fail, the tested implementations has to be adapted (let us know if you need help)

3. Create a pull request

  • Use this title:
TST Extend tests for `scipy.sparse.*array` in `<filename>`
  • Mention this issue in its description:
Towards #27090.

4. Once the pull request is created

  • Ignore the error on the CI related the changelog: those PR need not update the changelog since nothing has changed for the users (until this issue is resolved), and maintainers must label PRs as "No Changelog Needed" for the check to be deactivated.

Activity

  1. added
    Meta-issue
    good first issue
    on Aug 18, 2023
  2. jjerphan commented on Aug 18, 2023

    @jjerphan
    MemberAuthor

    Hi, I am starting working on sklearn/cluster/tests/test_affinity_propagation.py.

  3. changed the title [-]TST Extend test for `scipy.sparse.*array`[/-] [+]TST Extend tests for `scipy.sparse.*array`[/+] on Aug 18, 2023
  4. added
    module:test-suite
    on Aug 18, 2023
  5. msgomez06 commented on Aug 18, 2023

    @msgomez06
    Contributor

    Hi! I'm starting work on sklearn/cluster/tests/test_dbscan.py

  6. msgomez06 commented on Aug 18, 2023

    @msgomez06
    Contributor

    Hi! I'm starting work on sklearn/cluster/tests/test_birch.py

  7. Kislovskiy commented on Aug 18, 2023

    @Kislovskiy
    Contributor

    Hi, I am starting working on sklearn/cluster/tests/test_bisect_k_means.py.

  8. marenwestermann commented on Aug 18, 2023

    @marenwestermann
    Member

    Working on sklearn/cluster/tests/test_optics.py

  9. vvkrddy commented on Aug 18, 2023

    @vvkrddy
    Contributor

    I am working on sklearn/cluster/tests/test_hierarchical.py.

  10. Kislovskiy commented on Aug 18, 2023

    @Kislovskiy
    Contributor

    I am working on sklearn/cluster/tests/test_k_means.py.

  11. ivirshup commented on Aug 18, 2023

    @ivirshup
    Contributor

    @jjerphan I think we should add a step for testing that types are maintained in cases where a sparse array can be returned. E.g.:

    f(X: *_array, ...) -> *_array
    f(X: *_matrix, ...) -> *_matrix
    
  12. jjerphan commented on Aug 18, 2023

    @jjerphan
    MemberAuthor

    Indeed; thanks for mentioning that, @ivirshup. I updated the issue's description accordingly.

  13. ivirshup commented on Aug 18, 2023

    @ivirshup
    Contributor

    If we have to modify the code to support the *_array classes, is this considered a fix or a feature? Wondering where this goes in the changelog.

  14. jjerphan commented on Aug 18, 2023

    @jjerphan
    MemberAuthor

    I would consider this support and an enhancement, I think.

  15. 157 remaining items

  16. work-mohit commented on Oct 1, 2023

    @work-mohit
    Contributor

    Hi, I am starting working on sklearn/svm/tests/test_sparse.py.

    Hey @KartikeyBartwal , I already did some work on this previously. If you wanna help please let me know, I'm making a draft PR , will mention you.

    Please share the updates from your side. I'll try to contribute to the PR
    #27511

  17. added
    good first PR to review
    on Oct 8, 2023
  18. jjerphan commented on Nov 12, 2023

    @jjerphan
    MemberAuthor

    After a brief discussion with @Charlie-XIAO in #27723 (comment), we might want to clarify the changelog entry which has been introduced to clarify explicitly that all the interfaces supporting sparse matrices now explicitly support sparse areays.

    What do you think?

  19. StefanieSenger commented on Nov 12, 2023

    @StefanieSenger
    Member

    After a brief discussion with @Charlie-XIAO in #27723 (comment), we might want to clarify the changelog entry which has been introduced to clarify explicitly that all the interfaces supporting sparse matrices now explicitly support sparse areays.
    What do you think?

    I agree, with modifying the tests, the support for sparse arrays is made sure, but not introduced. Changing this phrase from the changelog maybe, into "now tested to support SciPy sparse array"?

    Several estimators are now supporting SciPy sparse arrays. The following functions and classes are impacted:

  20. jjerphan commented on Nov 12, 2023

    @jjerphan
    MemberAuthor

    When this issue is closed, I think we can adapt the changelog entry to mention that all interfaces supporting sparse matrices now support sparse arrays (potentially removing the enumeration of interfaces if it is too verbose).

    What do you think? Is this sufficient?

  21. y-vectorfield commented on Nov 18, 2023

    @y-vectorfield

    Hello, I will be starting working on sklearn/utils/_testing.py.
    @jjerphan, CC) @norbusan, this is my first contribution for sklearn.
    If I meet with trouble, can you advise me??

  22. jjerphan commented on Nov 18, 2023

    @jjerphan
    MemberAuthor

    Hello @y-vectorfield,

    Thank you. Yes, we will be there to help you.

  23. y-vectorfield commented on Nov 26, 2023

    @y-vectorfield

    Hello, @jjerphan,
    I modified tests in sklearn/utils/_testing.py and submitted a draft version of PR(#27847).
    I have two questions.
    First: Is my modification correct?
    I modified the codes as follows.
    https://github.com/scikit-learn/scikit-learn/pull/27847/files

    Second: I could not test using pytest.
    I implemented the modified codes, however, I could not run the tests...

    $ pytest sklearn/utils/_testing.py 
    ======================================================================================== test session starts =========================================================================================
    platform linux -- Python 3.8.18, pytest-7.4.3, pluggy-1.3.0
    rootdir: /home/skuser/dev/scikit-learn
    configfile: setup.cfg
    plugins: cov-4.1.0
    collected 2 items                                                                                                                                                                                    
    
    sklearn/utils/_testing.py ss                                                                                                                                                                   [100%]
    
    ========================================================================================= 2 skipped in 0.07s =========================================================================================
  24. wmin401 commented on Feb 19, 2024

    @wmin401

    I made PRs on sklearn/utils/tests/test_param_validation.py #27317.
    I am first-timer and it is my first PRs. I would appreciate it if you give me a advice with my PRs.
    I extended the existing test to cover scipy.sparse.*array objects and changed the parameter validation from sparse container where necessary.

    Here is my PRs below:
    #28456

  25. Charlie-XIAO commented on Feb 19, 2024

    @Charlie-XIAO
    Contributor

    @wmin401 I'm sorry but there is #27950 open for that file already. I'm afraid there are no more tasks left for this issue.

    Perhaps @jjerphan the "good first issue" tag should be removed now?

  26. removed
    good first issue
    on Feb 21, 2024
  27. Charlie-XIAO commented on Feb 28, 2024

    @Charlie-XIAO
    Contributor

    The last PRs have been merged. Thanks a lot everyone!

    @jjerphan I think all tasks here are completed. Should we close now?

  28. jjerphan commented on Feb 28, 2024

    @jjerphan
    MemberAuthor

    Thank you for the heads-up, @Charlie-XIAO !

    I will take some time to double-check it before we close it as completed.

  29. jjerphan commented on Mar 1, 2024

    @jjerphan
    MemberAuthor

    Everything looks good to me.

    Thank you everyone for your involvement!

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

    Meta-issueSprintgood first PR to reviewmodule:test-suite

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions