99import numpy as np
1010from numpy import ma
1111
12- from matplotlib ._path import point_in_path , get_path_extents , \
13- point_in_path_collection , get_path_collection_extents , \
14- path_in_path , path_intersects_path , convert_path_to_polygons , \
15- cleanup_path , points_in_path , clip_path_to_rect
12+ from matplotlib import _path
13+
14+ # ._path import point_in_path, get_path_extents, \
15+ # point_in_path_collection, get_path_collection_extents, \
16+ # path_in_path, path_intersects_path, convert_path_to_polygons, \
17+ # cleanup_path, points_in_path, clip_path_to_rect
1618from matplotlib .cbook import simple_linear_interpolation , maxdict
1719from matplotlib import rcParams
1820
21+
1922class Path (object ):
2023 """
2124 :class:`Path` represents a series of possibly disconnected,
@@ -356,9 +359,10 @@ def iter_segments(self, transform=None, remove_nans=True, clip=None,
356359 CLOSEPOLY = self .CLOSEPOLY
357360 STOP = self .STOP
358361
359- vertices , codes = cleanup_path (self , transform , remove_nans , clip ,
360- snap , stroke_width , simplify , curves ,
361- sketch )
362+ vertices , codes = _path .cleanup_path (
363+ self , transform , remove_nans , clip ,
364+ snap , stroke_width , simplify , curves ,
365+ sketch )
362366 len_vertices = len (vertices )
363367
364368 i = 0
@@ -398,7 +402,7 @@ def contains_point(self, point, transform=None, radius=0.0):
398402 """
399403 if transform is not None :
400404 transform = transform .frozen ()
401- result = point_in_path (point [0 ], point [1 ], radius , self , transform )
405+ result = _path . point_in_path (point [0 ], point [1 ], radius , self , transform )
402406 return result
403407
404408 def contains_points (self , points , transform = None , radius = 0.0 ):
@@ -414,7 +418,7 @@ def contains_points(self, points, transform=None, radius=0.0):
414418 """
415419 if transform is not None :
416420 transform = transform .frozen ()
417- result = points_in_path (points , radius , self , transform )
421+ result = _path . points_in_path (points , radius , self , transform )
418422 return result
419423
420424 def contains_path (self , path , transform = None ):
@@ -426,7 +430,7 @@ def contains_path(self, path, transform=None):
426430 """
427431 if transform is not None :
428432 transform = transform .frozen ()
429- return path_in_path (self , None , path , transform )
433+ return _path . path_in_path (self , None , path , transform )
430434
431435 def get_extents (self , transform = None ):
432436 """
@@ -444,7 +448,7 @@ def get_extents(self, transform=None):
444448 if not transform .is_affine :
445449 path = self .transformed (transform )
446450 transform = None
447- return Bbox (get_path_extents (path , transform ))
451+ return Bbox (_path . get_path_extents (path , transform ))
448452
449453 def intersects_path (self , other , filled = True ):
450454 """
@@ -454,7 +458,7 @@ def intersects_path(self, other, filled=True):
454458 That is, if one path completely encloses the other,
455459 :meth:`intersects_path` will return True.
456460 """
457- return path_intersects_path (self , other , filled )
461+ return _path . path_intersects_path (self , other , filled )
458462
459463 def intersects_bbox (self , bbox , filled = True ):
460464 """
@@ -514,7 +518,7 @@ def to_polygons(self, transform=None, width=0, height=0):
514518
515519 # Deal with the case where there are curves and/or multiple
516520 # subpaths (using extension code)
517- return convert_path_to_polygons (self , transform , width , height )
521+ return _path . convert_path_to_polygons (self , transform , width , height )
518522
519523 _unit_rectangle = None
520524 @classmethod
@@ -833,12 +837,11 @@ def clip_to_bbox(self, bbox, inside=True):
833837 to the outside of the box.
834838 """
835839 # Use make_compound_path_from_polys
836- verts = clip_path_to_rect (self , bbox , inside )
840+ verts = _path . clip_path_to_rect (self , bbox , inside )
837841 paths = [Path (poly ) for poly in verts ]
838842 return self .make_compound_path (* paths )
839843
840844
841- _get_path_collection_extents = get_path_collection_extents
842845def get_path_collection_extents (
843846 master_transform , paths , transforms , offsets , offset_transform ):
844847 """
@@ -869,9 +872,10 @@ def get_path_collection_extents(
869872 from transforms import Bbox
870873 if len (paths ) == 0 :
871874 raise ValueError ("No paths provided" )
872- return Bbox .from_extents (* _get_path_collection_extents (
875+ return Bbox .from_extents (* _path . get_path_collection_extents (
873876 master_transform , paths , transforms , offsets , offset_transform ))
874877
878+
875879def get_paths_extents (paths , transforms = []):
876880 """
877881 Given a sequence of :class:`Path` objects and optional
@@ -887,5 +891,28 @@ def get_paths_extents(paths, transforms=[]):
887891 from transforms import Bbox , Affine2D
888892 if len (paths ) == 0 :
889893 raise ValueError ("No paths provided" )
890- return Bbox .from_extents (* _get_path_collection_extents (
894+ return Bbox .from_extents (* _path . get_path_collection_extents (
891895 Affine2D (), paths , transforms , [], Affine2D ()))
896+
897+
898+ def _define_deprecated_functions (ns ):
899+ from cbook import deprecated
900+
901+ # The C++ functions are not meant to be used directly.
902+ # Users should use the more pythonic wrappers in the Path
903+ # class instead.
904+ for func , alternative in [
905+ ('point_in_path' , 'path.Path.contains_point' ),
906+ ('get_path_extents' , 'path.Path.get_extents' ),
907+ ('point_in_path_collection' , 'collection.Collection.contains' ),
908+ ('path_in_path' , 'path.Path.contains_path' ),
909+ ('path_intersects_path' , 'path.Path.intersects_path' ),
910+ ('convert_path_to_polygons' , 'path.Path.to_polygons' ),
911+ ('cleanup_path' , 'path.Path.cleaned' ),
912+ ('points_in_path' , 'path.Path.contains_points' ),
913+ ('clip_path_to_rect' , 'path.Path.clip_to_bbox' )]:
914+ ns [func ] = deprecated (
915+ since = '1.3' , alternative = alternative )(getattr (_path , func ))
916+
917+
918+ _define_deprecated_functions (locals ())
0 commit comments