5252`matplotlib.projections.polar` may also be of interest.
5353"""
5454
55- from .. import axes , _docstring
55+ from .. import _api , axes , _docstring
5656from .geo import AitoffAxes , HammerAxes , LambertAxes , MollweideAxes
5757from .polar import PolarAxes
5858
@@ -78,9 +78,10 @@ def register(self, *projections):
7878 name = projection .name
7979 self ._all_projection_types [name ] = projection
8080
81- def get_projection_class (self , name ):
81+ def get_projection_class (self , name , _error_cls = KeyError ):
8282 """Get a projection class from its *name*."""
83- return self ._all_projection_types [name ]
83+ return _api .getitem_checked (self ._all_projection_types , _error_cls = _error_cls ,
84+ projection = name )
8485
8586 def get_projection_names (self ):
8687 """Return the names of all projections currently registered."""
@@ -116,10 +117,7 @@ def get_projection_class(projection=None):
116117 if projection is None :
117118 projection = 'rectilinear'
118119
119- try :
120- return projection_registry .get_projection_class (projection )
121- except KeyError as err :
122- raise ValueError ("Unknown projection %r" % projection ) from err
120+ return projection_registry .get_projection_class (projection , _error_cls = ValueError )
123121
124122
125123get_projection_names = projection_registry .get_projection_names
0 commit comments