Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*~
*.pyc
node_modules/*
132 changes: 132 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/* global module:false */
module.exports = function(grunt) {

// Project configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
banner:
'/*!\n' +
' * reveal.js <%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd, HH:MM") %>)\n' +
' * http://lab.hakim.se/reveal-js\n' +
' * MIT licensed\n' +
' *\n' +
' * Copyright (C) 2013 Hakim El Hattab, http://hakim.se\n' +
' */'
},

// Tests will be added soon
qunit: {
files: [ 'test/**/*.html' ]
},

uglify: {
options: {
banner: '<%= meta.banner %>\n'
},
build: {
src: 'js/reveal.js',
dest: 'js/reveal.min.js'
}
},

cssmin: {
compress: {
files: {
'css/reveal.min.css': [ 'css/reveal.css' ]
}
}
},

sass: {
main: {
files: {
'css/theme/default.css': 'css/theme/source/default.scss',
'css/theme/beige.css': 'css/theme/source/beige.scss',
'css/theme/night.css': 'css/theme/source/night.scss',
'css/theme/serif.css': 'css/theme/source/serif.scss',
'css/theme/simple.css': 'css/theme/source/simple.scss',
'css/theme/sky.css': 'css/theme/source/sky.scss',
'css/theme/moon.css': 'css/theme/source/moon.scss',
'css/theme/solarized.css': 'css/theme/source/solarized.scss'
}
}
},

jshint: {
options: {
curly: false,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
eqnull: true,
browser: true,
expr: true,
globals: {
head: false,
module: false,
console: false
}
},
files: [ 'Gruntfile.js', 'js/reveal.js' ]
},

connect: {
server: {
options: {
port: 8000,
base: '.'
}
}
},

zip: {
'reveal-js-presentation.zip': [
'index.html',
'css/**',
'js/**',
'lib/**',
'images/**',
'plugin/**'
]
},

watch: {
main: {
files: [ 'Gruntfile.js', 'js/reveal.js', 'css/reveal.css' ],
tasks: 'default'
},
theme: {
files: [ 'css/theme/source/*.scss', 'css/theme/template/*.scss' ],
tasks: 'themes'
}
}

});

// Dependencies
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
grunt.loadNpmTasks( 'grunt-contrib-uglify' );
grunt.loadNpmTasks( 'grunt-contrib-watch' );
grunt.loadNpmTasks( 'grunt-contrib-sass' );
grunt.loadNpmTasks( 'grunt-contrib-connect' );
grunt.loadNpmTasks( 'grunt-zip' );

// Default task
grunt.registerTask( 'default', [ 'jshint', 'cssmin', 'uglify' ] );

// Theme task
grunt.registerTask( 'themes', [ 'sass' ] );

// Package presentation to archive
grunt.registerTask( 'package', [ 'default', 'zip' ] );

// Serve presentation locally
grunt.registerTask( 'serve', [ 'connect', 'watch' ] );

};
4 changes: 0 additions & 4 deletions data/numbers

This file was deleted.

5 changes: 5 additions & 0 deletions examples/data/numbers
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1 2
3 4
5 6
7 8
9 10
File renamed without changes.
6 changes: 6 additions & 0 deletions examples/intro/01_hello_world.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env python

import math
r = math.pi / 2.0
s = math.sin(r)
print "Hello world, sin(%f)=%f" % (r,s)
28 changes: 28 additions & 0 deletions examples/intro/02_write_numbers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python

import math
import os

data_dir = os.path.join(os.path.dirname(__file__), "..", "data")
infile = os.path.join(data_dir, "numbers")
outfile = os.path.join(data_dir, "f_numbers")

f = open(infile, 'r')
g = open(outfile, 'w')

def func(y):
if y >= 0.0:
return y**5.0*math.exp(-y)
else:
return 0.0


print "Read from", infile

for line in f:
line = line.split()
x, y = float(line[0]), float(line[1])
g.write("%g %12.5e\n" % (x,func(y)))

print "Wrote to", outfile
f.close(); g.close()
15 changes: 15 additions & 0 deletions examples/intro/03_call_sys_commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python

import sys
import os

cmd = 'date'
output = os.popen(cmd)
lines = output.readlines()
fail = output.close()

if fail: print 'You do not have the date command'; sys.exit()

for line in lines:
line = line.split()
print "The current time is %s on %s %s, %s" % (line[3],line[2],line[1],line[-1])
20 changes: 20 additions & 0 deletions examples/intro/04_regular_expressions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python

import os
import re

data_dir = os.path.join(os.path.dirname(__file__), "..", "data")
infile = os.path.join(data_dir, "python.bib")

pattern1 = "@Book{(.*),"
pattern2 = "\s+title\s+=\s+{(.*)},"

print "Reading from", infile
for line in file(infile):
match = re.search(pattern1, line)
if match:
print "Found a book with the tag '%s'" % match.group(1)

match = re.search(pattern2, line)
if match:
print "The title is '%s'" % match.group(1)
3 changes: 3 additions & 0 deletions examples/intro/05_debug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
l = range(10)

l[10] = 5
11 changes: 11 additions & 0 deletions examples/intro/06_simple_plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pylab as pl
import numpy as np

X = np.linspace(-np.pi, np.pi, 256, endpoint=True)
C, S = np.cos(X), np.sin(X)

pl.plot(X, C)
pl.plot(X, S)

#pl.show()
pl.savefig("foo.png")
19 changes: 19 additions & 0 deletions examples/intro/07_simple_plot_customize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pylab as pl
import numpy as np
# Create a figure of size 8x6 points, 80 dots per inch
pl.figure(figsize=(8, 6), dpi=80)
# Create a new subplot from a grid of 1x1
pl.subplot(1, 1, 1)
X = np.linspace(-np.pi, np.pi, 256, endpoint=True)
C, S = np.cos(X), np.sin(X)
# Plot cosine with a blue continuous line of width 1 (pixels)
pl.plot(X, C, color="blue", linewidth=2.5, linestyle="-")
# Plot sine with a green continuous line of width 1 (pixels)
pl.plot(X, S, color="green", linewidth=2.5, linestyle="--") # Set x limits
pl.xlim(-4.0, 4.0) # Set x ticks
pl.xticks(np.linspace(-4, 4, 9, endpoint=True)) # Set y limits
pl.ylim(-1.0, 1.0) # Set y ticks
pl.yticks(np.linspace(-1, 1, 5, endpoint=True)) # Save figure using 72 dots per inch
# savefig("exercice_2.png", dpi=72)
# Show result on screen
pl.show()
23 changes: 23 additions & 0 deletions examples/intro/08_simple_plot_legend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pylab as pl
import numpy as np
# Create a figure of size 8x6 points, 80 dots per inch
pl.figure(figsize=(8, 6), dpi=80)
# Create a new subplot from a grid of 1x1
pl.subplot(1, 1, 1)
X = np.linspace(-np.pi, np.pi, 256, endpoint=True)
C, S = np.cos(X), np.sin(X)
# Plot cosine with a blue continuous line of width 1 (pixels)
pl.plot(X, C, color="blue", linewidth=2.5, linestyle="-", label="cosine")
# Plot sine with a green continuous line of width 1 (pixels)
pl.plot(X, S, color="green", linewidth=2.5, linestyle="--", label="sine") # Set x limits
pl.xlim(-4.0, 4.0) # Set x ticks
pl.xticks(np.linspace(-4, 4, 9, endpoint=True)) # Set y limits
pl.ylim(-1.0, 1.0) # Set y ticks
pl.yticks(np.linspace(-1, 1, 5, endpoint=True)) # Save figure using 72 dots per inch

pl.legend(loc='upper left')


# savefig("exercice_2.png", dpi=72)
# Show result on screen
pl.show()
34 changes: 34 additions & 0 deletions examples/intro/09_simple_plot_spline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import pylab as pl
import numpy as np
# Create a figure of size 8x6 points, 80 dots per inch
pl.figure(figsize=(8, 6), dpi=80)
# Create a new subplot from a grid of 1x1
pl.subplot(1, 1, 1)
X = np.linspace(-np.pi, np.pi, 256, endpoint=True)
C, S = np.cos(X), np.sin(X)
# Plot cosine with a blue continuous line of width 1 (pixels)
pl.plot(X, C, color="blue", linewidth=2.5, linestyle="-", label="cosine")
# Plot sine with a green continuous line of width 1 (pixels)
pl.plot(X, S, color="green", linewidth=2.5, linestyle="--", label="sine") # Set x limits
pl.xlim(-4.0, 4.0) # Set x ticks
pl.xticks(np.linspace(-4, 4, 9, endpoint=True)) # Set y limits
pl.ylim(-1.0, 1.0) # Set y ticks
pl.yticks(np.linspace(-1, 1, 5, endpoint=True)) # Save figure using 72 dots per inch



ax = pl.gca() # gca stands for 'get current axis'
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.spines['bottom'].set_position(('data',0))
ax.yaxis.set_ticks_position('left')
ax.spines['left'].set_position(('data',0))


pl.legend(loc='upper left')


# savefig("exercice_2.png", dpi=72)
# Show result on screen
pl.show()
5 changes: 5 additions & 0 deletions examples/intro/10_histogram.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import pylab
from numpy import random

pylab.plot(random.randn(10000), 100)
pylab.show()
7 changes: 7 additions & 0 deletions examples/intro/11_histogram_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pylab

n, bins, patches = pylab.hist(pylab.randn(1000), 40, normed=1)
l, = pylab.plot(bins, pylab.normpdf(bins, 0.0, 1.0), 'r--', label='fit', linewidth=3)
pylab.legend([l, patches[0]], ['fit', 'hist'])

pylab.show()
33 changes: 33 additions & 0 deletions examples/scale/Bratu3D.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from petsc4py.PETSc cimport Vec, PetscVec
from petsc4py.PETSc cimport Mat, PetscMat
from petsc4py.PETSc cimport DA, PetscDM
from petsc4py.PETSc cimport SNES, PetscSNES

from petsc4py.PETSc import Error

cdef extern from "Bratu3Dimpl.h":
ctypedef struct Params:
double lambda_
int FormInitGuess(PetscDM da, PetscVec x, Params *p)
int FormFunction (PetscDM da, PetscVec x, PetscVec F, Params *p)
int FormJacobian (PetscDM da, PetscVec x, PetscMat J, Params *p)

def formInitGuess(Vec x, DA da, double lambda_):
cdef int ierr
cdef Params p = {"lambda_" : lambda_}
ierr = FormInitGuess(da.dm, x.vec, &p)
if ierr != 0: raise Error(ierr)

def formFunction(SNES snes, Vec x, Vec f, DA da, double lambda_):
cdef int ierr
cdef Params p = {"lambda_" : lambda_}
ierr = FormFunction(da.dm, x.vec, f.vec, &p)
if ierr != 0: raise Error(ierr)

def formJacobian(SNES snes, Vec x, Mat J, Mat P, DA da, double lambda_):
cdef int ierr
cdef Params p = {"lambda_" : lambda_}
ierr = FormJacobian(da.dm, x.vec, P.mat, &p)
if ierr != 0: raise Error(ierr)
if J != P: J.assemble() # for matrix-free operator
return Mat.Structure.SAME_NONZERO_PATTERN
Loading