Skip to content

Deprecate BBox.ignore() #17106

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

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 9 additions & 0 deletions doc/api/api_changes_3.3/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -433,3 +433,12 @@ Normalization of upper or mixed-case property names to lowercase in
`.Artist.set` and `.Artist.update` is deprecated. In the future, property
names will be passed as is, allowing one to pass names such as *patchA* or
*UVC*.

``Bbox.ignore``
~~~~~~~~~~~~~~~
The persistent ignore state for `.Bbox` is deprecated and *ignore* should be
explicitly passed to the relevant functions if needed. The method
``Bbox.ignore()`` is deprecated. The parameter *ignore* of
``Bbox.update_from_path()`` and ``Bbox.update_from_data_xy()`` will not accept
None anymore and default to ``True`` instead, which was the default persistent
ignore state.
4 changes: 2 additions & 2 deletions lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -1836,7 +1836,7 @@ def __init__(self, triangulation, **kwargs):
# was rewritten.
xy = np.hstack((triangulation.x.reshape(-1, 1),
triangulation.y.reshape(-1, 1)))
self._bbox.update_from_data_xy(xy)
self._bbox.update_from_data_xy(xy, ignore=True)

def get_paths(self):
if self._paths is None:
Expand Down Expand Up @@ -1924,7 +1924,7 @@ def __init__(self, meshWidth, meshHeight, coordinates,

self._bbox = transforms.Bbox.unit()
self._bbox.update_from_data_xy(coordinates.reshape(
((meshWidth + 1) * (meshHeight + 1), 2)))
((meshWidth + 1) * (meshHeight + 1), 2)), ignore=True)

def get_paths(self):
if self._paths is None:
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/projections/polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ def get_points(self):
wedge = mpatches.Wedge(self._center, points[1, 1],
points[0, 0], points[1, 0],
width=width)
self.update_from_path(wedge.get_path())
self.update_from_path(wedge.get_path(), ignore=True)

# Ensure equal aspect ratio.
w, h = self._points[1] - self._points[0]
Expand Down
32 changes: 32 additions & 0 deletions lib/matplotlib/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,9 @@ def __str__(self):
def __repr__(self):
return 'Bbox([[{0.x0}, {0.y0}], [{0.x1}, {0.y1}]])'.format(self)

@cbook.deprecated("3.3", message="The ignore state is deprecated. Please"
"Please pass *ignore* explicitly to "
"update_fom_data_xy().")
def ignore(self, value):
"""
Set whether the existing bounds of the box should be ignored
Expand Down Expand Up @@ -788,10 +791,23 @@ def update_from_path(self, path, ignore=None, updatex=True, updatey=True):
- when ``False``, include the existing bounds of the `Bbox`.
- when ``None``, use the last value passed to :meth:`ignore`.

*Deprecated*: The persistent ignore state is deprecated and
*ignore* will default to True in the future. Please pass
``ignore=False`` explicitly if needed.

updatex, updatey : bool, optional
When ``True``, update the x/y values.
"""
if ignore is None:
# Note: When removing this deprecation and changing the default
# to True, grep through the codebase to remove some explicit
# ignore=True usages, which were introduced in internal calls to
# prevent the warning.
cbook.warn_deprecated(
"3.3", message="The persistent ignore state is deprecated and "
"will default to True in the future. Please "
"please pass ignore=False explicitly if"
"needed.")
ignore = self._ignore

if path.vertices.size == 0:
Expand Down Expand Up @@ -825,12 +841,28 @@ def update_from_data_xy(self, xy, ignore=None, updatex=True, updatey=True):
- When ``False``, include the existing bounds of the `Bbox`.
- When ``None``, use the last value passed to :meth:`ignore`.

*Deprecated*: The persistent ignore state is deprecated and
*ignore* will default to True in the future. Please pass
``ignore=False`` explicitly if needed.

updatex, updatey : bool, optional
When ``True``, update the x/y values.
"""
if len(xy) == 0:
return

if ignore is None:
# Note: When removing this deprecation and changing the default
# to True, grep through the codebase to remove some explicit
# ignore=True usages, which were introduced in internal calls to
# prevent the warning.
cbook.warn_deprecated(
"3.3", message="The persistent ignore state is deprecated and "
"will default to True in the future. Please "
"please pass ignore=False explicitly if"
"needed.")
ignore = self._ignore

path = Path(xy)
self.update_from_path(path, ignore=ignore,
updatex=updatex, updatey=updatey)
Expand Down
4 changes: 2 additions & 2 deletions lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,11 @@ def auto_scale_xyz(self, X, Y, Z=None, had_data=None):
X = np.reshape(X, -1)
Y = np.reshape(Y, -1)
self.xy_dataLim.update_from_data_xy(
np.column_stack([X, Y]), not had_data)
np.column_stack([X, Y]), ignore=not had_data)
if Z is not None:
Z = np.reshape(Z, -1)
self.zz_dataLim.update_from_data_xy(
np.column_stack([Z, Z]), not had_data)
np.column_stack([Z, Z]), ignore=not had_data)
# Let autoscale_view figure out how to use this data.
self.autoscale_view()

Expand Down