Skip to content

Commit

Permalink
Enable all examples to run
Browse files Browse the repository at this point in the history
Massive change because titles needed to be added to all examples

Maybe, @Titan-C we should consider making titles optional in
sphinx-gallery (and using the file name if no title), because it will
make adoption easier.
  • Loading branch information
GaelVaroquaux committed Sep 21, 2015
1 parent 98a424f commit fab5d65
Show file tree
Hide file tree
Showing 138 changed files with 856 additions and 708 deletions.
8 changes: 8 additions & 0 deletions advanced/advanced_numpy/examples/mandelplot.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
"""
Plot Mandelbrot
================
Plot the Mandelbrot ensemble.
"""

import numpy as np
import mandel
x = np.linspace(-1.7, 0.6, 1000)
Expand Down
7 changes: 7 additions & 0 deletions advanced/advanced_numpy/examples/myobject_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"""
Importing the compiled module
==============================
Playing with the module defined in myobject.c
"""

#
# Compile myobject.c first with
#
Expand Down
8 changes: 8 additions & 0 deletions advanced/advanced_numpy/examples/pilbuffer-answer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
"""
From buffer
============
Show how to exchange data between numpy and a library that only knows
the buffer interface.
"""

import numpy as np
import Image

Expand Down
13 changes: 10 additions & 3 deletions advanced/advanced_numpy/examples/pilbuffer.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
"""
Exercise: using the buffer protocole
====================================
Skeletton of the code to do an exercise using the buffer protocole.
"""

import numpy as np
import Image

# Let's make a sample image, RGBA format

x = np.zeros((200, 200, 4), dtype=np.int8)

TODO: fill `x` with fully opaque red [255, 0, 0, 255]
# TODO: fill `x` with fully opaque red [255, 0, 0, 255]

TODO: RGBA images consist of 32-bit integers whose bytes are [RR,GG,BB,AA]
How to get that from ``x``?
# TODO: RGBA images consist of 32-bit integers whose bytes are [RR,GG,BB,AA]
# How to get that from ``x``?

data = ...

Expand Down
8 changes: 8 additions & 0 deletions advanced/advanced_numpy/examples/setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
"""
Building the mandel C-Python extension
=======================================
The "setup.py" script that builds the mandel.so extension from the
C sources.
"""

import os
import sys
from os.path import join
Expand Down
8 changes: 8 additions & 0 deletions advanced/advanced_numpy/examples/setup_myobject.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
"""
Building the extension
=======================
The script to build the extension
"""

from distutils.core import setup, Extension
setup(name='myobject',
version='1.0',
Expand Down
8 changes: 8 additions & 0 deletions advanced/advanced_numpy/examples/stride-diagonals-answer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
"""
Solution to the stride diagonal exercise
=========================================
Solution showing how to use as_strided to stride in diagonal.
"""

import numpy as np
from numpy.lib.stride_tricks import as_strided

Expand Down
7 changes: 7 additions & 0 deletions advanced/advanced_numpy/examples/stride-diagonals.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"""
Exercise: stride in diagonal
==============================
A small striding exercise
"""

import numpy as np
from numpy.lib.stride_tricks import as_strided

Expand Down
8 changes: 8 additions & 0 deletions advanced/advanced_numpy/examples/stride-fakedims.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
"""
Exercise: using strides to create fake dimensions
==================================================
Use strides to create fake dimensions.
"""

import numpy as np
from numpy.lib.stride_tricks import as_strided

Expand Down
125 changes: 0 additions & 125 deletions advanced/advanced_numpy/examples/stride_tricks.py

This file was deleted.

10 changes: 9 additions & 1 deletion advanced/advanced_numpy/examples/view-colors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
"""
Structured array exercise
==========================
Creating a structured array.
"""

import numpy as np
x = np.zeros((10, 10, 4), dtype=np.int8)
x[:,:,0] = 1
x[:,:,1] = 2
Expand All @@ -7,7 +15,7 @@
# How to make a (10, 10) structured array with fields 'r', 'g', 'b', 'a',
# without copying?

y = ...
# y = ...

assert (y['r'] == 1).all()
assert (y['g'] == 2).all()
Expand Down
9 changes: 8 additions & 1 deletion advanced/advanced_numpy/examples/wavreader.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"""
Exercise: reading a wav header
================================
An exercise to learn complex dtypes.
"""

import sys
import numpy as np

Expand All @@ -22,7 +29,7 @@

print wav_header_dtype.fields

# Mini-exercise: Rewrite the above by supplying only the ``sample_rate`` and
# Mini-exercise: Rewrite the above by supplying only the ``sample_rate`` and
# ``num_channels`` fields.
#
# wav_header_dtype = np.dtype(dict(
Expand Down
Loading

0 comments on commit fab5d65

Please sign in to comment.