Repository navigation
PY_SSIZE_T_CLEAN warning with Python 3.9 and Matplotlib 3.0 #10954
Copy link
Copy link
Labels
testingvisualization.wcsaxeszzz 💤 Python3.10archived: Python 3.10 is no longer supportedarchived: Python 3.10 is no longer supportedzzz 💤 Python3.8archived: Python 3.8 is no longer supportedarchived: Python 3.8 is no longer supportedzzz 💤 Python3.9archived: Python 3.9 is no longer supportedarchived: Python 3.9 is no longer supported
Description
Description
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 #10900 (comment) there will probably be no further action needed.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
testingvisualization.wcsaxeszzz 💤 Python3.10archived: Python 3.10 is no longer supportedarchived: Python 3.10 is no longer supportedzzz 💤 Python3.8archived: Python 3.8 is no longer supportedarchived: Python 3.8 is no longer supportedzzz 💤 Python3.9archived: Python 3.9 is no longer supportedarchived: Python 3.9 is no longer supported
Activity
pllim commentedon Oct 27, 2020
Hmm... We can choose to:
matplotlib < 3.1; ormatplotlib >= 3.1in 4.2 -- We are talking about bumping all the way from 2.1 to 3.1 between releases; though it is maybe not that controversial given that we already bumped to 3.0 to accommodate Python 3.7 as minversion in MNT: Bump minversion of Python to 3.7 (also Scipy, PyYAML, Matplotlib) #10900.dhomeier commentedon Oct 27, 2020
or
matplotlib < 3.1?] add"PY_SSIZE_T_CLEAN will be required for '#' formats" in w_msgto the list.bsipocz commentedon Oct 27, 2020
3.1 is a year and a bit old, feels a bit too recent, but if everyone agrees it can certainly be a bump for 4.2
pllim commentedon Oct 27, 2020
How about #10956?
dhomeier commentedon Oct 28, 2020
Closed by #10956
pllim commentedon Nov 9, 2020
Seeing a notification about this now reminded me of
astropy/setup.cfg
Line 126 in 0dabeb4
dhomeier commentedon Nov 9, 2020
Doh, just got the same warning & test failure with Python 3.8.6.
Although https://bugs.python.org/issue36381 mentioned a
PendingDeprecationWarningfor the 3.8 branch, this was apparently changed later toDeprecationWarningin python/cpython#12473 (if it even makes a difference).Anyway obviously need to extend the fix to
sys.version_info >= (3, 8)...