# Path: megaman/plotter/utils.py
# def _check_backend(backend):
#     def decorator(func):
#         def wrapper(*args,**kwargs):
#             import warnings
#             warnings.warn(
#                 'Be careful in using megaman.plotter modules'
#                 ' API will change in the next release.',
#                 FutureWarning
#             )
#             import pkgutil
#             package = pkgutil.find_loader(backend)
#             if package is not None:
#                 return func(*args,**kwargs)
#             else:
#                 raise ImportError('plotting backend {} not installed'.format(backend))
#         return wrapper
#     return decorator


import numpy as np
    import plotly.graph_objs as go
from .utils import _check_backend
    from matplotlib.patches import Ellipse
    from mpl_toolkits.mplot3d import art3d, Axes3D
# Author: Yu-Chia Chen <yuchaz@uw.edu>
#
#
# Transformed 2D patches to 3D after:
#         Till Hoffmann <t.hoffmann13@imperial.ac.uk>
#         https://stackoverflow.com/questions/18228966/how-can-matplotlib-2d-patches-be-transformed-to-3d-with-arbitrary-normals
# LICENSE: Simplified BSD https://github.com/mmp2/megaman/blob/master/LICENSE


def covar_plotter3d_matplotlib(embedding, rieman_metric, inspect_points_idx, ax,
                               colors):
    """3 Dimensional Covariance plotter using matplotlib backend."""
    for pts_idx in inspect_points_idx:
        plot_ellipse_matplotlib( cov=rieman_metric[pts_idx],
                             pos=embedding[pts_idx],
                             ax=ax, ec='k', lw=1,
                             color=colors[pts_idx] )
    return ax


# Path: megaman/plotter/utils.py
# def _check_backend(backend):
#     def decorator(func):
#         def wrapper(*args,**kwargs):
#             import warnings
#             warnings.warn(
#                 'Be careful in using megaman.plotter modules'
#                 ' API will change in the next release.',
#                 FutureWarning
#             )
#             import pkgutil
#             package = pkgutil.find_loader(backend)
#             if package is not None:
#                 return func(*args,**kwargs)
#             else:
#                 raise ImportError('plotting backend {} not installed'.format(backend))
#         return wrapper
#     return decorator


# Path: megaman/plotter/covar_plotter3.py
import numpy as np
    import plotly.graph_objs as go
from .utils import _check_backend
    from matplotlib.patches import Ellipse
    from mpl_toolkits.mplot3d import art3d, Axes3D

# Author: Yu-Chia Chen <yuchaz@uw.edu>
#
#
# Transformed 2D patches to 3D after:
#         Till Hoffmann <t.hoffmann13@imperial.ac.uk>
#         https://stackoverflow.com/questions/18228966/how-can-matplotlib-2d-patches-be-transformed-to-3d-with-arbitrary-normals
# LICENSE: Simplified BSD https://github.com/mmp2/megaman/blob/master/LICENSE


def covar_plotter3d_matplotlib(embedding, rieman_metric, inspect_points_idx, ax,
                               colors):
    """3 Dimensional Covariance plotter using matplotlib backend."""
    for pts_idx in inspect_points_idx:
        plot_ellipse_matplotlib( cov=rieman_metric[pts_idx],
                             pos=embedding[pts_idx],
                             ax=ax, ec='k', lw=1,
                             color=colors[pts_idx] )
    return ax


@_check_backend('matplotlib')