Temporary First Post (just a test)

First post

This is a simple markdown cell in which I am making my first post.

In [3]:
import matplotlib.pyplot as plt
import numpy as np

def plot_sinewave(amplitude, frequency, color):
    fig, ax = plt.subplots( figsize = (4,3), subplot_kw={axis_bg:'#FFFFFF', axis_below: True})
    
    x = np.linspace(0,20,100)
    ax.plot( x, amplitude*np.sin(frequency*x), color = color, lw=5, alpha = 0.4)
    return fig
/Users/damien/miniconda2/envs/venv/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
  warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
In [9]:
from ipywidgets import interact, SliderWidget, RadioWidget
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
 in ()
----> 1 from ipywidgets import interact, SliderWidget, RadioWidget

ImportError: cannot import name SliderWidget
In [10]:
dir(ipywidgets)
Out[10]:
['Accordion',
 'BoundedFloatText',
 'BoundedIntText',
 'Box',
 'Button',
 'CallbackDispatcher',
 'Checkbox',
 'Color',
 'ColorPicker',
 'Controller',
 'DOMWidget',
 'Dropdown',
 'EventfulDict',
 'EventfulList',
 'FlexBox',
 'FloatProgress',
 'FloatRangeSlider',
 'FloatSlider',
 'FloatText',
 'HBox',
 'HTML',
 'Image',
 'IntProgress',
 'IntRangeSlider',
 'IntSlider',
 'IntText',
 'Label',
 'Latex',
 'Layout',
 'Output',
 'PlaceProxy',
 'Play',
 'Proxy',
 'RadioButtons',
 'Select',
 'SelectMultiple',
 'SelectionSlider',
 'Tab',
 'Text',
 'Textarea',
 'ToggleButton',
 'ToggleButtons',
 'VBox',
 'Valid',
 'Widget',
 '__builtins__',
 '__doc__',
 '__file__',
 '__frontend_version__',
 '__name__',
 '__package__',
 '__path__',
 '__version__',
 '_handle_ipython',
 '_version',
 'domwidget',
 'eventful',
 'find_static_assets',
 'fixed',
 'get_ipython',
 'handle_kernel',
 'handle_version_comm_opened',
 'interact',
 'interact_manual',
 'interaction',
 'interactive',
 'jsdlink',
 'jslink',
 'load_ipython_extension',
 'os',
 'register',
 'register_comm_target',
 'trait_types',
 'version_info',
 'widget',
 'widget_bool',
 'widget_box',
 'widget_button',
 'widget_color',
 'widget_controller',
 'widget_float',
 'widget_image',
 'widget_int',
 'widget_layout',
 'widget_link',
 'widget_output',
 'widget_selection',
 'widget_selectioncontainer',
 'widget_serialization',
 'widget_string',
 'widgets']
In [11]:
import networkx as nx
In [12]:
# wrap a few graph generation functions so they have the same signature

def random_lobster(n, m, k, p):
    return nx.random_lobster(n, p, p / m)

def powerlaw_cluster(n, m, k, p):
    return nx.powerlaw_cluster_graph(n, m, p)

def erdos_renyi(n, m, k, p):
    return nx.erdos_renyi_graph(n, p)

def newman_watts_strogatz(n, m, k, p):
    return nx.newman_watts_strogatz_graph(n, k, p)

def plot_random_graph(n, m, k, p, generator):
    g = generator(n, m, k, p)
    nx.draw(g)
    plt.show()
    
In [13]:
interact(plot_random_graph, n=(2,30), m=(1,10), k=(1,10), p=(0.0, 1.0, 0.001),
         generator={
             'lobster': random_lobster,
             'power law': powerlaw_cluster,
             'Newman-Watts-Strogatz': newman_watts_strogatz,
             u'Erdős-Rényi': erdos_renyi,
         });
In [14]:
interact(lambda x:2^x,x=10)
28
In [15]:
@interact
def powersOf2(x):
    if x >= 0: 
        return 2^x
    return 1.0/2^(-x)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
 in ()
----> 1 @interact
      2 def powersOf2(x):
      3     if x >= 0:
      4         return 2^x
      5     return 1.0/2^(-x)

/Users/damien/miniconda2/envs/venv/lib/python2.7/site-packages/ipywidgets/widgets/interaction.pyc in interact(__interact_f, **kwargs)
    356         #        ...
    357         f = __interact_f
--> 358         w = interactive(f, **kwargs)
    359         try:
    360             f.widget = w

/Users/damien/miniconda2/envs/venv/lib/python2.7/site-packages/ipywidgets/widgets/interaction.pyc in interactive(__interact_f, **kwargs)
    222     kwargs = kwargs.copy()
    223 
--> 224     new_kwargs = _find_abbreviations(f, kwargs)
    225     # Before we proceed, let's make sure that the user has passed a set of args+kwargs
    226     # that will lead to a valid call of the function. This protects against unspecified

/Users/damien/miniconda2/envs/venv/lib/python2.7/site-packages/ipywidgets/widgets/interaction.pyc in _find_abbreviations(f, kwargs)
    179         for name, value, default in _yield_abbreviations_for_parameter(param, kwargs):
    180             if value is empty:
--> 181                 raise ValueError('cannot find widget or abbreviation for argument: {!r}'.format(name))
    182             new_kwargs.append((name, value, default))
    183     return new_kwargs

ValueError: cannot find widget or abbreviation for argument: 'x'