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

Pytest Warnings #210

Closed
wants to merge 1 commit into from
Closed

Pytest Warnings #210

wants to merge 1 commit into from

Conversation

purva-thakre
Copy link
Collaborator

Description

Fixes #196

Todos

Notable points that this PR has either accomplished or will accomplish.

  • TODO 1

Questions

  • Question1

Status

  • Ready to go

@codecov
Copy link

codecov bot commented Oct 30, 2023

Codecov Report

Merging #210 (149e951) into master (74f8b85) will increase coverage by 0.0%.
Report is 1 commits behind head on master.
The diff coverage is 100.0%.

❗ Current head 149e951 differs from pull request most recent head ade9c8a. Consider uploading reports for the commit ade9c8a to get more accurate results

@@          Coverage Diff           @@
##           master    #210   +/-   ##
======================================
  Coverage    95.9%   95.9%           
======================================
  Files         146     146           
  Lines        2961    2962    +1     
  Branches      725     725           
======================================
+ Hits         2840    2841    +1     
  Misses         76      76           
  Partials       45      45           
Files Coverage Δ
toqito/matrices/gell_mann.py 100.0% <100.0%> (ø)
toqito/matrices/pauli.py 100.0% <ø> (ø)
toqito/perms/symmetric_projection.py 100.0% <100.0%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@purva-thakre
Copy link
Collaborator Author

purva-thakre commented Oct 30, 2023

@vprusso Am I right to assume this warning is due to some unresolved deprecation warning in scipy and unrelated to toqito?

tests/test_channel_metrics/test_completely_bounded_trace_norm.py::test_cb_trace_norm_unitaries_channel
tests/test_channel_metrics/test_completely_bounded_trace_norm.py::test_cb_trace_norm_unitaries_channel
tests/test_channel_metrics/test_completely_bounded_trace_norm.py::test_cb_trace_norm_unitaries_channel
tests/test_channel_metrics/test_completely_bounded_trace_norm.py::test_cb_trace_norm_unitaries_channel
  /root_path/.pyenv/versions/3.11.5/envs/venv_poetry/lib/python3.11/site-packages/scipy/sparse/_sputils.py:44: DeprecationWarning: np.find_common_type is deprecated.  Please use `np.result_type` or `np.promote_types`.
  See https://numpy.org/devdocs/release/1.25.0-notes.html and the docs for more information.  (Deprecated NumPy 1.25)
    upcast = np.find_common_type(args, [])

Edit: Similar issues for cvxpy and pytest. I think these warnings won't be fixed in this repo.
https://github.com/vprusso/toqito/actions/runs/6686601698/job/18166160699?pr=210#step:5:718
https://github.com/vprusso/toqito/actions/runs/6686601698/job/18166160699?pr=210#step:5:668

@vprusso
Copy link
Owner

vprusso commented Oct 30, 2023

@vprusso Am I right to assume this warning is due to some unresolved deprecation warning in scipy and unrelated to toqito?

tests/test_channel_metrics/test_completely_bounded_trace_norm.py::test_cb_trace_norm_unitaries_channel
tests/test_channel_metrics/test_completely_bounded_trace_norm.py::test_cb_trace_norm_unitaries_channel
tests/test_channel_metrics/test_completely_bounded_trace_norm.py::test_cb_trace_norm_unitaries_channel
tests/test_channel_metrics/test_completely_bounded_trace_norm.py::test_cb_trace_norm_unitaries_channel
  /root_path/.pyenv/versions/3.11.5/envs/venv_poetry/lib/python3.11/site-packages/scipy/sparse/_sputils.py:44: DeprecationWarning: np.find_common_type is deprecated.  Please use `np.result_type` or `np.promote_types`.
  See https://numpy.org/devdocs/release/1.25.0-notes.html and the docs for more information.  (Deprecated NumPy 1.25)
    upcast = np.find_common_type(args, [])

Edit: Similar issues for cvxpy and pytest. I think these warnings won't be fixed in this repo. https://github.com/vprusso/toqito/actions/runs/6686601698/job/18166160699?pr=210#step:5:718 https://github.com/vprusso/toqito/actions/runs/6686601698/job/18166160699?pr=210#step:5:668

Yes, that seems to be correct. As it appears to be complaining about np.find_common_type (which we don't use).

However, when attempting to run the tests for this module I don't appear to be obtaining the same warning.

Indeed, when running it, I do obtain scipy warnings, but they are different:

% pytest tests/test_channel_metrics/test_completely_bounded_trace_norm.py 
==================================================================== test session starts =====================================================================
platform darwin -- Python 3.10.11, pytest-7.3.1, pluggy-1.0.0
rootdir: /Users/vrusso/Projects/research/toqito
collected 3 items                                                                                                                                            

tests/test_channel_metrics/test_completely_bounded_trace_norm.py ...                                                                                   [100%]

====================================================================== warnings summary ======================================================================
toqito/matrices/gell_mann.py:8
  /Users/vrusso/Projects/research/toqito/toqito/matrices/gell_mann.py:8: DeprecationWarning: Please use `csr_matrix` from the `scipy.sparse` namespace, the `scipy.sparse.csr` namespace is deprecated.
    def gell_mann(ind: int, is_sparse: bool = False) -> np.ndarray | scipy.sparse.csr.csr_matrix:

toqito/matrices/pauli.py:13
  /Users/vrusso/Projects/research/toqito/toqito/matrices/pauli.py:13: DeprecationWarning: Please use `csr_matrix` from the `scipy.sparse` namespace, the `scipy.sparse.csr` namespace is deprecated.
    ) -> np.ndarray | sparse.csr.csr_matrix:

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=============================================================== 3 passed, 2 warnings in 2.47s ================================================================

For reference, I tried the above with scipy==1.10.1 and numpy==1.26.1. I also noticed that when attempting to upgrade scipy to the latest version it appears to throw some errors (which might be due to some updates that cvx needs to make on their end from what I can tell).

@purva-thakre
Copy link
Collaborator Author

purva-thakre commented Oct 30, 2023

@vprusso The errors you get with scipy should be fixed with the latest commit in this branch.

Yes, I think cvx warnings and 1 pytest warning could be ignored for now. From the look of it, I don't think cvx will ever get around to fixing those.

https://stackoverflow.com/questions/40710094/how-to-suppress-py-test-internal-deprecation-warnings

Interesting that you don't get the same errors as me. This time, I did use poetry for a brand new virtual environment.

However, I just figured out this environment has the same import issue that should have been fixed in #206. All tests pass in toqito/tests but if I go inside some toqito/tests/test_something and then run pytest, some tests fail due to Module not found error. Some dependency incompatibility?

Edit: I am attempting to fix the module not found issue with adding a pytest.ini file.
https://stackoverflow.com/a/73380948/10241324
https://stackoverflow.com/a/50610630/10241324

@purva-thakre purva-thakre mentioned this pull request Oct 30, 2023
2 tasks
* all pylint issues in tests/

* state_props:eof

* python install

* pylint userwarning

* remove exception and from future annotations

* import lines

* matrix_props/is_positive_def

* fixes Make parameter typing consistent in doc examples #209

* state_metrics/fid_of_sep

* channel_props/is_trace_preserving

* nonlocalgame

* useless suppression

* quick fixes

* all redefinition disabled

* all unsubscriptable object

* possibly unbalanced tuples

* unnecessary-list-index-lookup

* black reformatter no pylint issues

* black reformatter pylint issues

* test useless supression

* Fixes #205 (comment)

* Fixes #205 (comment)

* Fixes #205 (comment)

* fixes #205 (comment) + black reformatter
@purva-thakre
Copy link
Collaborator Author

Closing this PR because I messed up my git rebase.

@purva-thakre purva-thakre deleted the pytest_errors branch October 31, 2023 12:54
@purva-thakre purva-thakre mentioned this pull request Oct 31, 2023
3 tasks
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.

Warnings via pytest
2 participants