Coder Social home page Coder Social logo

samlau95 / nbinteract Goto Github PK

View Code? Open in Web Editor NEW
230.0 7.0 23.0 26.98 MB

Create interactive webpages from Jupyter Notebooks

Home Page: http://www.samlau.me/nbinteract/

License: BSD 3-Clause "New" or "Revised" License

Jupyter Notebook 2.85% HTML 95.81% JavaScript 0.26% CSS 0.15% Makefile 0.03% Python 0.80% Smarty 0.11%
notebook jupyter-notebook interactive-webpages ipywidgets python3

nbinteract's Introduction

‼️ nbinteract is an old research project and is no longer actively maintained. Try https://github.com/voila-dashboards/voila instead. ‼️

nbinteract

Read the Docs Gitter

Build Status PyPI npm

nbinteract is a Python package that creates interactive webpages from Jupyter notebooks. nbinteract also has built-in support for interactive plotting. These interactions are driven by data, not callbacks, allowing authors to focus on the logic of their programs.

nbinteract is most useful for:

  • Data scientists that want to create simple interactive blog posts without having to know / work with Javascript.
  • Instructors that want to include interactive examples in their textbooks.
  • Students that want to publish data analysis that contains interactive demos.

Currently, nbinteract is in an alpha stage because of its quickly-changing API.

Examples

Most plotting functions from other libraries (e.g. matplotlib) take data as input. nbinteract's plotting functions take functions as input.

import numpy as np
import nbinteract as nbi

def normal(mean, sd):
    '''Returns 1000 points drawn at random fron N(mean, sd)'''
    return np.random.normal(mean, sd, 1000)

# Pass in the `normal` function and let user change mean and sd.
# Whenever the user interacts with the sliders, the `normal` function
# is called and the returned data are plotted.
nbi.hist(normal, mean=(0, 10), sd=(0, 2.0), options=options)

example1

Simulations are easy to create using nbinteract. In this simulation, we roll a die and plot the running average of the rolls. We can see that with more rolls, the average gets closer to the expected value: 3.5.

rolls = np.random.choice([1, 2, 3, 4, 5, 6], size=300)
averages = np.cumsum(rolls) / np.arange(1, 301)

def x_vals(num_rolls):
    return range(num_rolls)

# The function to generate y-values gets called with the
# x-values as its first argument.
def y_vals(xs):
    return averages[:len(xs)]

nbi.line(x_vals, y_vals, num_rolls=(1, 300))

example2

Publishing

From a notebook cell:

# Run in a notebook cell to convert the notebook into a publishable HTML page:
#
# nbi.publish('my_binder_spec', 'my_notebook.ipynb')
#
# Replace my_binder_spec with a Binder spec in the format
# {username}/{repo}/{branch} (e.g. SamLau95/nbinteract-image/master).
#
# Replace my_notebook.ipynb with the name of the notebook file to convert.
#
# Example:
nbi.publish('SamLau95/nbinteract-image/master', 'homepage.ipynb')

From the command line:

# Run on the command line to convert the notebook into a publishable HTML page.
#
# nbinteract my_binder_spec my_notebook.ipynb
#
# Replace my_binder_spec with a Binder spec in the format
# {username}/{repo}/{branch} (e.g. SamLau95/nbinteract-image/master).
#
# Replace my_notebook.ipynb with the name of the notebook file to convert.
#
# Example:
nbinteract SamLau95/nbinteract-image/master homepage.ipynb

For more information on publishing, see the tutorial which has a complete walkthrough on publishing a notebook to the web.

Installation

Using pip:

pip install nbinteract

# The next two lines can be skipped for notebook version 5.3 and above
jupyter nbextension enable --py --sys-prefix widgetsnbextension
jupyter nbextension enable --py --sys-prefix bqplot

You may now import the nbinteract package in Python code and use the nbinteract CLI command to convert notebooks to HTML pages.

Tutorial and Documentation

Here's a link to the tutorial and docs for this project.

Developer Install

If you are interested in developing this project locally, run the following:

git clone https://github.com/SamLau95/nbinteract
cd nbinteract

# Installs the nbconvert exporter
pip install -e .

# To export a notebook to interactive HTML format:
jupyter nbconvert --to interact notebooks/Test.ipynb

pip install -U ipywidgets
jupyter nbextension enable --py --sys-prefix widgetsnbextension

brew install yarn
yarn install

# Start notebook and webpack servers
make -j2 serve

Feedback

If you have any questions or comments, send us a message on the Gitter channel. We appreciate your feedback!

Contributors

nbinteract is originally developed by Sam Lau and Caleb Siu as part of a Masters project at UC Berkeley. The code lives under a BSD 3 license and we welcome contributions and pull requests from the community.

nbinteract's People

Contributors

bnavigator avatar cleb11 avatar emmyoop avatar pleabargain avatar samlaf avatar samlau95 avatar yuvipanda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

nbinteract's Issues

Allow users to specify binder params when converting

Right now all converted notebooks can only use the nbinteract-image Binder server. We should let users specify a specific spec to run on the command line somehow.

Maybe something like:

nbinteract --template local --spec "some/other/master" *.ipynb

Handle kernel failure more gracefully

If the kernel fails to start for whatever reason, the user sees the cells to create widgets but no actual widgets appear.

In the ideal case when the kernel fails, the widget cells disappear and are replaced with normal cells that generate plots.

Investigate %matplotlib notebook

In Jupyter notebooks if you use %matplotlib notebook instead of %matplotlib inline the backend is javascript based and plots can be updated very quickly, it doesn't create pngs. This is the best to pair with ipython widgets.

Also note that this doesn't work in JupyterLab. A new matplotlib widget extension has been developed: https://github.com/matplotlib/jupyter-matplotlib.

Add bqplot support

We'd like to support bqplot's widgets since we have some nice demos that use them. A user should be able to create a notebook using bqplot widgets and export them to Gitbook.

Spec Flag/Json Missing

Hi,
Getting the following output when I run nbinteract.publish('owenrog/nbinteract-image/master', 'cow.ipynb') from a cell. However, the following works in CLI: nbinteract -s "owenrog/nbinteract-image/master" cow.ipynb.
....
Saving notebook... Saved 'cow.ipynb'.
Converting notebook...
WARNING:root:
Error when converting :(

Double check that you didn't misspell your filename. This is the filename you
wanted to publish: cow.ipynb.

If you believe this is an error with the package, please report an issue at
https://github.com/SamLau95/nbinteract/issues/new and include the error output
below:

==============

[nbinteract] --spec flag not set and no .nbinteract.json file found. Rerun this
[nbinteract] command with the --spec flag or run nbinteract init to resolve
[nbinteract] this issue.
Usage:
nbinteract init
nbinteract NOTEBOOKS ...
nbinteract [options] NOTEBOOKS ...
nbinteract (-h | --help)

Process of converting Riemann books

  • Cells have to ran manually and saved in order for widget button to be displayed (nbconvert execute did not work, must have widget output)
    TODO: Add button to show run all widgets in notebook at the top of page
  • Binder had problems importing Packages written in github repo
  • Had to add a js script to end of html file to redirect to correct NbInteract image

Dynamic tables

It would be nice to be able to display dynamic html content based on e.g. dropdown choice. I naively assumed the code below would work but it only displays the string values (doesn´t generate html). Anyone have an idea of how this could be achieved?

from IPython.display import display, HTML

def display_dynamic_table(number):
    return display(HTML(number))

interact(display_dynamic_table, number={'a': '<table><tr><td>test a<td/></tr></table>', 'b': '<table><tr><td>test b<td/></tr></table>'})

allow passing custom params to plotting functions

currently, the marker settings for each plot type is hard-coded in the function itself.

e.g. for nbi.hist, we see

params = {
        'marks': [{
            'sample': _array_or_placeholder(hist_function),
            'bins': _get_option('bins'),
            'normalized': _get_option('normalized'),
            'scales': (
                lambda opts: {'sample': opts['x_sc'], 'count': opts['y_sc']}
            ),
        }],

which is passed to ._create_marks, then merged with default marks and finally rendered.

It would be nice to be able to control some aspects of the marks, most importantly colors in order to have better control over the rendering

e.g. in order to generate the color-coded stack bar chart in

https://twitter.com/lukasheinrich_/status/1088760129070219266

I needed these params

params = {
        'marks': [{
            'x': _array_or_placeholder(x_fn, PLACEHOLDER_RANGE),
            'y': _array_or_placeholder(y_fn),
            'colors': bq.CATEGORY10,
            'stroke': '#000000'
        }]
    }

since you already have the utility functions to merge param specs (in create_marks) this seems not too difficult to add.

cc @choldgraf

my web page is not published, give me the following error

WARNING:root:
Error when converting :(

Double check that you didn't misspell your filename. This is the filename you
wanted to publish: tutorial.ipynb.

If you believe this is an error with the package, please report an issue at
https://github.com/SamLau95/nbinteract/issues/new and include the error output
below:

==============

[nbinteract] --spec flag not set and no .nbinteract.json file found. Rerun this
[nbinteract] command with the --spec flag or run nbinteract init to resolve
[nbinteract] this issue.
Usage:
nbinteract init
nbinteract NOTEBOOKS ...
nbinteract [options] NOTEBOOKS ...
nbinteract (-h | --help)

mybinder.org usage

Hello from mybinder.org :) Just wanted to stop by and say that I like nbinteract!

You are by far the biggest user of mybinder.org by number of pods launched. Once in a while we will get about ~350 or so pods related to nbinteract appear all in oen go and then slowly die away again over time. I was wondering if you knew what that could be.

This is what it looks like on grafana.mybinder.org
image

Errors in console for Gitbook

Something is a bit off with closing old kernel connections and moving between pages in the Gitbook results in a bunch of errors in the JS console.

Operation cost estimation

At some point, we'd like to run our own BinderHub so we won't have to worry
about overloading the mybinder.org servers. How much will this cost?

Suppose we want to use Google Cloud (pricing). If we can fit 4 people per
n1-standard-1 machine (1 CPU, 3.75GB RAM), this costs us $6 per notebook
server per month if we assume each server runs non-stop for the entire month. 4
people per CPU seems reasonable since CPU workloads are very bursty (usually
one complete notebook run, plus interactions afterwards).

My guess is that we'll get a mix of regular usage from textbooks and bursty
usage from blog posts. Let's analyze these costs separately.

Data 100 has 650 students in Spring 2018. About 200 students have used the
textbook at least once and we're getting an average of 10 users per hour during
9am-midnight. If each user starts a Binder server, this comes out to about $75
a month including overhead for running JupyterHub. This will be the most
predictable cost for us in the short term.

If someone makes a blog post that requests a thousand servers for 24 hours
straight, this will cost us about $200 to handle. If bursts of activity like
this happen twice a month this comes out to $400 per month.

This gives us a total operating cost of around $500 a month if we assume
nbinteract gets pretty popular. It's not too hard to put a cap on the monthly
cost since we can deny server requests once we're full; I think a cap of $1000
a month sounds like reasonable place to start.

Binder spec path "is neither an existing file or folder"

This looks like a great project! Thanks for developing it!

I'm having some trouble getting my widget/notebook to convert correctly. I've tried doing it both through the CLI and through the nbi.publish() function, and in both cases I get this error:

Traceback (most recent call last):
  File "/home/emily/anaconda3/bin/nbinteract", line 11, in <module>
    sys.exit(main())
  File "/home/emily/anaconda3/lib/python3.6/site-packages/nbinteract/cli.py", line 166, in main
    run_converter(arguments)
  File "/home/emily/anaconda3/lib/python3.6/site-packages/nbinteract/cli.py", line 184, in run_converter
    recursive=arguments['--recursive']
  File "/home/emily/anaconda3/lib/python3.6/site-packages/nbinteract/cli.py", line 103, in flatmap
    mapped for item in iterable for mapped in fn(item, *args, **kwargs)
  File "/home/emily/anaconda3/lib/python3.6/site-packages/nbinteract/cli.py", line 103, in <listcomp>
    mapped for item in iterable for mapped in fn(item, *args, **kwargs)
  File "/home/emily/anaconda3/lib/python3.6/site-packages/nbinteract/cli.py", line 367, in expand_folder
    .format(notebook_or_folder)
ValueError: emilydolson/ecology_of_evolutionary_computation/master is neither an existing file nor a folder.

This the notebook I'm trying to publish: https://github.com/emilydolson/ecology_of_evolutionary_computation/blob/master/EEBB_talk.ipynb

In case it matters, I'm doing this on Linux Mint 18.3 and Python3 installed through Anaconda. Let me know if there's any more information that would be helpful.

Figure out why we're overloading Binder

#33 and jupyterhub/mybinder.org-user-guide#34 report that the mybinder.org
servers are overloaded with notebook servers for the nbinteract docs
(https://github.com/SamLau95/nbinteract-image) and the Data 100 textbook
(https://github.com/DS-100/textbook).

The morning of Feb 7, 2018, @yuvipanda wisely blocked both repos on
mybinder.org and immediately saw pod usage go back to normal levels.

After Yuvi notified me of this, I made the following changes to the places
where we use nbinteract:

  1. We only start a Binder server when a user manually clicks a Run Widgets
    button instead of on page load. Although this was implemented a long time
    ago, I mis-configured the nbinteract docs and Data 100 textbook (my bad!).

    Example page with Run Widgets button: https://www.textbook.ds100.org/ch4/cleaning_1.html

    To verify the implementation, I visited the page above, opened the Network
    tab in the dev tools, and made a hard page refresh. I checked that the page
    makes no requests to mybinder.org until the Run Widgets button is clicked.

  2. Following @minrk 's suggestion, I cache Binder server information in
    localStorage to re-use servers across page refreshes.

    To verify the implementation, I started a local notebook server and opened a
    page that used nbinteract locally. I checked that the page re-uses the
    same kernel across page refreshes and hard refreshes.

After I made these changes, Yuvi unblocked us but had to immediately block us
again because mybinder.org was still getting hammered with notebook requests!

My first thought was that many students were visiting the Data 100 textbook
with old versions of Javascript cached by their browsers. However, it looks
like neither nbinteract docs nor Data 100 textbook got enough traffic to
produce the load that the Binder team reported. Here are the pageviews plotted
for each hour from 12am-3pm Feb 7, 2018 (Yuvi blocked us for the second time
at around 2pm):

Data 100 textbook:

screenshot 2018-02-07 14 15 51

nbinteract docs:

screenshot 2018-02-07 14 17 49

There were a max of 25 pageviews during any given hour across both of these
Gitbooks, far below the numerous notebook requests that the mybinder.org
servers received. The pageview data is from Google Analytics and matches the
separately generated pageview data from the built-in Gitbook platform so I'm
inclined to believe its faithfulness.

It looks like something else is going on but I'm not sure what it could be.
Here are some possibilities:

  1. Some users have a really faulty cached version of the Javascript that
    just repeatedly requests kernels from Binder. We should observe a small set
    of IPs that are repeatedly requesting servers from a browser.
  2. A broken script is running somewhere that repeatedly requests Binder
    servers. We should observe a smaller set of IPs that are repeated requesting
    servers from a non-browser User Agent (e.g. curl).

To distinguish between 1), 2), or other possibilities we'll want to know which
IPs, devices, and user agents are generating these requests.

@yuvipanda @choldgraf @minrk @betatim Do you have any thoughts or suggestions?

Support dependency files at the command line

Binder supports passing in a requirements.txtor environment.yml file to be used in the default binder docker image. This allows simple installation of packages. It seems that currently you are required to create a full github repo with a binder spec. It be nice if we could do:

$ nbinteract -f environment.yml my_notebook_.ipynb

Heavy mybinder.org load

Hi guys,

you are too popular :) This morning we noticed quite a lot of load on mybinder.org and tracked it down to nbinteract.

We track the number of binders launched (in a 10m window), which is plotted here:
https://grafana.mybinder.org/dashboard/db/1-overview?refresh=1m&orgId=1&panelId=17&fullscreen&from=1523872922006&to=1523916122006 basically all of that is nbinteract (after about 6pm Zurich time)

What seems to cause a lot of load for us isn't so much the total number of binders connected to nbinteract but the fact that you are launching a lot of them. Could you implement something that reuses a running binder when a user clicks on a different page or something?

@choldgraf @willingc

Idea to enhance nbviewer with js/css plugins to make nbviewer+ipynb secure, dynamic and mobile friendly

Not long ago the Idea to enhance nbviewer with js/css plugins to make nbviewer+ipynb secure, dynamic and mobile friendly visited me. It came to me when I connected nbviewer and gitbook experience together - how it would be if we join them (plus add security and dynamic content).

I've just found your nbinteract: you added interactivity and use gitbook. So I invite you to discussion of enhancing nbviewer in order to create a new online publishing experience. New in a sense that we are still to get a free secure one click solution convenient both for the content publishers and for content readers on desktop and mobile.

Write nbi.line

Let's add a function called nbi.line that creates an interactive line plot. The API should be similar to nbi.bar:

>>> nbi.line([1, 2, 3], [10, 11, 12])
interactive(...)

>>> def x(max): return np.arange(0, max)
>>> def y(xs, sd): return xs + np.random.normal(len(xs), scale=sd)
>>> nbi.line(x, y, max=(10, 50), sd=(1, 10))
interactive(...)

Unable to publish notebook: "ImportError: No module named 'exporters'"

I created a minimal notebook, with just this content:

import nbinteract
nbinteract.publish('test','Untitled7.ipynb')

Here's the output I get:

Saving notebook... Saved 'Untitled7.ipynb'.
Converting notebook...
WARNING:root:
Error when converting :(

Double check that you didn't misspell your filename. This is the filename you
wanted to publish: Untitled7.ipynb.

If you believe this is an error with the package, please report an issue at
https://github.com/SamLau95/nbinteract/issues/new and include the error output
below:

==============

Traceback (most recent call last):
  File "/usr/local/bin/nbinteract", line 48, in <module>
    from exporters import InteractExporter  # noqa: E402
ImportError: No module named 'exporters'

I would be grateful for any tips as to what I'm doing wrong.

Write nbinteract converter for Gitbook

I'd like to replace all the convert_notebooks_to_html_partial.py files we have across these textbooks:

With something like:

$ nbinteract --gitbook foo.ipynb bar.ipynb

# converts all notebooks in folder and outputs to notebooks-html/
$ nbinteract --gitbook --output notebooks-html notebooks/

# converts all notebooks in folder, outputs to notebooks-html/,
# and outputs images to notebooks-images/
$ nbinteract --gitbook --output notebooks-html --images notebook-images notebooks/

# converts all notebooks in folder and recurses into all subfolders
$ nbinteract --gitbook -r notebooks/

# converts all notebooks in folder and recurses into all subfolders,
# then outputs notebooks into notebooks-html without folders
$ nbinteract --gitbook --output notebooks-html -r notebooks/

Here's a docopt docstring that I think might work:

'''Converts notebooks to interactive HTML pages or Gitbook pages.

Usage:
  nbinteract NOTEBOOKS...

Arguments:
  NOTEBOOKS  The list of notebooks or folders containing notebooks to convert.

Options:
  -g --gitbook               Convert to HTML partial for Gitbook
  -r --recursive             Recursively convert notebooks in subdirectories.
                             Leaves HTML files in the same folders as the
                             original notebooks.
  -o FOLDER --output=FOLDER  Outputs HTML files into FOLDER. If -r is also set,
                             will not recreate input folder structure in output
                             folder (all output files are direct children of
                             FOLDER).
  -i FOLDER --images=FOLDER  Extracts images from HTML and writes into FOLDER.
                             Requires -o option to be set as well.
'''

Right now we have the following CLI option:

$ nbinteract my_notebook.ipynb

Which is a simple alias of

$ jupyter nbconvert --to interact my_notebook.ipynb

We'll have to change the script to use Python instead of bash.

Write tests

We only have doctests right now :(.

I think starting with the Python converter is probably the easiest place to start. Then we can write tests for the JS.

Allow Custom Templates

I think that the options provided in the default templates are great but for example I would like to create my own template, with custom title, a GA tracker code and without Bootstrap and I didn't want to alter the source files to do so but rather write my own template.

Binder error web page publish - "Could not resolve ref for gh. . ."

"""""""
Windows 7, behind a proxy
Running tutorial straight from http://mybinder.org/
""""""""

Followed your tutorial steps:

https://www.nbinteract.com/tutorial/tutorial_intro.html

I created a public repo: https://github.com/SantiagoG/nbinteract-test

Initializing nbinteract (Binder terminal):

`jovyan@jupyter-santiagog-2dnbinteract-2dtest-2dhjwtpv4i:~$ nbinteract init

[nbinteract] Initializing folder for nbinteract.
[nbinteract]
[nbinteract] Checking to see if this folder is the root folder of a git project.
[nbinteract] Looks like we're in the root of a git project.
[nbinteract]
[nbinteract] Checking for requirements.txt or Dockerfile.
[nbinteract] requirements.txt found.
[nbinteract]
[nbinteract] Generating .nbinteract.json file...
[nbinteract] Created .nbinteract.json file successfully
[nbinteract]
[nbinteract] Initialization complete! Now, you should make a git commit with the
[nbinteract] files created by in this process and push your commits to GitHub.
[nbinteract]
[nbinteract] After you push, you should visit
[nbinteract] https://mybinder.org/v2/gh/nbinteract/test/master and verify that
[nbinteract] your Binder image successfully starts.
`

When clicking binder link I get:

Could not resolve ref for gh:nbinteract/test/master. Double check your URL.

Also stuck at your web page publishing steps. Widgets fail to load after following publishing steps in Github Pages:

tutorial steps: https://www.nbinteract.com/tutorial/tutorial_publishing.html

SantiagoG.github.io/nbinteract-test/tutorial.html

image

Thanks much!

Add ability to specify notebook server instead of Binder server

Right now, the JS API only allows specifying a Binder URL. To start a widget, the JS does three things:

  1. Request a notebook server from Binder.
  2. Request a Python kernel from the notebook server.
  3. Connect the widgets to the Python kernel.

It should also be possible to specify the URL of a running notebook server as well. This will skip step 1), which happens to also be the most time-consuming step by far for initial widget render — step 1) takes something on the order of 10 seconds; steps 2) and 3) take around 100ms.

The author will have to set up a publicly facing notebook server themself, however, since binder.org requires users to go through step 1) before we can do step 2) and 3).

Requested by @mathematicalmichael

Main page error

Thanks for your work on this project @SamLau95 !!


On this page: https://www.nbinteract.com/
There is an error for me when showing widgets in one of the cells.

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
/srv/venv/lib/python3.6/site-packages/ipywidgets/widgets/interaction.py in update(self, *args)
    248                     value = widget.get_interact_value()
    249                     self.kwargs[widget._kwarg] = value
--> 250                 self.result = self.f(**self.kwargs)
    251                 show_inline_matplotlib_plots()
    252                 if self.auto_display and self.result is not None:

/srv/venv/lib/python3.6/site-packages/nbinteract/plotting.py in wrapped(**interact_params)
    499         line.x = x_data
    500 
--> 501         y_bound = util.maybe_curry(y_fn, x_data)
    502         line.y = util.maybe_call(y_bound, interact_params, prefix='y')
    503 

/srv/venv/lib/python3.6/site-packages/nbinteract/util.py in maybe_curry(maybe_fn, first_arg)
     41     if not callable(maybe_fn):
     42         return maybe_fn
---> 43     return toolz.curry(maybe_fn)(first_arg)
     44 
     45 

NameError: name 'toolz' is not defined

Unicode issues/support?

I am having the same issue as presented in #74 , but I have tried the workaround listed at #77 and came across an interesting error (see Jupyter terminal output below).

I am using unicode characters in my notebook (though, I am not using copied characters, I am using the decimal code in HTML/markdown, like &#178;, or the Python equivalent, \u00B2, where appropriate). Does nbinteract support unicode? (and, if not will it eventually?) Oddly, the unicode character referenced in the error, \u2265 (the greater-than or equal to sign), is not one I used anywhere in my notebook. When looking at my notebook in Notepad++, that character was not located in the 424231st position like the error states either.

I am still very new to all of this, so it's possible I have goofed somewhere too. Thanks!

(Also, does/will nbinteract have matplotlib support? I don't see matplotlib listed anywhere in your documentation, so perhaps my use of it is what is causing this error?)

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS D:\Google Drive\Sync Locally\SHAEDIT> nbinteract -s Lindt8/SHAEDIT/master SHAEDIT.ipynb
?[0;34m[nbinteract] ?[0mConverting notebooks to HTML...
Traceback (most recent call last):
File "c:\users\hunter\anaconda3\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec)
File "c:\users\hunter\anaconda3\lib\runpy.py", line 85, in _run_code exec(code, run_globals)
File "C:\Users\Hunter\Anaconda3\Scripts\nbinteract.exe\__main__.py", line 9, in <module>
File "c:\users\hunter\anaconda3\lib\site-packages\nbinteract\cli.py", line 166, in main run_converter(arguments)
File "c:\users\hunter\anaconda3\lib\site-packages\nbinteract\cli.py", line 203, in run_converter images_folder=arguments['--images']
File "c:\users\hunter\anaconda3\lib\site-packages\nbinteract\cli.py", line 449, in convert outfile.write(final_output)
File "c:\users\hunter\anaconda3\lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2265' in position 424231: character maps to <undefined>
PS D:\Google Drive\Sync Locally\SHAEDIT>

Allow hist to take in bins

nbi.hist should allow the user to input bins as an option:

options = { 'bins': np.arange(10) }

nbi.hist([1, 2, 3, 3], options=options)

Github Gists are already Supported!

I was experimenting a bit and it isn't necessary to create a Github Repo, instead, one can create a Github Gist and use it.

To achieve this, follow this format in the nbinteract.json file:

{
    "spec": "{username}/{gist ID}/master",
    "provider": "gist"
}

The only problem is that using "provider" in the json file doesn't update the provider in the HTML. So in the HTML instead of having

var interact = new window.NbInteract({
      spec: '{username}/{repo}/master',
      baseUrl: 'https://mybinder.org',
      provider: 'gh',
    })

The code generated should be:

var interact = new window.NbInteract({
      spec: '{username}/{gist ID}/master',
      baseUrl: 'https://mybinder.org',
      provider: 'gist',  <- Read from nbinteract.json
    })

I've already tested changing the value in the HTML manually and it works without problems. I think that changing the code to perform this shouldn't be much complicated but until it's done, the manual change works.

I find this method much more practical since one shouldn't want to create a separate repo for each notebook or more convoluted alternatives (such as having unrelated notebooks in a common repo to achieve the same)

Implement kernel status indicator

Right now the kernel loads / fails to load completely in the background, but we'd like some indication on the page of the loading progress since it can take >5 secs.

Write nbi.scatter

We currently have an nbi.scatter_drag method which creates a scatterplot with draggable points.

However, this doesn't work super well when generating points using functions. For example:

>>> def x(): return np.arange(10)
>>> def y(xs): return xs + 10

>>> scatter_drag(x, y) # Dragging points conflicts with function outputs

We should instead have an nbi.scatter function that doesn't allow point dragging but takes in response functions like the other plotting functions:

>>> def x(n): return np.random.normal(n)
>>> def y(xs): return np.random.normal(len(xs))
>>> scatter(x, y, n=100)
interactive(...)

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.