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

Skip to content

Commit afe6632

Browse files
authored
Merge branch 'matplotlib:main' into add_test_pcolorfast
2 parents 3966ad4 + f80ff65 commit afe6632

File tree

8 files changed

+73
-79
lines changed

8 files changed

+73
-79
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Deprecated Classes Removed
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
The following deprecated classes from version 3.7 have been removed:
5+
6+
- ``matplotlib.backends.backend_ps.PsBackendHelper``
7+
- ``matplotlib.backends.backend_webagg.ServerThread``
8+
9+
These classes were previously marked as deprecated and have now been removed in accordance with the deprecation cycle.
10+
11+
Deprecated C++ Methods Removed
12+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13+
14+
The following deprecated C++ methods from :file:`src/_backend_agg_wrapper.cpp`, deprecated since version 3.7, have also been removed:
15+
16+
- ``PyBufferRegion_to_string``
17+
- ``PyBufferRegion_to_string_argb``
18+
19+
These methods were previously marked as deprecated and have now been removed.

galleries/plot_types/basic/stairs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
stairs(values)
44
==============
55
6-
See `~matplotlib.axes.Axes.stairs`.
6+
See `~matplotlib.axes.Axes.stairs` when plotting :math:`y` between
7+
:math:`(x_i, x_{i+1})`. For plotting :math:`y` at :math:`x`, see
8+
`~matplotlib.axes.Axes.step`.
79
810
.. redirect-from:: /plot_types/basic/step
911
"""

lib/matplotlib/backends/backend_ps.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,9 @@
3939
debugPS = False
4040

4141

42-
@_api.deprecated("3.7")
43-
class PsBackendHelper:
44-
def __init__(self):
45-
self._cached = {}
46-
47-
4842
@_api.caching_module_getattr
4943
class __getattr__:
5044
# module-level deprecations
51-
ps_backend_helper = _api.deprecated("3.7", obj_type="")(
52-
property(lambda self: PsBackendHelper()))
5345
psDefs = _api.deprecated("3.8", obj_type="")(property(lambda self: _psDefs))
5446

5547

lib/matplotlib/backends/backend_webagg.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@
3737
TimerAsyncio, TimerTornado)
3838

3939

40-
@mpl._api.deprecated("3.7")
41-
class ServerThread(threading.Thread):
42-
def run(self):
43-
tornado.ioloop.IOLoop.instance().start()
44-
45-
4640
webagg_server_thread = threading.Thread(
4741
target=lambda: tornado.ioloop.IOLoop.instance().start())
4842

lib/matplotlib/tests/test_datetime.py

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,40 @@ def test_fill_between(self):
390390
ax2.fill_between(x_dates, y_values1, y_values2)
391391
ax3.fill_between(x_dates, y_dates1, y_dates2)
392392

393-
@pytest.mark.xfail(reason="Test for fill_betweenx not written yet")
394393
@mpl.style.context("default")
395394
def test_fill_betweenx(self):
396-
fig, ax = plt.subplots()
397-
ax.fill_betweenx(...)
395+
mpl.rcParams["date.converter"] = "concise"
396+
np.random.seed(19680801)
397+
398+
x_base_date = datetime.datetime(2023, 1, 1)
399+
x_dates1 = [x_base_date]
400+
for i in range(1, 10):
401+
x_base_date += datetime.timedelta(days=np.random.randint(1, 5))
402+
x_dates1.append(x_base_date)
403+
404+
x_dates2 = [x_base_date]
405+
for i in range(1, 10):
406+
x_base_date += datetime.timedelta(days=np.random.randint(1, 5))
407+
x_dates2.append(x_base_date)
408+
y_values = np.random.rand(10) * 10
409+
y_values.sort()
410+
411+
x_values1 = np.random.rand(10) * 10
412+
x_values2 = x_values1 + np.random.rand(10) * 10
413+
x_values1.sort()
414+
x_values2.sort()
415+
416+
y_base_date = datetime.datetime(2023, 1, 1)
417+
y_dates = [y_base_date]
418+
for i in range(1, 10):
419+
y_base_date += datetime.timedelta(days=np.random.randint(1, 10))
420+
y_dates.append(y_base_date)
421+
422+
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, layout="constrained")
423+
424+
ax1.fill_betweenx(y_values, x_dates1, x_dates2)
425+
ax2.fill_betweenx(y_dates, x_values1, x_values2)
426+
ax3.fill_betweenx(y_dates, x_dates1, x_dates2)
398427

399428
@pytest.mark.xfail(reason="Test for hexbin not written yet")
400429
@mpl.style.context("default")
@@ -740,8 +769,24 @@ def test_violinplot(self):
740769
fig, ax = plt.subplots()
741770
ax.violinplot(...)
742771

743-
@pytest.mark.xfail(reason="Test for vlines not written yet")
744772
@mpl.style.context("default")
745773
def test_vlines(self):
746-
fig, ax = plt.subplots()
747-
ax.vlines(...)
774+
mpl.rcParams["date.converter"] = 'concise'
775+
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, layout='constrained')
776+
ax1.set_xlim(left=datetime.datetime(2023, 1, 1),
777+
right=datetime.datetime(2023, 6, 30))
778+
ax1.vlines(x=[datetime.datetime(2023, 2, 10),
779+
datetime.datetime(2023, 5, 18),
780+
datetime.datetime(2023, 6, 6)],
781+
ymin=[0, 0.25, 0.5],
782+
ymax=[0.25, 0.5, 0.75])
783+
ax2.set_xlim(left=0,
784+
right=0.5)
785+
ax2.vlines(x=[0.3, 0.35],
786+
ymin=[np.datetime64('2023-03-20'), np.datetime64('2023-03-31')],
787+
ymax=[np.datetime64('2023-05-01'), np.datetime64('2023-05-16')])
788+
ax3.set_xlim(left=datetime.datetime(2023, 7, 1),
789+
right=datetime.datetime(2023, 12, 31))
790+
ax3.vlines(x=[datetime.datetime(2023, 9, 1), datetime.datetime(2023, 12, 10)],
791+
ymin=datetime.datetime(2023, 1, 15),
792+
ymax=datetime.datetime(2023, 1, 30))

src/_backend_agg.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,6 @@
55
#include "_backend_agg.h"
66
#include "mplutils.h"
77

8-
void BufferRegion::to_string_argb(uint8_t *buf)
9-
{
10-
unsigned char *pix;
11-
unsigned char tmp;
12-
size_t i, j;
13-
14-
memcpy(buf, data, (size_t) height * stride);
15-
16-
for (i = 0; i < (size_t)height; ++i) {
17-
pix = buf + i * stride;
18-
for (j = 0; j < (size_t)width; ++j) {
19-
// Convert rgba to argb
20-
tmp = pix[2];
21-
pix[2] = pix[0];
22-
pix[0] = tmp;
23-
pix += 4;
24-
}
25-
}
26-
}
27-
288
RendererAgg::RendererAgg(unsigned int width, unsigned int height, double dpi)
299
: width(width),
3010
height(height),

src/_backend_agg.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ class BufferRegion
8686
return stride;
8787
}
8888

89-
void to_string_argb(uint8_t *buf);
90-
9189
private:
9290
agg::int8u *data;
9391
agg::rect_i rect;

src/_backend_agg_wrapper.cpp

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,6 @@ static void PyBufferRegion_dealloc(PyBufferRegion *self)
4444
Py_TYPE(self)->tp_free((PyObject *)self);
4545
}
4646

47-
static PyObject *PyBufferRegion_to_string(PyBufferRegion *self, PyObject *args)
48-
{
49-
char const* msg =
50-
"BufferRegion.to_string is deprecated since Matplotlib 3.7 and will "
51-
"be removed two minor releases later; use np.asarray(region) instead.";
52-
if (PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1)) {
53-
return NULL;
54-
}
55-
return PyBytes_FromStringAndSize((const char *)self->x->get_data(),
56-
(Py_ssize_t) self->x->get_height() * self->x->get_stride());
57-
}
58-
5947
/* TODO: This doesn't seem to be used internally. Remove? */
6048

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

90-
static PyObject *PyBufferRegion_to_string_argb(PyBufferRegion *self, PyObject *args)
91-
{
92-
char const* msg =
93-
"BufferRegion.to_string_argb is deprecated since Matplotlib 3.7 and "
94-
"will be removed two minor releases later; use "
95-
"np.take(region, [2, 1, 0, 3], axis=2) instead.";
96-
if (PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1)) {
97-
return NULL;
98-
}
99-
PyObject *bufobj;
100-
uint8_t *buf;
101-
Py_ssize_t height, stride;
102-
height = self->x->get_height();
103-
stride = self->x->get_stride();
104-
bufobj = PyBytes_FromStringAndSize(NULL, height * stride);
105-
buf = (uint8_t *)PyBytes_AS_STRING(bufobj);
106-
107-
CALL_CPP_CLEANUP("to_string_argb", (self->x->to_string_argb(buf)), Py_DECREF(bufobj));
108-
109-
return bufobj;
110-
}
111-
11278
int PyBufferRegion_get_buffer(PyBufferRegion *self, Py_buffer *buf, int flags)
11379
{
11480
Py_INCREF(self);
@@ -136,8 +102,6 @@ int PyBufferRegion_get_buffer(PyBufferRegion *self, Py_buffer *buf, int flags)
136102
static PyTypeObject *PyBufferRegion_init_type()
137103
{
138104
static PyMethodDef methods[] = {
139-
{ "to_string", (PyCFunction)PyBufferRegion_to_string, METH_NOARGS, NULL },
140-
{ "to_string_argb", (PyCFunction)PyBufferRegion_to_string_argb, METH_NOARGS, NULL },
141105
{ "set_x", (PyCFunction)PyBufferRegion_set_x, METH_VARARGS, NULL },
142106
{ "set_y", (PyCFunction)PyBufferRegion_set_y, METH_VARARGS, NULL },
143107
{ "get_extents", (PyCFunction)PyBufferRegion_get_extents, METH_NOARGS, NULL },

0 commit comments

Comments
 (0)