<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Tutorial on The Carpentries</title><link>https://deploy-preview-705--carpentries-website.netlify.app/blog/tag/tutorial/</link><description>Recent content in Tutorial on The Carpentries</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Wed, 20 Nov 2024 10:51:28 -0500</lastBuildDate><atom:link href="https://deploy-preview-705--carpentries-website.netlify.app/blog/tag/tutorial/index.xml" rel="self" type="application/rss+xml"/><item><title>Counting to Five (or, A Plan for Online Tutorials and What's Wrong With It)</title><link>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/10/counting-to-five-or-a-plan-for-online-tutorials-and-whats-wrong-with-it/</link><pubDate>Fri, 26 Oct 2012 00:00:00 +0000</pubDate><guid>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/10/counting-to-five-or-a-plan-for-online-tutorials-and-whats-wrong-with-it/</guid><description>&lt;p>&lt;b>This post originally appeared on the &lt;a href="https://software-carpentry.org/">Software Carpentry website.&lt;/a>&lt;/b>&lt;/p>

&lt;p>My daughter is five and a half years old, and some time in the last couple of weeks, she made a small cognitive breakthrough. It used to be that if I asked her, "What's five plus three?", she would carefully count five fingers, then count three, then go back and count them all together to get eight. She doesn't do that any more; instead, she holds up five fingers, then counts, "Six... seven... eight!" to get the answer. It may sound like a small thing, but it's not: the idea that five is always five, even if you didn't count it this time around, is such a big one that we forget it ever had to be learned.&lt;/p></description></item><item><title>Handling Variant Configuration Files</title><link>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/06/handling-variant-configuration-files/</link><pubDate>Tue, 26 Jun 2012 00:00:00 +0000</pubDate><guid>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/06/handling-variant-configuration-files/</guid><description>&lt;p>&lt;b>This post originally appeared on the &lt;a href="https://software-carpentry.org/">Software Carpentry website.&lt;/a>&lt;/b>&lt;/p>
&lt;p>One of our learners came to us with a problem last week. The program she uses depends on some complex configuration files, which she'd like to store in version control. However, a couple of parameters change depending on the machine the program is running on. She doesn't want to check &lt;em>those&lt;/em> changes into version control over and over again; what should she do?&lt;/p></description></item><item><title>This Week's Tutorials</title><link>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/06/this-weeks-tutorials/</link><pubDate>Fri, 15 Jun 2012 00:00:00 +0000</pubDate><guid>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/06/this-weeks-tutorials/</guid><description>&lt;p>&lt;b>This post originally appeared on the &lt;a href="https://software-carpentry.org/">Software Carpentry website.&lt;/a>&lt;/b>&lt;/p>
&lt;p>We ran five and a half online tutorials this week: one each for the workshop participants from UCL, Newcastle, UBC, and Edmonton, one for students combined from five previous workshops, and a make-up mini-tutorial for students from Plymouth who'd had A/V problems. The topics included:&lt;/p>
&lt;ul>
&lt;li>creating simple HTML pages (both by hand and programmatically)&lt;/li>
&lt;li>Python dictionaries (a.k.a. "hashes" or "maps" in other languages)&lt;/li>
&lt;li>the Pandas statistical package&lt;/li>
&lt;/ul>
&lt;p>People who would like to review should look at the first half of the Version 3 notes on HTML (slides 1-17), the Version 4 videos on sets and dictionaries, and&amp;mdash;well, we don't have anything on Pandas yet, but its creator has &lt;a href="http://shop.oreilly.com/product/0636920023784.do">a book that you can preview&lt;/a>.&lt;/p></description></item><item><title>Tutorial: NumPy, SciPy, and matplotlib</title><link>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/06/tutorial-numpy-scipy-and-matplotlib/</link><pubDate>Thu, 07 Jun 2012 00:00:00 +0000</pubDate><guid>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/06/tutorial-numpy-scipy-and-matplotlib/</guid><description>&lt;p>&lt;b>This post originally appeared on the &lt;a href="https://software-carpentry.org/">Software Carpentry website.&lt;/a>&lt;/b>&lt;/p>
&lt;p>Today I did a toy data analysis of &lt;a href="https://raw.github.com/gist/2891223/06c4a9709d38625134fa5df0ffa00926c69fd175/temperatures.txt">some annual temperature data&lt;/a> in Australia and Canada over the last ~100 years. The goal of the exercise was to demonstrate loading data, inspecting it, and fitting trends. My &lt;a href="{{site.baseurl}}/blog/2012/06/introduction-to-numpy-tutorial.html">last tutorial&lt;/a> didn't involve any real data so this week we wanted to change that.&lt;/p>
&lt;p>Like my previous tutorial I used the &lt;a href="http://ipython.org">IPython&lt;/a> HTML notebook to present. I hadn't been planning to use pylab mode or inline plots but some issues with my matplotlib forced me in that direction. There's an awkward situation here because I actually recommend people not use the pylab interface to matplotlib because the behind-the-scenes magic can cause problems (difficult to debug problems), but for doing demos the inline plots are really the way to go. The obvious upside is that the plots I made as part of the tutorial are embedded in the notebook for you to see now.&lt;/p></description></item><item><title>Git tutorial links</title><link>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/06/git-tutorial-links/</link><pubDate>Sun, 03 Jun 2012 00:00:00 +0000</pubDate><guid>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/06/git-tutorial-links/</guid><description>&lt;p>&lt;b>This post originally appeared on the &lt;a href="https://software-carpentry.org/">Software Carpentry website.&lt;/a>&lt;/b>&lt;/p>
&lt;p>I promised to post some links related to the Git tutorial I taught on May 24, 2012. Most of my material was based on this excellent online book (free): &lt;a href="http://git-scm.com/book/ch1-3.html">http://git-scm.com/book/ch1-3.html&lt;/a>. Here's another resource with help on specific and common Git commands: &lt;a href="http://gitref.org/">http://gitref.org/&lt;/a>.&lt;/p>
&lt;p>Someone asked the differences between Git and Mercurial, but because I haven't used Mercurial I wasn't able to answer. I found these links that I hope are useful: &lt;a href="http://www.wikivs.com/wiki/Git_vs_Mercurial">http://www.wikivs.com/wiki/Git_vs_Mercurial&lt;/a> and &lt;a href="http://www.rockstarprogrammer.org/post/2008/apr/06/differences-between-mercurial-and-git/">http://www.rockstarprogrammer.org/post/2008/apr/06/differences-between-mercurial-and-git/&lt;/a>. Also, here's a video of Linus Torvalds himself (creator of the Linux kernel and Git) promoting Git (and putting down everything that is not Git):&lt;/p></description></item><item><title>Introduction to NumPy Tutorial</title><link>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/06/introduction-to-numpy-tutorial/</link><pubDate>Fri, 01 Jun 2012 00:00:00 +0000</pubDate><guid>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/06/introduction-to-numpy-tutorial/</guid><description>&lt;p>&lt;b>This post originally appeared on the &lt;a href="https://software-carpentry.org/">Software Carpentry website.&lt;/a>&lt;/b>&lt;/p>
&lt;p>Today I did a tutorial moving quickly through the basic usage of &lt;a href="http://docs.scipy.org/doc/numpy/reference/">NumPy&lt;/a>, the essential library for doing numeric computing with Python. We covered &lt;a href="http://docs.scipy.org/doc/numpy/reference/routines.array-creation.html">building arrays&lt;/a>; &lt;a href="http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html">indexing&lt;/a>; array math; NumPy's&lt;a href="http://docs.scipy.org/doc/numpy/reference/ufuncs.html#available-ufuncs"> element-wise functions&lt;/a>; array &lt;a href="http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html#array-attributes">attributes&lt;/a> and &lt;a href="http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html#array-methods">methods&lt;/a>; &lt;a href="http://docs.scipy.org/doc/numpy/reference/routines.random.html">random numbers&lt;/a>; &lt;a href="http://docs.scipy.org/doc/numpy/reference/maskedarray.html">masked arrays&lt;/a>; and &lt;a href="http://docs.scipy.org/doc/numpy/reference/routines.testing.html">array comparison&lt;/a>.&lt;/p>
&lt;p>I presented using the &lt;a href="http://ipython.org">IPython&lt;/a> &lt;a href="http://ipython.org/ipython-doc/dev/interactive/htmlnotebook.html">HTML Notebook&lt;/a>. I enjoyed it because I never had to switch between a terminal and text editor, but I wonder what the people viewing thought. A nice feature of the notebook is that I can export it, both as a PDF and in the .ipynb format importable by IPython. The PDF is &lt;a href="{{ site.filesurl }}/2012/06/NumpyLesson.pdf">here&lt;/a>, and the .ipynb file &lt;a href="https://raw.github.com/gist/2847673/2973541fd2d1209f511efbdda81c3dc6c7d7b7c9/NumpyLesson.ipynb">here&lt;/a>.&lt;/p></description></item><item><title>Dictionaries are a Scientist's Friend</title><link>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/05/dictionaries-are-a-scientists-friend/</link><pubDate>Thu, 31 May 2012 00:00:00 +0000</pubDate><guid>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/05/dictionaries-are-a-scientists-friend/</guid><description>&lt;p>&lt;b>This post originally appeared on the &lt;a href="https://software-carpentry.org/">Software Carpentry website.&lt;/a>&lt;/b>&lt;/p>
&lt;p>[Code]&lt;/p>
&lt;p>Today I would like to share with other scientists the power of &lt;a href="http://docs.python.org/tutorial/datastructures.html#dictionaries">dictionaries&lt;/a>. I recently learned about this data structure during a Software Carpentry bootcamp that Greg Wilson and &lt;a href="http://whitelab.weecology.org/">Ethan White&lt;/a> organized. Greg and Jason Pell (from Michigan State) visited Utah State University for a two day bootcamp where &lt;a href="http://mcglinn.web.unc.edu/">I am a postdoc studying&lt;/a> patterns of biodiversity. During that time we covered a whole slew of topics, but today I wanted to demonstrate how dictionaries helped to significantly speed up my Python code.&lt;/p></description></item><item><title>An Exercise With Matplotlib and Numpy</title><link>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/05/an-exercise-with-matplotlib-and-numpy/</link><pubDate>Mon, 21 May 2012 00:00:00 +0000</pubDate><guid>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/05/an-exercise-with-matplotlib-and-numpy/</guid><description>&lt;p>&lt;b>This post originally appeared on the &lt;a href="https://software-carpentry.org/">Software Carpentry website.&lt;/a>&lt;/b>&lt;/p>
&lt;p>For this tutorial, we'll be plotting some weather data from a site call &lt;a href="http://www.wunderground.com/">Weather Underground&lt;/a>. You can download temperature readings and weather events for your local area in a comma-separated file.&lt;/p>
&lt;p>I've put weather data for Bloomington, IN in a file called &lt;tt>weather.csv&lt;/tt>. Each row is one day, and there are columns for min/mean/max temperature, dew point, wind speed, etc. We'll be plotting temperature and weather event data (e.g., rain, snow).&lt;/p></description></item><item><title>Solution to Indented List Problem</title><link>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/05/solution-to-indented-list-problem/</link><pubDate>Mon, 14 May 2012 00:00:00 +0000</pubDate><guid>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/05/solution-to-indented-list-problem/</guid><description>&lt;p>&lt;b>This post originally appeared on the &lt;a href="https://software-carpentry.org/">Software Carpentry website.&lt;/a>&lt;/b>&lt;/p>
&lt;p>Last week's homework was to convert a two-level bullet-point list like this:&lt;/p>
&lt;pre>* A
* B
 * 1
 * 2
* C
 * 3&lt;/pre>
&lt;p>into an HTML list like this:&lt;/p>
&lt;pre>&amp;lt;ul&amp;gt;
 &amp;lt;li&amp;gt;A&amp;lt;/li&amp;gt;
 &amp;lt;li&amp;gt;B
 &amp;lt;ul&amp;gt;
 &amp;lt;li&amp;gt;1&amp;lt;/li&amp;gt;
 &amp;lt;li&amp;gt;2&amp;lt;/li&amp;gt;
 &amp;lt;/ul&amp;gt;
 &amp;lt;/li&amp;gt;
 &amp;lt;li&amp;gt;C
 &amp;lt;ul&amp;gt;
 &amp;lt;li&amp;gt;3&amp;lt;/li&amp;gt;
 &amp;lt;/ul&amp;gt;
 &amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;&lt;/pre>
&lt;pre>so it would display like this:&lt;/pre>
&lt;ul>
&lt;li>A&lt;/li>
&lt;li>B
&lt;ul>
&lt;li>1&lt;/li>
&lt;li>2&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>C
&lt;ul>
&lt;li>3&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;p>My solution is shown in the video below; the code follows.&lt;/p></description></item><item><title>Solution to Sets and Dictionaries Exercise</title><link>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/04/solution-to-sets-and-dictionaries-exercise/</link><pubDate>Thu, 26 Apr 2012 00:00:00 +0000</pubDate><guid>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/04/solution-to-sets-and-dictionaries-exercise/</guid><description>&lt;p>&lt;b>This post originally appeared on the &lt;a href="https://software-carpentry.org/">Software Carpentry website.&lt;/a>&lt;/b>&lt;/p>
&lt;p>Last week, I posted an exercise on &lt;a href="{{site.baseurl}}/blog/2012/04/an-exercise-with-sets-and-dictionaries.html">working with sets and dictionaries&lt;/a> that also included a fair bit of file I/O and string manipulation. My solution is below, in four parts, along with the code produced in each. If someone would like to re-do the file parsing using regular expressions, I'd be happy to post that as well.&lt;/p>

&lt;pre>import sys

#--------------------

def parse_pair(pair):
 '''
 Parse an atom-count pair. If the count is missing, assume
 that the count value is 1.
 '''
 if '*' not in pair:
 return pair, 1
 atom, count = pair.split('*')
 count = int(count)
 return atom, count

#--------------------

def parse_molecule(text):
 '''
 Get a single molecule description from a text string.
 '''
 name, formula_text = text.split(':')
 name = name.strip()
 pairs = formula_text.strip().split('.')
 formula = {}
 for p in pairs:
 atom, count = parse_pair(p)
 assert atom not in formula, \
 'Already seen atom %s in text %s' % (atom, text)
 formula[atom] = count
 return name, formula

#--------------------

def read_molecules(reader):
 '''
 Read molecules from a molecule file, returning a dictionary
 of {name : formula} pairs.
 '''
 result = {}
 for line in reader:
 line = line.strip()
 if (not line) or line.startswith('#'):
 continue
 name, formula = parse_molecule(line)
 assert name not in result, \
 'Already seen %s!' % name
 result[name] = formula
 return result

#--------------------

print read_molecules(sys.stdin)&lt;/pre>
&lt;p>&lt;strong>Part 2&lt;/strong>&lt;/p></description></item><item><title>An Exercise With Sets and Dictionaries</title><link>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/04/an-exercise-with-sets-and-dictionaries/</link><pubDate>Fri, 20 Apr 2012 00:00:00 +0000</pubDate><guid>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/04/an-exercise-with-sets-and-dictionaries/</guid><description>&lt;p>&lt;b>This post originally appeared on the &lt;a href="https://software-carpentry.org/">Software Carpentry website.&lt;/a>&lt;/b>&lt;/p>
&lt;p>You are working for a nanotechnology company that prides itself on manufacturing some of the finest molecules in the world. Your job is to rewrite parts of their ordering system, which keeps track of what molecules they can actually make. Before trying this exercise, please review:&lt;/p>
&lt;ol>
&lt;li>Introduction&lt;/li>
&lt;li>Storage&lt;/a> &lt;/li>
&lt;li>Dictionaries&lt;/li>
&lt;li>Examples&lt;/li>
&lt;li>Nanotech Example&lt;/li>
&lt;/ol>
&lt;p>Submit your work by mailing Greg:&lt;/p>
&lt;ol>
&lt;li>your final program,&lt;/li>
&lt;li>the input file(s) you used to test it, and&lt;/li>
&lt;li>a shell script that runs all of your tests.&lt;/li>
&lt;/ol>
&lt;p>&lt;strong>&lt;span id="more-4756">&lt;/span>1. Reading&lt;/strong>&lt;/p></description></item><item><title>Data Munging with Regular Expressions</title><link>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/04/data-munging-with-regular-expressions/</link><pubDate>Sun, 15 Apr 2012 00:00:00 +0000</pubDate><guid>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/04/data-munging-with-regular-expressions/</guid><description>&lt;p>&lt;b>This post originally appeared on the &lt;a href="https://software-carpentry.org/">Software Carpentry website.&lt;/a>&lt;/b>&lt;/p>
&lt;p>Indiana U's Mike Hansen has written a &lt;a href="http://synesthesiam.com/?p=81">blog post&lt;/a> explaining how he used regular expressions to rename and fix some MATLAB files. Even if you don't use MATLAB, you should find lots of useful stuff in it. Thanks, Mike.&lt;/p></description></item><item><title>Solution to Data Merging with Dictionaries</title><link>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/04/solution-to-data-merging-with-dictionaries/</link><pubDate>Thu, 12 Apr 2012 00:00:00 +0000</pubDate><guid>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/04/solution-to-data-merging-with-dictionaries/</guid><description>&lt;p>&lt;b>This post originally appeared on the &lt;a href="https://software-carpentry.org/">Software Carpentry website.&lt;/a>&lt;/b>&lt;/p>
&lt;p>This week's tutorial problem was to merge the data from a set of input files to show how often different species were observed on different dates. The shell pipeline, Python code, and two sample input files follow the video.&lt;/p>

{% assign video_title="Data Merging with Dictionaries" %}
{% assign video_slug="S-dqlYWs4S0" %}
{% assign video_time="00:09:18" %}
{% include youtube %}

&lt;p>&lt;strong>shell command&lt;/strong>&lt;/p>
&lt;pre>grep -h -v '#' *.txt | sort | uniq -c&lt;/pre>
&lt;p>&lt;strong>merge.py&lt;/strong>&lt;/p></description></item><item><title>Solution to Data Checking Problem</title><link>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/04/solution-to-data-checking-problem/</link><pubDate>Wed, 04 Apr 2012 00:00:00 +0000</pubDate><guid>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/04/solution-to-data-checking-problem/</guid><description>&lt;p>&lt;b>This post originally appeared on the &lt;a href="https://software-carpentry.org/">Software Carpentry website.&lt;/a>&lt;/b>&lt;/p>
&lt;p>I finally had a chance this morning to record my solution to the final exercise I set the learners from the Space Telescope Science Institute. It demonstrates how to build a little program in Python that checks the consistency of some experimental data; along the way, it uses file I/O, functions, assert statements, lists of lists, and on-the-fly unpacking. As always, feedback on the content and format would be greatly appreciated. (And if anyone would like to post their own solution, either as plain code or as a video, please let me know so that I can include it here.)&lt;/p></description></item><item><title>Solution to the First Image Processing Homework</title><link>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/04/solution-to-the-first-image-processing-homework/</link><pubDate>Tue, 03 Apr 2012 00:00:00 +0000</pubDate><guid>https://deploy-preview-705--carpentries-website.netlify.app/blog/2012/04/solution-to-the-first-image-processing-homework/</guid><description>&lt;p>&lt;b>This post originally appeared on the &lt;a href="https://software-carpentry.org/">Software Carpentry website.&lt;/a>&lt;/b>&lt;/p>
&lt;p>We had technical issues during yesterday's online tutorial (again), so I have recorded the solution to the image processing exercise we gave the students in Indiana and Toronto. I'd be very grateful for feedback (not just from students): is this a useful way to present ideas? Or should we put our effort into debugging [name of web conferencing software goes here]?&lt;/p>

{% assign video_title="Solution to First Image Processing Homework" %}
{% assign video_slug="zwl1W4PjaMI" %}
{% assign video_time="00:16:25" %}
{% include youtube %}

&lt;p>My final code is:&lt;/p></description></item></channel></rss>