This course is now fully booked and has a long waiting list. If you would like to be informed of similar events in the future, please e-mail us on email@example.com.
What: Our goal is to help scientists and engineers become more productive by teaching them basic computing skills like program design, version control, testing, and task automation. In this two-day bootcamp, short tutorials will alternate with hands-on practical exercises. Participants will be encouraged both to help one another, and to apply what they have learned to their own research problems during and between sessions. Attendants are offered online office hours: regular events to get one-on-one help from Software Carpentry instructors, online.
Who: The course is aimed at postgraduate students and other scientists who are familiar with basic programming concepts (like loops, conditionals, arrays, and functions) but need help to translate this knowledge into practical tools to help them work more productively.
Requirements: Participants must bring a laptop with a few specific software packages installed. (The list will be sent to participants a week before the bootcamp.)
Content: The syllabus for this bootcamp will include:
# Count data records in file. # Reads from standard input if no filename given. # Reads from a single file if filename given. # Title and comments don't count. import sys def count_records(reader): number = 0 expected = None for line in reader: if line.startswith('#-'): junk, expected = line.split() expected = int(expected) elif line.startswith('#'): pass elif line.startswith('D'): # FIXME pass else: number = number + 1 return number, expected if len(sys.argv) == 2: filename = sys.argv source = file(filename, 'r') else: source = sys.stdin number, expected = count_records(source) source.close() if expected == None: print 'number of records:', number elif expected == number: print 'pass' else: print 'fail'
def double(x): return 2 * x def add_three(x): return x + 3 def sub_one(x): return x - 1 def do_for_each(func, values): result =  for v in values: temp = func(v) result.append(temp) return result start = [3, 7, 42, 96] doubled = do_for_each(double, start) added = do_for_each(add_three, start) subtracted = do_for_each(sub_one, start) print 'started with', start print 'doubled', doubled print 'incremented', added print 'subtracted', subtracted
-- Get the people who worked on each project. select distinct Project.ProjectName, Involved.Login from Project join Involved where Project.ProjectId = Involved.ProjectId order by Involved.Login;
Get project name, person's last name, experiment ID, and hours worked in one table.
select '# $Revision:$'; select '# db version' || VersionId from DatabaseVersion; select Project.ProjectName, Person.LastName, Experiment.ExperimentId, Experiment.Hours from Person join Project join Experiment join Involved where (Project.ProjectId = Experiment.ProjectId) and (Involved.ProjectId = Project.ProjectId) and (Involved.Login = Person.Login) and (Experiment.ExperimentId = Involved.ExperimentId);
Access from Python
import sqlite3 connection = sqlite3.connect("experiments.db") cursor = connection.cursor() cursor.execute("SELECT FirstName, LastName FROM Person;") results = cursor.fetchall(); for r in results: print r, r cursor.close(); connection.close();
Nose tests for rectangle overlap
from overlap import overlap def test_overlap_on_one_corner(): assert overlap([0, 2, 0, 2], [1, 3, 1, 3]) == [1, 2, 1, 2] def test_no_overlap_at_all(): assert overlap([0, 1, 0, 1], [3, 4, 3, 4]) == None def test_one_inside_another(): assert overlap([0, 10, 0, 10], [2, 3, 2, 3]) == [2, 3, 2, 3] def test_overlap_along_one_edge(): assert overlap([0, 3, 0, 3], [3, 5, 0, 3]) == None def test_inside_on_one_axis(): assert overlap([0, 3, 0, 3], [1, 2, 1, 4]) == [1, 2, 1, 3]