Code Monkey home page Code Monkey logo

jupyter-sigplot's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jupyter-sigplot's Issues

Fix Python dependency versioning

We removed the versions to fix #47, but it seems this is breaking fresh installations of Jupyter-SigPlot in Python 2 (Python 3 works).

@RinconResearch @sterre what versions are you and your customers able to use? My environment is very flexible, so I can use the latest version, but one of my customers is constrained by Jupyter 5.2.2 and ipywidgets==6.0.2 (still need to fix this, see #40.

cc @jrmims

Explore re-architecture of server-client interaction

Per @sterre's recommendation:

Explore generically dispatching server-side calls to the client as much as possible; for example, a Python call to sp.change_settings({'xmin': 0}) would be sent to the browser side as something like a json {"function": "change_settings", "arguments": { "xmin": 0 } (ideally without special Python-side logic for the function name, either). It might be able to replace oldArrays, oldHrefs, and inputs, and possibly make future API changes to the Javascript SigPlot object transparently available to to widget.

This would require some pre-processing for those cases where we're currently moving files into a space accessible to the notebook server--this needs to be done generically.

Setup Travis-CI

Setup for #4. Will need:

  • Setup travis in general, add badge, etc.
  • Python
    • Tests
    • Flake8/pep8
    • Coverage
  • [ ] JS Replacing with Selenium

"Development Installation" instructions typo

  • git URL is advertised as: git clone https://github.com/LGS Innovations/jupyterSigplot.git
  • But the whitespace in LGS Innovations appears to be erroneous
  • The URL that worked for me was: git clone https://github.com/LGSInnovations/jupyterSigplot.git

`_done` has odd behavior

Client-side code in _done creates, but then immediately removes, an element for the PNG rendering of the plot's canvas.

Add tests

Both Python and JS tests. The JS tests should simply make sure the right values are being passed to SigPlot.js and the Python tests should make sure the right objects are being created (that end up getting synched with the JS side).

  • Python Tests
  • JS Tests
  • Python Selenium Tests to test JS

Version 0.1.1 of the extension does not import because it references removed example module

There's still an import from the removed example module in __init__.py that prevents successful import of jupyter_sigplot at version 0.1.1:

from .example import *

Removing this line allows successful import and instantiation of a widget.

It seems likely that testing was done in a clone that still had the removed module in place, suggesting an opportunity for automated testing.

Running in MyBinder - Failed to load data

Running the MyBinder demo, I get lots of error pop-ups from hub.mybinder.org saying:

Failed to load data

whenever I try to load data in, with the result that the demo notebook does not show off the full range of capabilities of the SigPlot package.

Fix Documentation

Some old documentation (e.g., jupyter_sigplot.sigplot.SigPlot was modified to .Plot)

Save rendered SigPlot images with the notebook

We've talked about this some in person and on Slack. This issue is just trying to capture some of what we've discussed, with no strong organization.

Currently, when a saved notebook is re-opened, SigPlot widgets do not reliably show a rendered image without re-evaluating the generating cell and all dependencies. This is especially vexing in cases like nbviewer or GitHub / GitLab, and is likely a showstopper if the original data is no longer available.

There's some nascent logic in the extension around done and imageOutput that looks like it wants to capture a png from SigPlot and save it to the client for rich representation. This seems like a solid approach, with the only question being how to make that PNG repr display at the right time. It's possible that widgets and rich representation don't mix--this from a very quick experiment where I tried to add an HTML representation to the hello world widget.

Libraries like Matplotlib/Seaborn and Bokeh seem to address this by using a Javascript rich representation instead of a bona fide widget. I make this claim based on observing what's saved with a notebook containing figures from each library.

  • Matplotlib with %matplotlib notebook generates a Javascript and image representation. On load, the image is displayed until the cell is re-evaluated.
  • Matplotlib with %matplotlib inline just generates an image repr.
  • (Seaborn is a wrapper around Matplotlib, and its save semantics are the same.)
  • Bokeh generates a Javascript representation that appears to load the required library from a CDN (I believe it can also be inlined), plus a JSON representation that the Javascript code renders.

I thought D3 might be a reasonable analog to SigPlot, so went looking for some examples of D3 in a notebook. Here's what I found. None of these is as complete as we might like.

It appears that Javascript reprs take precedence over other rich reprs. This may depend on whether the notebook is trusted. If you return None from a _repr_* function, that repr is not used, which could potentially allow us to wait until a PNG was available before rendering it.

Whatever the representation in the saved notebook, it needs to deal gracefully with very large input data. Matplotlib and Bokeh do this by serializing the figure instead of the data. (There's a size inflation for small data sets, but a big saving on larger data.) A DataShader-style approach may also be relevant.

JupyterLab has a different extension model, and also restricts Javascript content.

Remove or fix magics.

The overlay_array, overlay_href, overlay_file, and plot functions all have the @register_line_cell_magic decorator, but they don't actually seem to work as magics. They should be fixed or removed.

Unicode strings not handled quite right in Python 2

We have several checks like isinstance(arg, str) that return False in Python 2 if the argument is a Unicode string. This happens in practice if you're using Jupyter magics for plotting, and passing the magic argument to __init__, overlay_href, or overlay_file.

You can get the right answer in Python 2 by checking isinstance(..., basestring) instead, but the basestring type does not exist in Python 3, where all strings are Unicode. Neither does the unicode type.

One way to fix this would be to replace those base isinstance calls with calls to a function that makes a version-appropriate check. Another is to have your magic call str(line), which will do the right thing in both Python 2 and Python 3, but at the expense of requiring the magic author to remember to do this.

Recommend we decide how we want to address this (as code or documentation), then implement.

_unravel_path tests are not extensible

@sterre On macOS, /tmp is actually a link to /private/tmp, so test_unravel_path fails.

>               assert(actual == expected)
E               AssertionError: assert '/private/tmp' == '/tmp'
E                 - /private/tmp
E                 + /tmp

Plot is very slow to display large array via overlay_array

When I use overlay_array to plot a large array (e.g. 20M points) it takes a significant amount of time (i.e. over one minute) for the data to be displayed in the widget. This is basically what my notebook looks like:

In[1]:

from jupyter_sigplot.sigplot import SigPlot
import numpy as np

x = np.arange(0, 200e3, 0.01)
sinx = np.sin(x)
cosx = np.cos(x)

In[2]:

plot = SigPlot(sinx, cosx, xi=True, cross=True, all=True)
plot.plot()

In[4]:

# After writing sinx and cosx to Type 1000 'SF' files ...
plot = SigPlot("sinx.tmp", "cosx.tmp", xi=True, cross=True, all=True)
plot.plot()

When I evaluate the second cell, a blank plot is displayed right away, but the data takes over a minute to show up, and there is no indication that any background work is taking place.

When I evaluate the fourth cell, the full plot is displayed almost instantly, including the data.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.