PY_SSIZE_T_CLEAN warning with Python 3.9 and Matplotlib 3.0
See original GitHub issueDescription
With matplotlib 3.0.x test_no_numpy_warnings
runs into an unexpected deprecation warning.
Steps to Reproduce
astropy.test(package='visualization', args='-vk numpy_warn')
...
Running tests with Astropy version 4.2.dev1150+g3421137b6.d20201027.
Running tests in lib/python3.9/site-packages/astropy/visualization.
Date: 2020-10-27T13:58:40
Platform: macOS-10.14.6-x86_64-i386-64bit
Executable: /opt/bin/python3.9
Full Python Version:
3.9.0 (default, Oct 10 2020, 10:27:03)
[Clang 11.0.0 (clang-1100.0.33.17)]
encodings: sys: utf-8, locale: UTF-8, filesystem: utf-8
byteorder: little
float info: dig: 15, mant_dig: 15
Package versions:
Numpy: 1.19.2
Scipy: 1.5.3
Matplotlib: 3.0.3
h5py: not available
Pandas: not available
PyERFA: 1.7.0
Cython: 0.29.21
Scikit-image: not available
asdf: 2.7.1
Using Astropy options: remote_data: any.
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/Users/derek/.hypothesis/examples')
rootdir: /Users/derek
plugins: arraydiff-0.3, xdist-2.1.0, astropy-header-0.1.2, hypothesis-5.16.0, cov-2.10.1, flaky-3.7.0, asdf-2.7.1, remotedata-0.3.2, mock-3.3.1, forked-1.3.0, openfiles-0.5.0, doctestplus-0.8.0, expect-1.1.0, flake8-1.0.6
collected 479 items / 477 deselected / 2 selected
lib/python3.9/site-packages/astropy/visualization/wcsaxes/tests/test_misc.py::test_no_numpy_warnings[lines] FAILED [ 50%]
lib/python3.9/site-packages/astropy/visualization/wcsaxes/tests/test_misc.py::test_no_numpy_warnings[contours] FAILED [100%]
===================================================================================== FAILURES =====================================================================================
__________________________________________________________________________ test_no_numpy_warnings[lines] ___________________________________________________________________________
ignore_matplotlibrc = None, tmpdir = local('/private/var/folders/7l/j6rbh6fw8xjc4w0059bv63_h00027w/T/pytest-of-derek/pytest-18/test_no_numpy_warnings_lines_0'), grid_type = 'lines'
@pytest.mark.parametrize('grid_type', ['lines', 'contours'])
def test_no_numpy_warnings(ignore_matplotlibrc, tmpdir, grid_type):
ax = plt.subplot(1, 1, 1, projection=WCS(TARGET_HEADER))
ax.imshow(np.zeros((100, 200)))
ax.coords.grid(color='white', grid_type=grid_type)
with pytest.warns(None) as warning_lines:
plt.savefig(tmpdir.join('test.png').strpath)
# There should be no warnings raised if some pixels are outside WCS
# (since this is normal).
# BUT catch_warning was ignoring some warnings before, so now we
# have to catch it. Otherwise, the pytest filterwarnings=error
# setting in setup.cfg will fail this test.
# There are actually multiple warnings but they are all similar.
for w in warning_lines:
print(w.message)
w_msg = str(w.message)
> assert ('converting a masked element to nan' in w_msg or
'No contour levels were found within the data range' in w_msg or
'np.asscalar(a) is deprecated since NumPy v1.16' in w_msg)
E assert ('converting a masked element to nan' in "PY_SSIZE_T_CLEAN will be required for '#' formats" or 'No contour levels were found within the data range' in "PY_SSIZE_T_CLEAN will be required for '#' formats" or 'np.asscalar(a) is deprecated since NumPy v1.16' in "PY_SSIZE_T_CLEAN will be required for '#' formats")
lib/python3.9/site-packages/astropy/visualization/wcsaxes/tests/test_misc.py:95: AssertionError
------------------------------------------------------------------------------- Captured stdout call -------------------------------------------------------------------------------
PY_SSIZE_T_CLEAN will be required for '#' formats
_________________________________________________________________________ test_no_numpy_warnings[contours] _________________________________________________________________________
...
This is related to https://bugs.python.org/issue36381 and seems fixed as of Matplotlib 3.1. Adding it to the list of expected warnings would be trivial, but if the minimum version is increased to >= 3.1.0 as per https://github.com/astropy/astropy/pull/10900#issuecomment-717211293 there will probably be no further action needed.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Python, Error while installing matplotlib - Stack Overflow
Hence Down-versioned Python to 3.9 and installed Matplotlib. For Python version upto 3.9 wheel is defined for Matplotlib, do use Python 3.9 ......
Read more >Installation — Matplotlib 3.6.2 documentation
If you are using the Python version that comes with your Linux distribution, you can install Matplotlib via your package manager, e.g.:.
Read more >Python plotting — Matplotlib 3.0.2 documentation
Matplotlib is a Python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across ...
Read more >Dependencies — Matplotlib 3.6.2 documentation
When installing through a package manager like pip or conda , the mandatory dependencies are automatically installed. This list is mainly for reference....
Read more >API Changes for 3.4.0 — Matplotlib 3.6.2 documentation
colorbar and pyplot.colorbar now emits a warning when the current Axes is not the same as the mappable's Axes. Colorbar docstrings#. The ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Seeing a notification about this now reminded me of
https://github.com/astropy/astropy/blob/0dabeb4bb1bb5b66bc7b93f632c77ca4ad0ba413/setup.cfg#L126
How about #10956?