Test Notebook

A test notebook by Nathan Whitehead Copyright 2015

This notebook is designed to test the styling and functionality of Pineapple. You are reading introductory text right now.

Basic Paragraph

Pineapple is a customized build of Jupyter (formerly known as IPython) designed as an easy way to get started with scientific computing.

It has a list of features:

  • Full power of Python
  • Interactive editing, syntax highlighting
  • Easy download and installation
  • Lots of packages preinstalled
  • Native interface

Platforms

Currently Pineapple runs on:

  1. Linux
  2. Mac OS X 10.6 (Snow Leopard) and later versions
  3. Windows 7 and later (in progress)

Markdown features

There are other markdown features you can use, for example you can do inline code to indicate that x is a variable. The function get_ready is set to True until it gets reset to false.

You can also put code within markdown (will not be runnable). Here is the broken version:

def f(x):
    return f(x)
to do f:
    f

Do not run this code, it will smash your stack.

You can also include links to http://news.ycombinator.com places with or without descriptive text.

Interactive

Let's get down to business. Here is some code.


In [11]:
asdfasdfasdsdssfsdssdfsdf


Out[11]:
4

Are you impressed yet?

Maybe the next one will be more impressive.


In [2]:
%cd


/home/nwhitehead

Notice that the working directory is set to your home directory by default.


In [5]:
from IPython.display import Image
Image(filename='projects/pineapple/data/images/Pineapple-256.png')


Out[5]:

Of course you can also do inline markdown images if you want.

Using special markdown syntax.

Or just good ol' HTML5.

Here it is different, the URL is relative to the notebook file. Much nicer in my opinion.

Let's see what versions of libraries we have.


In [7]:
import sys
print(sys.version)


2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2]

Numpy

The real reason you want to use Python, let's be honest. You want that numpy goodness. You got it.


In [11]:
from numpy import *
a = arange(9).reshape(3, 3); a


Out[11]:
array([[0, 1, 2],
       [3, 4, 5],
       [6, 7, 8]])

In [13]:
a.dot(a)


Out[13]:
array([[ 15,  18,  21],
       [ 42,  54,  66],
       [ 69,  90, 111]])

In [1]:
print('hello')


hello

In [6]:
from IPython.core.display import HTML
HTML('<b>hello</b>')


Out[6]:
hello

In [18]:
def f(x):
    return HTML("<i>{}</i> waa".format(x))

f('Simon')


Out[18]:
Simon waa

In [1]:
%%html
<i>This is italics</i>


This is italics

$\LaTeX$ Section Names

Oh yeah, you can do $\TeX$ inline with dollars or as equations with double dollars.

$$x^2+y^2=z^{x+y}$$

Rich Objects

You can define rich representations of Python objects.


In [6]:
class Fancy(object):
    def __init__(self, text):
        self.text = text
    def __repr_html__(self):
        return "<h3>{}</h3>".format(self.text)

Fancy("Nathan")


Out[6]:
<__main__.Fancy at 0x7f0a3c0c1350>

In [8]:
import numpy as np
maxtime = 3
f1 = 220.0
f2 = 224.0
rate = 8000.0
L = 3
times = np.linspace(0, L, rate*L)
signal = np.sin(2*np.pi*f1*times) + np.sin(2*np.pi*f2*times)

from IPython.display import Audio
Audio(data=signal, rate=rate)


Out[8]:

Matplotlib

What use is data crunching if you can't graph it?


In [10]:
%matplotlib inline

import matplotlib.pyplot as plt
import numpy as np

plt.rcParams['figure.figsize'] = (10.0, 8.0)
plt.figure()
x = np.linspace(0, 3*np.pi, 500)
plt.plot(x,np.sin(np.sin(1.0*x) + x))
plt.title('Phase Modulation plot')
plt.show()



In [ ]: