Skip to content

Remove backend 3.7-deprecated API #26962

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 14 commits into from
Dec 6, 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
19 changes: 19 additions & 0 deletions doc/api/next_api_changes/removals/26962-IA.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Deprecated Classes Removed
~~~~~~~~~~~~~~~~~~~~~~~~~~

The following deprecated classes from version 3.7 have been removed:

- ``matplotlib.backends.backend_ps.PsBackendHelper``
- ``matplotlib.backends.backend_webagg.ServerThread``

These classes were previously marked as deprecated and have now been removed in accordance with the deprecation cycle.

Deprecated C++ Methods Removed
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The following deprecated C++ methods from :file:`src/_backend_agg_wrapper.cpp`, deprecated since version 3.7, have also been removed:

- ``PyBufferRegion_to_string``
- ``PyBufferRegion_to_string_argb``

These methods were previously marked as deprecated and have now been removed.
8 changes: 0 additions & 8 deletions lib/matplotlib/backends/backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,9 @@
debugPS = False


@_api.deprecated("3.7")
class PsBackendHelper:
def __init__(self):
self._cached = {}


@_api.caching_module_getattr
class __getattr__:
# module-level deprecations
ps_backend_helper = _api.deprecated("3.7", obj_type="")(
property(lambda self: PsBackendHelper()))
psDefs = _api.deprecated("3.8", obj_type="")(property(lambda self: _psDefs))


Expand Down
6 changes: 0 additions & 6 deletions lib/matplotlib/backends/backend_webagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@
TimerAsyncio, TimerTornado)


@mpl._api.deprecated("3.7")
class ServerThread(threading.Thread):
def run(self):
tornado.ioloop.IOLoop.instance().start()


webagg_server_thread = threading.Thread(
target=lambda: tornado.ioloop.IOLoop.instance().start())

Expand Down
20 changes: 0 additions & 20 deletions src/_backend_agg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,6 @@
#include "_backend_agg.h"
#include "mplutils.h"

void BufferRegion::to_string_argb(uint8_t *buf)
{
unsigned char *pix;
unsigned char tmp;
size_t i, j;

memcpy(buf, data, (size_t) height * stride);

for (i = 0; i < (size_t)height; ++i) {
pix = buf + i * stride;
for (j = 0; j < (size_t)width; ++j) {
// Convert rgba to argb
tmp = pix[2];
pix[2] = pix[0];
pix[0] = tmp;
pix += 4;
}
}
}

RendererAgg::RendererAgg(unsigned int width, unsigned int height, double dpi)
: width(width),
height(height),
Expand Down
2 changes: 0 additions & 2 deletions src/_backend_agg.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ class BufferRegion
return stride;
}

void to_string_argb(uint8_t *buf);

private:
agg::int8u *data;
agg::rect_i rect;
Expand Down
36 changes: 0 additions & 36 deletions src/_backend_agg_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,6 @@ static void PyBufferRegion_dealloc(PyBufferRegion *self)
Py_TYPE(self)->tp_free((PyObject *)self);
}

static PyObject *PyBufferRegion_to_string(PyBufferRegion *self, PyObject *args)
{
char const* msg =
"BufferRegion.to_string is deprecated since Matplotlib 3.7 and will "
"be removed two minor releases later; use np.asarray(region) instead.";
if (PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1)) {
return NULL;
}
return PyBytes_FromStringAndSize((const char *)self->x->get_data(),
(Py_ssize_t) self->x->get_height() * self->x->get_stride());
}

/* TODO: This doesn't seem to be used internally. Remove? */

static PyObject *PyBufferRegion_set_x(PyBufferRegion *self, PyObject *args)
Expand Down Expand Up @@ -87,28 +75,6 @@ static PyObject *PyBufferRegion_get_extents(PyBufferRegion *self, PyObject *args
return Py_BuildValue("IIII", rect.x1, rect.y1, rect.x2, rect.y2);
}

static PyObject *PyBufferRegion_to_string_argb(PyBufferRegion *self, PyObject *args)
{
char const* msg =
"BufferRegion.to_string_argb is deprecated since Matplotlib 3.7 and "
"will be removed two minor releases later; use "
"np.take(region, [2, 1, 0, 3], axis=2) instead.";
if (PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1)) {
return NULL;
}
PyObject *bufobj;
uint8_t *buf;
Py_ssize_t height, stride;
height = self->x->get_height();
stride = self->x->get_stride();
bufobj = PyBytes_FromStringAndSize(NULL, height * stride);
buf = (uint8_t *)PyBytes_AS_STRING(bufobj);

CALL_CPP_CLEANUP("to_string_argb", (self->x->to_string_argb(buf)), Py_DECREF(bufobj));

return bufobj;
}

int PyBufferRegion_get_buffer(PyBufferRegion *self, Py_buffer *buf, int flags)
{
Py_INCREF(self);
Expand Down Expand Up @@ -136,8 +102,6 @@ int PyBufferRegion_get_buffer(PyBufferRegion *self, Py_buffer *buf, int flags)
static PyTypeObject *PyBufferRegion_init_type()
{
static PyMethodDef methods[] = {
{ "to_string", (PyCFunction)PyBufferRegion_to_string, METH_NOARGS, NULL },
{ "to_string_argb", (PyCFunction)PyBufferRegion_to_string_argb, METH_NOARGS, NULL },
{ "set_x", (PyCFunction)PyBufferRegion_set_x, METH_VARARGS, NULL },
{ "set_y", (PyCFunction)PyBufferRegion_set_y, METH_VARARGS, NULL },
{ "get_extents", (PyCFunction)PyBufferRegion_get_extents, METH_NOARGS, NULL },
Expand Down