Skip to content

Handling warnings in pytest #1845

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

Merged
merged 33 commits into from
Jun 14, 2024
Merged

Handling warnings in pytest #1845

merged 33 commits into from
Jun 14, 2024

Conversation

vlad-perevezentsev
Copy link
Collaborator

@vlad-perevezentsev vlad-perevezentsev commented May 22, 2024

This PR suggests getting rid of use -p warnings flag in pytest configuration and handling warnings separately.
This will help you see new warnings in internal CI logs and during development

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • If this PR is a work in progress, are you filing the PR as a draft?

@vlad-perevezentsev vlad-perevezentsev self-assigned this May 22, 2024
Copy link
Contributor

github-actions bot commented May 22, 2024

View rendered docs @ https://intelpython.github.io/dpnp/index.html

@vlad-perevezentsev vlad-perevezentsev marked this pull request as ready for review May 29, 2024 10:29
Copy link
Contributor

@antonwolfy antonwolfy left a comment

Choose a reason for hiding this comment

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

pytest -s run on Gen9 reports 255 warnings:

=================================================================================================================================== warnings summary ===================================================================================================================================
tests/test_arraycreation.py: 250 warnings
  /localdisk/work/antonvol/soft/miniconda3/envs/dpnp_py39_ext/lib/python3.9/site-packages/dpctl/tensor/_type_utils.py:456: DeprecationWarning: finfo() dtype cannot be None. This behavior will raise an error in the future. (Deprecated in NumPy 1.25)
    self._finfo = np.finfo(dtype)

tests/test_sycl_queue.py::test_from_dlpack_with_dpt[complex64-level_zero:gpu:0]
  /localdisk/work/antonvol/soft/miniconda3/envs/dpnp_py39_ext/lib/python3.9/site-packages/numpy/testing/_private/utils.py:722: RuntimeWarning: invalid value encountered in equal
    func=lambda xy: xy == +inf,

tests/test_sycl_queue.py::test_from_dlpack_with_dpt[complex64-level_zero:gpu:0]
  /localdisk/work/antonvol/soft/miniconda3/envs/dpnp_py39_ext/lib/python3.9/site-packages/numpy/testing/_private/utils.py:725: RuntimeWarning: invalid value encountered in equal
    func=lambda xy: xy == -inf,

tests/third_party/cupy/core_tests/test_ndarray_math.py::TestRoundHalfway_param_0_{decimals=-3}::test_round_halfway_uint
  /localdisk/work/antonvol/soft/miniconda3/envs/dpnp_py39_ext/lib/python3.9/site-packages/dpctl/tensor/_ctors.py:646: DeprecationWarning: NumPy will stop allowing conversion of out-of-bound Python integers to integer arrays.  The conversion of 1000 to uint8 will fail in the future.
  For the old behavior, usually:
      np.array(value).astype(dtype)
  will give the desired result (the cast overflows).
    np.asarray(obj, dtype=dtype),

tests/third_party/cupy/core_tests/test_ndarray_math.py::TestRoundHalfway_param_0_{decimals=-3}::test_round_halfway_uint
  /localdisk/work/antonvol/code/dpnp/tests/third_party/cupy/core_tests/test_ndarray_math.py:108: DeprecationWarning: NumPy will stop allowing conversion of out-of-bound Python integers to integer arrays.  The conversion of 1000 to uint8 will fail in the future.
  For the old behavior, usually:
      np.array(value).astype(dtype)
  will give the desired result (the cast overflows).
    a *= xp.array(scale, dtype=dtype)

tests/third_party/cupy/creation_tests/test_ranges.py::TestRanges::test_linspace_float_underflow
  /localdisk/work/antonvol/soft/miniconda3/envs/dpnp_py39_ext/lib/python3.9/site-packages/numpy/core/function_base.py:158: RuntimeWarning: overflow encountered in multiply
    y *= step

Is it expected to have warning on Gen9?

@antonwolfy
Copy link
Contributor

There are still warnings on PVC:

=========================================================================================== warnings summary ===========================================================================================
tests/test_sycl_queue.py::test_from_dlpack_with_dpt[complex64-level_zero:gpu:0]
tests/test_sycl_queue.py::test_from_dlpack_with_dpt[complex64-level_zero:gpu:1]
  /home/gta/miniconda3/envs/dpnp_dev/lib/python3.10/site-packages/numpy/testing/_private/utils.py:722: RuntimeWarning: invalid value encountered in equal
    func=lambda xy: xy == +inf,

tests/test_sycl_queue.py::test_from_dlpack_with_dpt[complex64-level_zero:gpu:0]
tests/test_sycl_queue.py::test_from_dlpack_with_dpt[complex64-level_zero:gpu:1]
  /home/gta/miniconda3/envs/dpnp_dev/lib/python3.10/site-packages/numpy/testing/_private/utils.py:725: RuntimeWarning: invalid value encountered in equal
    func=lambda xy: xy == -inf,

Copy link
Contributor

@antonwolfy antonwolfy left a comment

Choose a reason for hiding this comment

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

@antonwolfy antonwolfy merged commit 6a737c4 into master Jun 14, 2024
47 of 56 checks passed
@antonwolfy antonwolfy deleted the handle_pytest_warnings branch June 14, 2024 16:35
github-actions bot added a commit that referenced this pull request Jun 14, 2024
* Enable loading of warning plugin in pytest

* Fix DeprecationWarning in test_histogram.py

* Ignore DeprecationWarning for pkg_resources

* Fix SyntaxWarning in test_ndarray_math.py

* Deprecate numpy_cupy_array_list_equal

* Fix DeprecationWarning in test_mathematical.py

* Avoid FutureWarning for rcond parameter of numpy.linalg.lstsq

* Fix DeprecationWarning in cupy test_elementwise.py

* Skip test_msort_zero_dim - not implemented

* Ignore RuntimeWarning for numpy.arccosh

* Fix DeprecationWarning for numpy.fromstring

* Add test_digitize_inf to TestDigitize

* Fix DeprecationWarning: Converting np.integer to a dtype is deprecated

* Fix ComplexWarning in 2 ways

* Fix RuntimeWarning by reducing shape in TestNansumNanprodLong

* Handle DeprecationWarning in test_dparray.py

* Skip test_lexsort_one_dim/_two_dim - not implemented

* Handle RuntimeWarning in test_linspace_float_underflow

* Fix DeprecationWarning in test_round_halfway_uint

* Update test_linspace to avoid DeprecationWarning

* Use pytest.mark.usefixtures('suppress_complex_warning')

* Handle RuntimeWarning: divide by zero in test_reciprocal

* Fix DeprecationWarning in test_mathematical.py

* Handle RuntimeWarning in test_from_dlpack

* Add the fixture to test_from_dlpack_with_dpt insted of test_from_dlpack 6a737c4
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.

2 participants