Rick Wagner - Lab Zero
Creating a Branch
Since this is my first time accessing the repository, I'm going to create a folder for my code. I could just create the folder, but instead I'll make a copy of the trunk, so that I get whatever's there.
cable:~/Software rpwagner$ svn copy -m "Creating branch for personal work" \ > svn://mngrid.ucsd.edu/scicomp/trunk svn://mngrid.ucsd.edu/scicomp/branches/rpwagner Committed revision 3. cable:~/Software rpwagner$
The -m puts a message in the repository log, a very useful feature.
Checking Out a Branch
Now, I'll check out my branch, so I can get to work. (I can actually do a check from anywhere in the repository structure.)
cable:~/Software rpwagner$ svn co svn://mngrid.ucsd.edu/scicomp/branches/rpwagner Checked out revision 3. cable:~/Software rpwagner$
Writing a Function
For this, I'm going to make a Python module called fibonacci.py, and write the function in there. Here's the function:
def F(n): if n == 0 or n == 1: return n else: return F(n-1) + F(n-2)
Plotting
First, I'll need to start up the interpreter, and import the modules I need:
cable:~/Software/rpwagner rpwagner$ python Python 2.4.3 (#1, Apr 7 2006, 10:54:33) [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import scipy >>> import pylab as p >>> import fibonacci
Next, I'll generate the first 20 Fibonacci numbers:
>>> x = scipy.arange(0,19) >>> fibs = [] >>> for val in x: ... fibs.append(fibonacci.F(val)) ... >>> fibs = scipy.array(fibs)
And finally, the plot:
>>> p.semilogy(x,fibs) [<matplotlib.lines.Line2D instance at 0x354b7b0>] >>> p.show()
Submitting to the Repository
And now, I get my work into the repository. Since I've made a new file, this is a two step process:
Tell Subversion you want to add the file
cable:~/Software/rpwagner rpwagner$ svn add fibonacci.py A fibonacci.py
And then commit any changes
cable:~/Software/rpwagner rpwagner$ svn commit -m "Fibonacci calculator for Lab Zero" Adding fibonacci.py Transmitting file data . Committed revision 4. cable:~/Software/rpwagner rpwagner$
Fin!

