Skip to content
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

Removed dependency on matplotlib, nbformat and pyparsing in ipython #529

Merged
merged 3 commits into from
Mar 23, 2016
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
36 changes: 23 additions & 13 deletions holoviews/ipython/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,41 @@
from unittest import SkipTest

import param
import jinja2
from IPython import version_info
import numpy as np
import holoviews
from param import ipython as param_ext
from IPython.display import HTML

import holoviews
from ..core.options import Store
from ..core.options import Store, Cycle, Palette
from ..element.comparison import ComparisonTestCase
from ..interface.collector import Collector
from ..plotting.renderer import Renderer
from ..plotting import * # noqa (API import - register plotting backends)
from .archive import notebook_archive
from .magics import load_magics
from .display_hooks import display # noqa (API import)
from .display_hooks import set_display_hooks, OutputMagic
from .parser import Parser
from .widgets import RunProgress

from param import ipython as param_ext
try:
if version_info[0] >= 4:
import nbformat # noqa (ensures availability)
else:
from IPython import nbformat # noqa (ensures availability)
from .archive import notebook_archive
holoviews.archive = notebook_archive
except ImportError:
pass

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect we'll want to add some # noqa lines here for pyflakes...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, the nbformat lines will need it.

try:
import pyparsing
from .parser import Parser
Parser.namespace = {'np': np, 'Cycle': Cycle, 'Palette': Palette}
except ImportError:
pyparsing = None


Collector.interval_hook = RunProgress
holoviews.archive = notebook_archive


def show_traceback():
Expand Down Expand Up @@ -79,6 +94,7 @@ def load_hvjs(logo=False, JS=True, message='HoloViewsJS successfully loaded.'):
"""
Displays javascript and CSS to initialize HoloViews widgets.
"""
import jinja2
# Evaluate load_notebook.html template with widgetjs code
if JS:
widgetjs, widgetcss = Renderer.html_assets(extras=False, backends=[])
Expand All @@ -93,12 +109,6 @@ def load_hvjs(logo=False, JS=True, message='HoloViewsJS successfully loaded.'):
'message':message})))


# Populating the namespace for keyword evaluation
from ..core.options import Cycle, Palette # noqa (namespace import)
import numpy as np # noqa (namespace import)

Parser.namespace = {'np':np, 'Cycle':Cycle, 'Palette': Palette}

class notebook_extension(param.ParameterizedFunction):
"""
Parameterized function to initialize notebook resources
Expand Down
4 changes: 2 additions & 2 deletions holoviews/ipython/display_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import IPython
from IPython.core.ultratb import AutoFormattedTB

import holoviews
from ..core.options import Store, StoreOptions, BackendError, SkipRendering
from ..core import (ViewableElement, UniformNdMapping,
HoloMap, AdjointLayout, NdLayout, GridSpace, Layout,
CompositeOverlay, DynamicMap)
from ..core.traversal import unique_dimkeys
from .magics import OutputMagic, OptsMagic

from .archive import notebook_archive
# To assist with debugging of display hooks
FULL_TRACEBACK = None
ABBREVIATE_TRACEBACKS = True
Expand Down Expand Up @@ -103,7 +103,7 @@ def wrapped(element):
# Only want to add to the archive for one display hook...
disabled_suffixes = ['png_display', 'svg_display']
if not any(fn.__name__.endswith(suffix) for suffix in disabled_suffixes):
notebook_archive.add(element, html=html)
holoviews.archive.add(element, html=html)
filename = OutputMagic.options['filename']
if filename:
Store.renderers[Store.current_backend].save(element, filename)
Expand Down
8 changes: 6 additions & 2 deletions holoviews/ipython/magics.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,15 @@ def list_formats(format_type, backend=None):
"""
if backend is None:
backend = Store.current_backend
mode = Store.renderers[backend].mode
mode = Store.renderers[backend].mode if backend in Store.renderers else None
else:
split = backend.split(':')
backend, mode = split if len(split)==2 else (split[0], 'default')
return Store.renderers[backend].mode_formats[format_type][mode]

if backend in Store.renderers:
return Store.renderers[backend].mode_formats[format_type][mode]
else:
return []


@magics_class
Expand Down