8000 Cleanup projections/__init__.py. by anntzer · Pull Request #15222 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Cleanup projections/__init__.py. #15222

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

Merged
merged 1 commit into from
Sep 10, 2019
Merged
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
8 changes: 2 additions & 6 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import matplotlib.artist as martist
from matplotlib.artist import Artist, allow_rasterization
from matplotlib.backend_bases import FigureCanvasBase
from matplotlib.backend_bases import FigureCanvasBase, NonGuiException
import matplotlib.cbook as cbook
import matplotlib.colorbar as cbar
import matplotlib.image as mimage
Expand All @@ -33,18 +33,14 @@
from matplotlib.gridspec import GridSpec
import matplotlib.legend as mlegend
from matplotlib.patches import Rectangle
from matplotlib.projections import (get_projection_names,
process_projection_requirements)
from matplotlib.projections import process_projection_requirements
from matplotlib.text import Text, TextWithDash
from matplotlib.transforms import (Affine2D, Bbox, BboxTransformTo,
TransformedBbox)
import matplotlib._layoutbox as layoutbox
from matplotlib.backend_bases import NonGuiException

_log = logging.getLogger(__name__)

docstring.interpd.update(projection_names=get_projection_names())


def _stale_figure_callback(self, val):
if self.figure:
Expand Down
26 changes: 8 additions & 18 deletions lib/matplotlib/projections/__init__.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
from .. import axes, cbook
from .. import axes, docstring, cbook
from .geo import AitoffAxes, HammerAxes, LambertAxes, MollweideAxes
from .polar import PolarAxes
from mpl_toolkits.mplot3d import Axes3D


class ProjectionRegistry:
"""
Manages the set of projections available to the system.
"""
"""A mapping of registered projection names to projection classes."""

def __init__(self):
self._all_projection_types = {}

def register(self, *projections):
"""
Register a new set of projections.
"""
"""Register a new set of projections."""
for projection in projections:
name = projection.name
self._all_projection_types[name] = projection

def get_projection_class(self, name):
"""
Get a projection class from its *name*.
"""
"""Get a projection class from its *name*."""
return self._all_projection_types[name]

def get_projection_names(self):
"""
Get a list of the names of all projections currently registered.
"""
"""Return the names of all projections currently registered."""
return sorted(self._all_projection_types)


Expand Down Expand Up @@ -68,8 +61,5 @@ def process_projection_requirements(figure, *args, **kwargs):
return figure._process_projection_requirements(*args, **kwargs)


def get_projection_names():
"""
Get a list of acceptable projection names.
"""
return projection_registry.get_projection_names()
get_projection_names = projection_registry.get_projection_names
docstring.interpd.update(projection_names=get_projection_names())
0