Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove remaining deprecations from 3.5 #24948

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 6 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions doc/api/next_api_changes/removals/24948-ES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@

Testing support
~~~~~~~~~~~~~~~

``matplotlib.test()`` has been removed
......................................

Run tests using ``pytest`` from the commandline instead. The variable
``matplotlib.default_test_modules`` was only used for ``matplotlib.test()`` and
is thus removed as well.

To test an installed copy, be sure to specify both ``matplotlib`` and
``mpl_toolkits`` with ``--pyargs``::

python -m pytest --pyargs matplotlib.tests mpl_toolkits.tests

See :ref:`testing` for more details.



Auto-removal of grids by `~.Axes.pcolor` and `~.Axes.pcolormesh`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

`~.Axes.pcolor` and `~.Axes.pcolormesh` previously remove any visible axes
major grid. This behavior is removed; please explicitly call ``ax.grid(False)``
to remove the grid.



Modification of ``Axes`` children sublists
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

See :ref:`Behavioural API Changes 3.5 - Axes children combined` for more
information; modification of the following sublists is no longer supported:

* ``Axes.artists``
* ``Axes.collections``
* ``Axes.images``
* ``Axes.lines``
* ``Axes.patches``
* ``Axes.tables``
* ``Axes.texts``

To remove an Artist, use its `.Artist.remove` method. To add an Artist, use the
corresponding ``Axes.add_*`` method.



``ConversionInterface.convert`` no longer accepts unitless values
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Previously, custom subclasses of `.units.ConversionInterface` needed to
implement a ``convert`` method that not only accepted instances of the unit,
but also unitless values (which are passed through as is). This is no longer
the case (``convert`` is never called with a unitless value), and such support
in ``.StrCategoryConverter`` is removed. Likewise, the
``.ConversionInterface.is_numlike`` helper is removed.

Consider calling `.Axis.convert_units` instead, which still supports unitless
values.


Normal list of `.Artist` objects now returned by `.HandlerLine2D.create_artists`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For Matplotlib 3.5 and 3.6 a proxy list was returned that simulated the return
of `.HandlerLine2DCompound.create_artists`. Now a list containing only the
single artist is return.


rcParams will no longer cast inputs to str
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

rcParams that expect a (non-pathlike) str no longer cast non-str inputs using
`str`. This will avoid confusing errors in subsequent code if e.g. a list input
gets implicitly cast to a str.



Case-insensitive scales
~~~~~~~~~~~~~~~~~~~~~~~

Previously, scales could be set case-insensitively (e.g.,
``set_xscale("LoG")``). Now all builtin scales use lowercase names.



Support for ``nx1 = None`` or ``ny1 = None`` in ``AxesLocator`` and ``Divider.locate``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In `.axes_grid1.axes_divider`, various internal APIs no longer supports
passing ``nx1 = None`` or ``ny1 = None`` to mean ``nx + 1`` or ``ny + 1``, in
preparation for a possible future API which allows indexing and slicing of
dividers (possibly ``divider[a:b] == divider.new_locator(a, b)``, but also
``divider[a:] == divider.new_locator(a, <end>)``). The user-facing
`.Divider.new_locator` API is unaffected -- it correctly normalizes ``nx1 =
None`` and ``ny1 = None`` as needed.


change signature of ``.FigureCanvasBase.enter_notify_event``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The *xy* parameter is now required and keyword only. This was deprecated in
3.0 and originally slated to be removed in 3.5.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ implement a ``convert`` method that not only accepted instances of the unit,
but also unitless values (which are passed through as is). This is no longer
the case (``convert`` is never called with a unitless value), and such support
in `.StrCategoryConverter` is deprecated. Likewise, the
`.ConversionInterface.is_numlike` helper is deprecated.
``.ConversionInterface.is_numlike`` helper is deprecated.

Consider calling `.Axis.convert_units` instead, which still supports unitless
values.
Expand Down
2 changes: 1 addition & 1 deletion doc/api/prev_api_changes/api_changes_3.5.0/removals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ Arguments
- The *dummy* parameter of `.RendererPgf` has been removed.
- The *props* parameter of `.Shadow` has been removed; use keyword arguments
instead.
- The *recursionlimit* parameter of `matplotlib.test` has been removed.
- The *recursionlimit* parameter of ``matplotlib.test`` has been removed.
- The *label* parameter of `.Tick` has no effect and has been removed.
- `~.ticker.MaxNLocator` no longer accepts a positional parameter and the
keyword argument *nbins* simultaneously because they specify the same
Expand Down
5 changes: 0 additions & 5 deletions doc/api/testing_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
**********************


:func:`matplotlib.test`
=======================

.. autofunction:: matplotlib.test

:mod:`matplotlib.testing`
=========================

Expand Down
58 changes: 0 additions & 58 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1278,12 +1278,6 @@ def is_interactive():
return rcParams['interactive']


default_test_modules = [
'matplotlib.tests',
'mpl_toolkits.tests',
]


def _init_tests():
# The version of FreeType to install locally for running the
# tests. This must match the value in `setupext.py`
Expand All @@ -1302,58 +1296,6 @@ def _init_tests():
"" if ft2font.__freetype_build_type__ == 'local' else "not "))


@_api.deprecated("3.5", alternative='pytest')
def test(verbosity=None, coverage=False, **kwargs):
"""Run the matplotlib test suite."""

try:
import pytest
except ImportError:
print("matplotlib.test requires pytest to run.")
return -1

if not os.path.isdir(os.path.join(os.path.dirname(__file__), 'tests')):
print("Matplotlib test data is not installed")
return -1

old_backend = get_backend()
try:
use('agg')

args = kwargs.pop('argv', [])
provide_default_modules = True
use_pyargs = True
for arg in args:
if any(arg.startswith(module_path)
for module_path in default_test_modules):
provide_default_modules = False
break
if os.path.exists(arg):
provide_default_modules = False
use_pyargs = False
break
if use_pyargs:
args += ['--pyargs']
if provide_default_modules:
args += default_test_modules

if coverage:
args += ['--cov']

if verbosity:
args += ['-' + 'v' * verbosity]

retcode = pytest.main(args, **kwargs)
finally:
if old_backend.lower() != 'agg':
use(old_backend)

return retcode


test.__test__ = False # pytest: this function is not a test


def _replacer(data, value):
"""
Either returns ``data[value]`` or passes ``data`` back, converts either to
Expand Down
14 changes: 0 additions & 14 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5792,18 +5792,6 @@ def _interp_grid(X):
C = cbook.safe_masked_invalid(C)
return X, Y, C, shading

def _pcolor_grid_deprecation_helper(self):
grid_active = any(axis._major_tick_kw["gridOn"]
for axis in self._axis_map.values())
# explicit is-True check because get_axisbelow() can also be 'line'
grid_hidden_by_pcolor = self.get_axisbelow() is True
if grid_active and not grid_hidden_by_pcolor:
_api.warn_deprecated(
"3.5", message="Auto-removal of grids by pcolor() and "
"pcolormesh() is deprecated since %(since)s and will be "
"removed %(removal)s; please call grid(False) first.")
self.grid(False)

@_preprocess_data()
@_docstring.dedent_interpd
def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
Expand Down Expand Up @@ -6008,7 +5996,6 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
collection = mcoll.PolyCollection(
verts, array=C, cmap=cmap, norm=norm, alpha=alpha, **kwargs)
collection._scale_norm(norm, vmin, vmax)
self._pcolor_grid_deprecation_helper()

x = X.compressed()
y = Y.compressed()
Expand Down Expand Up @@ -6242,7 +6229,6 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
coords, antialiased=antialiased, shading=shading,
array=C, cmap=cmap, norm=norm, alpha=alpha, **kwargs)
collection._scale_norm(norm, vmin, vmax)
self._pcolor_grid_deprecation_helper()

coords = coords.reshape(-1, 2) # flatten the grid structure; keep x, y

Expand Down
Loading