Skip to content

Commit 3b6cc7f

Browse files
committed
MAINT: Removing unused offset_position code
This removes most of the backend code that uses offset_position, but leaves the argument in place for backwards compatibility.
1 parent 39ab96d commit 3b6cc7f

File tree

9 files changed

+12
-84
lines changed

9 files changed

+12
-84
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
228228
*offsets* are first transformed by *offsetTrans* before being
229229
applied.
230230
231-
*offset_position* may be either "screen" or "data" depending on the
232-
space that the offsets are in; "data" is deprecated.
231+
*offset_position* is unused now, but the argument is kept for
232+
backwards compatibility.
233233
234234
This provides a fallback implementation of
235235
:meth:`draw_path_collection` that makes multiple calls to
@@ -401,11 +401,6 @@ def _iter_collection(self, gc, master_transform, all_transforms,
401401
Naa = len(antialiaseds)
402402
Nurls = len(urls)
403403

404-
if offset_position == "data":
405-
_api.warn_deprecated(
406-
"3.3", message="Support for offset_position='data' is "
407-
"deprecated since %(since)s and will be removed %(removal)s.")
408-
409404
if (Nfacecolors == 0 and Nedgecolors == 0) or Npaths == 0:
410405
return
411406
if Noffsets:
@@ -425,17 +420,6 @@ def _iter_collection(self, gc, master_transform, all_transforms,
425420
path_id = path_ids[i % Npaths]
426421
if Noffsets:
427422
xo, yo = toffsets[i % Noffsets]
428-
if offset_position == 'data':
429-
if Ntransforms:
430-
transform = (
431-
Affine2D(all_transforms[i % Ntransforms]) +
432-
master_transform)
433-
else:
434-
transform = master_transform
435-
(xo, yo), (xp, yp) = transform.transform(
436-
[(xo, yo), (0, 0)])
437-
xo = -(xp - xo)
438-
yo = -(yp - yo)
439423
if not (np.isfinite(xo) and np.isfinite(yo)):
440424
continue
441425
if Nfacecolors:

lib/matplotlib/backends/backend_agg.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ def _update_methods(self):
109109
self.draw_gouraud_triangles = self._renderer.draw_gouraud_triangles
110110
self.draw_image = self._renderer.draw_image
111111
self.draw_markers = self._renderer.draw_markers
112-
# This is its own method for the duration of the deprecation of
113-
# offset_position = "data".
114-
# self.draw_path_collection = self._renderer.draw_path_collection
112+
self.draw_path_collection = self._renderer.draw_path_collection
115113
self.draw_quad_mesh = self._renderer.draw_quad_mesh
116114
self.copy_from_bbox = self._renderer.copy_from_bbox
117115

@@ -163,19 +161,6 @@ def draw_path(self, gc, path, transform, rgbFace=None):
163161
raise OverflowError("Exceeded cell block limit (set "
164162
"'agg.path.chunksize' rcparam)") from err
165163

166-
def draw_path_collection(self, gc, master_transform, paths, all_transforms,
167-
offsets, offsetTrans, facecolors, edgecolors,
168-
linewidths, linestyles, antialiaseds, urls,
169-
offset_position):
170-
if offset_position == "data":
171-
_api.warn_deprecated(
172-
"3.3", message="Support for offset_position='data' is "
173-
"deprecated since %(since)s and will be removed %(removal)s.")
174-
return self._renderer.draw_path_collection(
175-
gc, master_transform, paths, all_transforms, offsets, offsetTrans,
176-
facecolors, edgecolors, linewidths, linestyles, antialiaseds, urls,
177-
offset_position)
178-
179164
def draw_mathtext(self, gc, x, y, s, prop, angle):
180165
"""Draw mathtext using :mod:`matplotlib.mathtext`."""
181166
ox, oy, width, height, descent, font_image, used_characters = \

src/_backend_agg.h

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,7 @@ class RendererAgg
176176
ColorArray &edgecolors,
177177
LineWidthArray &linewidths,
178178
DashesVector &linestyles,
179-
AntialiasedArray &antialiaseds,
180-
e_offset_position offset_position);
179+
AntialiasedArray &antialiaseds);
181180

182181
template <class CoordinateArray, class OffsetArray, class ColorArray>
183182
void draw_quad_mesh(GCAgg &gc,
@@ -277,7 +276,6 @@ class RendererAgg
277276
LineWidthArray &linewidths,
278277
DashesVector &linestyles,
279278
AntialiasedArray &antialiaseds,
280-
e_offset_position offset_position,
281279
bool check_snap,
282280
bool has_curves);
283281

@@ -911,7 +909,6 @@ inline void RendererAgg::_draw_path_collection_generic(GCAgg &gc,
911909
LineWidthArray &linewidths,
912910
DashesVector &linestyles,
913911
AntialiasedArray &antialiaseds,
914-
e_offset_position offset_position,
915912
bool check_snap,
916913
bool has_curves)
917914
{
@@ -969,11 +966,7 @@ inline void RendererAgg::_draw_path_collection_generic(GCAgg &gc,
969966
double xo = offsets(i % Noffsets, 0);
970967
double yo = offsets(i % Noffsets, 1);
971968
offset_trans.transform(&xo, &yo);
972-
if (offset_position == OFFSET_POSITION_DATA) {
973-
trans = agg::trans_affine_translation(xo, yo) * trans;
974-
} else {
975-
trans *= agg::trans_affine_translation(xo, yo);
976-
}
969+
trans *= agg::trans_affine_translation(xo, yo);
977970
}
978971

979972
// These transformations must be done post-offsets
@@ -1047,8 +1040,7 @@ inline void RendererAgg::draw_path_collection(GCAgg &gc,
10471040
ColorArray &edgecolors,
10481041
LineWidthArray &linewidths,
10491042
DashesVector &linestyles,
1050-
AntialiasedArray &antialiaseds,
1051-
e_offset_position offset_position)
1043+
AntialiasedArray &antialiaseds)
10521044
{
10531045
_draw_path_collection_generic(gc,
10541046
master_transform,
@@ -1064,7 +1056,6 @@ inline void RendererAgg::draw_path_collection(GCAgg &gc,
10641056
linewidths,
10651057
linestyles,
10661058
antialiaseds,
1067-
offset_position,
10681059
true,
10691060
true);
10701061
}
@@ -1175,7 +1166,6 @@ inline void RendererAgg::draw_quad_mesh(GCAgg &gc,
11751166
linewidths,
11761167
linestyles,
11771168
antialiaseds,
1178-
OFFSET_POSITION_FIGURE,
11791169
true, // check_snap
11801170
false);
11811171
}

src/_backend_agg_basic_types.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ class Dashes
6969

7070
typedef std::vector<Dashes> DashesVector;
7171

72-
enum e_offset_position {
73-
OFFSET_POSITION_FIGURE,
74-
OFFSET_POSITION_DATA
75-
};
76-
7772
class GCAgg
7873
{
7974
public:

src/_backend_agg_wrapper.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,10 @@ PyRendererAgg_draw_path_collection(PyRendererAgg *self, PyObject *args, PyObject
330330
DashesVector dashes;
331331
numpy::array_view<const uint8_t, 1> antialiaseds;
332332
PyObject *ignored;
333-
e_offset_position offset_position;
333+
PyObject *offset_position; // offset position is no longer used
334334

335335
if (!PyArg_ParseTuple(args,
336-
"O&O&OO&O&O&O&O&O&O&O&OO&:draw_path_collection",
336+
"O&O&OO&O&O&O&O&O&O&O&OO:draw_path_collection",
337337
&convert_gcagg,
338338
&gc,
339339
&convert_trans_affine,
@@ -356,7 +356,6 @@ PyRendererAgg_draw_path_collection(PyRendererAgg *self, PyObject *args, PyObject
356356
&antialiaseds.converter,
357357
&antialiaseds,
358358
&ignored,
359-
&convert_offset_position,
360359
&offset_position)) {
361360
return NULL;
362361
}
@@ -376,8 +375,7 @@ PyRendererAgg_draw_path_collection(PyRendererAgg *self, PyObject *args, PyObject
376375
edgecolors,
377376
linewidths,
378377
dashes,
379-
antialiaseds,
380-
offset_position)));
378+
antialiaseds)));
381379
}
382380
catch (const py::exception &)
383381
{

src/_path.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,6 @@ void point_in_path_collection(double x,
442442
OffsetArray &offsets,
443443
agg::trans_affine &offset_trans,
444444
bool filled,
445-
e_offset_position offset_position,
446445
std::vector<int> &result)
447446
{
448447
size_t Npaths = paths.size();
@@ -478,11 +477,7 @@ void point_in_path_collection(double x,
478477
double xo = offsets(i % Noffsets, 0);
479478
double yo = offsets(i % Noffsets, 1);
480479
offset_trans.transform(&xo, &yo);
481-
if (offset_position == OFFSET_POSITION_DATA) {
482-
trans = agg::trans_affine_translation(xo, yo) * trans;
483-
} else {
484-
trans *= agg::trans_affine_translation(xo, yo);
485-
}
480+
trans *= agg::trans_affine_translation(xo, yo);
486481
}
487482

488483
if (filled) {

src/_path_wrapper.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,11 @@ static PyObject *Py_point_in_path_collection(PyObject *self, PyObject *args, PyO
332332
numpy::array_view<const double, 2> offsets;
333333
agg::trans_affine offset_trans;
334334
bool filled;
335-
e_offset_position offset_position;
335+
PyObject *offset_position; // no longer used
336336
std::vector<int> result;
337337

338338
if (!PyArg_ParseTuple(args,
339-
"dddO&OO&O&O&O&O&:point_in_path_collection",
339+
"dddO&OO&O&O&O&O:point_in_path_collection",
340340
&x,
341341
&y,
342342
&radius,
@@ -351,7 +351,6 @@ static PyObject *Py_point_in_path_collection(PyObject *self, PyObject *args, PyO
351351
&offset_trans,
352352
&convert_bool,
353353
&filled,
354-
&convert_offset_position,
355354
&offset_position)) {
356355
return NULL;
357356
}
@@ -370,7 +369,6 @@ static PyObject *Py_point_in_path_collection(PyObject *self, PyObject *args, PyO
370369
offsets,
371370
offset_trans,
372371
filled,
373-
offset_position,
374372
result)));
375373
}
376374
catch (const py::exception &)

src/py_converters.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -492,22 +492,6 @@ int convert_gcagg(PyObject *pygc, void *gcp)
492492
return 1;
493493
}
494494

495-
int convert_offset_position(PyObject *obj, void *offsetp)
496-
{
497-
e_offset_position *offset = (e_offset_position *)offsetp;
498-
const char *names[] = {"data", NULL};
499-
int values[] = {OFFSET_POSITION_DATA};
500-
int result = (int)OFFSET_POSITION_FIGURE;
501-
502-
if (!convert_string_enum(obj, "offset_position", names, values, &result)) {
503-
PyErr_Clear();
504-
}
505-
506-
*offset = (e_offset_position)result;
507-
508-
return 1;
509-
}
510-
511495
int convert_face(PyObject *color, GCAgg &gc, agg::rgba *rgba)
512496
{
513497
if (!convert_rgba(color, rgba)) {

src/py_converters.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ int convert_trans_affine(PyObject *obj, void *transp);
3434
int convert_path(PyObject *obj, void *pathp);
3535
int convert_clippath(PyObject *clippath_tuple, void *clippathp);
3636
int convert_snap(PyObject *obj, void *snapp);
37-
int convert_offset_position(PyObject *obj, void *offsetp);
3837
int convert_sketch_params(PyObject *obj, void *sketchp);
3938
int convert_gcagg(PyObject *pygc, void *gcp);
4039
int convert_points(PyObject *pygc, void *pointsp);

0 commit comments

Comments
 (0)