10000 Deprecate Path.has_nonfinite. (#12846) · matplotlib/matplotlib@0ed35b1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0ed35b1

Browse files
anntzertimhoffm
authored andcommitted
Deprecate Path.has_nonfinite. (#12846)
The attribute was introduced in c7837e4 (Oct. 2008) for optimization pruposes, but it is internally unused since 0ad0ee4 (Jan. 2009) when the path nan-handling moved to C++. Since then it's only been touched by additional commits to make sure it is correctly updated by APIs like `cleaned`, but it has far outlived its utility (plus, directly checking the vertices is just as good if you really care -- don't make everyone else pay for it when instantiating Paths).
1 parent 2e95ec4 commit 0ed35b1

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Deprecations
2+
````````````
3+
4+
The ``Path.has_nonfinite`` attribute is deprecated (use ``not
5+
np.isfinite(path.vertices).all()`` instead).

lib/matplotlib/path.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,8 @@ def _fast_from_codes_and_verts(cls, verts, codes, internals=None):
166166
verts : numpy array
167167
codes : numpy array
168168
internals : dict or None
169-
The attributes that the resulting path should have.
170-
Allowed keys are ``readonly``, ``should_simplify``,
171-
``simplify_threshold``, ``has_nonfinite`` and
169+
The attributes that the resulting path should have. Allowed keys
170+
are ``readonly``, ``should_simplify``, ``simplify_threshold``, and
172171
``interpolation_steps``.
173172
174173
"""
@@ -182,7 +181,6 @@ def _fast_from_codes_and_verts(cls, verts, codes, internals=None):
182181
internals.pop('simplify_threshold',
183182
rcParams['path.simplify_threshold'])
184183
)
185-
pth._has_nonfinite = internals.pop('has_nonfinite', False)
186184
pth._interpolation_steps = internals.pop('interpolation_steps', 1)
187185
if internals:
188186
raise ValueError('Unexpected internals provided to '
@@ -198,7 +196,6 @@ def _update_values(self):
198196
len(self._vertices) >= 128 and
199197
(self._codes is None or np.all(self._codes <= Path.LINETO))
200198
)
201-
self._has_nonfinite = not np.isfinite(self._vertices).all()
202199

203200
@property
204201
def vertices(self):
@@ -245,12 +242,14 @@ def simplify_threshold(self):
245242
def simplify_threshold(self, threshold):
246243
self._simplify_threshold = threshold
247244

245+
@cbook.deprecated(
246+
"3.1", alternative="not np.isfinite(self.vertices).all()")
248247
@property
249248
def has_nonfinite(self):
250249
"""
251250
`True` if the vertices array has nonfinite values.
252251
"""
253-
return self._has_nonfinite
252+
return not np.isfinite(self._vertices).all()
254253

255254
@property
256255
def should_simplify(self):
@@ -442,7 +441,6 @@ def cleaned(self, transform=None, remove_nans=False, clip=None,
442441
snap, stroke_width,
443442
simplify, curves, sketch)
444443
internals = {'should_simplify': self.should_simplify and not simplify,
445-
'has_nonfinite': self.has_nonfinite and not remove_nans,
446444
'simplify_threshold': self.simplify_threshold,
447445
'interpolation_steps': self._interpolation_steps}
448446
return Path._fast_from_codes_and_verts(vertices, codes, internals)

lib/matplotlib/textpath.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,6 @@ def __init__(self, xy, s, size=None, prop=None,
480480

481481
self._should_simplify = False
482482
self._simplify_threshold = rcParams['path.simplify_threshold']
483-
self._has_nonfinite = False
484483
self._interpolation_steps = _interpolation_steps
485484

486485
def set_size(self, size):

0 commit comments

Comments
 (0)
0