Skip to content

Commit

Permalink
Merge pull request #529 from ioam/fix_requirements
Browse files Browse the repository at this point in the history
Removed dependency on matplotlib, nbformat and pyparsing in ipython
  • Loading branch information
jlstevens committed Mar 23, 2016
2 parents 1c7e285 + 410106b commit 757ac50
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
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

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

0 comments on commit 757ac50

Please sign in to comment.