summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPuneeth Chaganti2010-09-23 12:15:27 +0530
committerPuneeth Chaganti2010-09-23 12:15:27 +0530
commite87701e90870293f32c71899482855fc4dba646f (patch)
tree25473101c18dcf5aa9d8be8d8295f5171e1cb93a
parent10cd38559c9791b58da4fca2f668fb94026e4db6 (diff)
parent5d18b5da68dbc831a9de2c8b8a13cecbc1f74e1d (diff)
downloadst-scripts-e87701e90870293f32c71899482855fc4dba646f.tar.gz
st-scripts-e87701e90870293f32c71899482855fc4dba646f.tar.bz2
st-scripts-e87701e90870293f32c71899482855fc4dba646f.zip
Merged heads.
-rw-r--r--embellishing_a_plot.rst22
-rw-r--r--getting_started_with_for.rst71
-rw-r--r--loading-data-from-files.rst30
-rw-r--r--progress.org6
-rw-r--r--symbolics.rst15
5 files changed, 113 insertions, 31 deletions
diff --git a/embellishing_a_plot.rst b/embellishing_a_plot.rst
index 3c22ef9..acb601f 100644
--- a/embellishing_a_plot.rst
+++ b/embellishing_a_plot.rst
@@ -17,7 +17,8 @@ Let us start ipython with pylab loaded, by typing on the terminal
ipython -pylab
-#[madhu: I feel the instructions should precede the actual action,
+.. #[madhu: I feel the instructions should precede the actual action,
+
since while recording we need to know before hand what we need to do]
We shall first make a simple plot and start decorating it.
@@ -55,7 +56,7 @@ As we can see we have the same plot but now in red colour.
.. #[Madhu: diff again]
-To alter the thickness of the line, we use the =linewidth= argument in the plot
+To alter the thickness of the line, we use the ``linewidth`` argument in the plot
command. Hence
::
@@ -90,7 +91,7 @@ A combination of colour and linewidth would do the job for us. Hence
produces the required plot
-#[Nishanth]: I could not think of a SIMPLE recipe approach for
+.. #[Nishanth]: I could not think of a SIMPLE recipe approach for
introducing linestyle. Hence the naive approach.
.. #[[Anoop: I guess the recipe is fine, but would be better if you
@@ -167,7 +168,7 @@ the figure does not have any description describing the plot.
.. #[Madhu: Added "not". See the diff]
-We will now add a title to the plot by using the =title= command.
+We will now add a title to the plot by using the ``title`` command.
::
title("Parabolic function -x^2+4x-5")
@@ -175,7 +176,7 @@ We will now add a title to the plot by using the =title= command.
{{{ Show the plot window and point to the title }}}
The figure now has a title which describes what the plot is. The
-=title= command as you can see, takes a string as an argument and sets
+``title`` command as you can see, takes a string as an argument and sets
the title accordingly.
.. #[Madhu: See the diff]
@@ -194,7 +195,7 @@ for instance, we can use
and we get the polynomial formatted properly.
-#[Nishanth]: Unsure if I have to give this exercise since enclosing the whole
+.. #[Nishanth]: Unsure if I have to give this exercise since enclosing the whole
string in LaTex style is not good
.. #[[Anoop: I guess you can go ahead with the LaTex thing, it's
@@ -224,8 +225,8 @@ and y axes. Hence we shall label x-axis to "x" and y-axis to "f(x)" ::
{{{ Switch to plot window and show the xlabel }}}
-As you can see, =xlabel= command takes a string as an argument,
-similar to the =title= command and sets it as the label to x-axis.
+As you can see, ``xlabel`` command takes a string as an argument,
+similar to the ``title`` command and sets it as the label to x-axis.
.. #[See the diff]
@@ -264,7 +265,7 @@ like to name the point accordingly. We can do this by using
{{{ Show the annotation that has appeared on the plot }}}
-As you can see, the first argument to =annotate= command is the name we would
+As you can see, the first argument to ``annotate`` command is the name we would
like to mark the point as and the second argument is the co-ordinates of the
point at which the name should appear. It is a sequence containing two numbers.
The first is x co-ordinate and second is y co-ordinate.
@@ -295,7 +296,8 @@ we have looked at
{{{ Show the "sponsored by FOSSEE" slide }}}
-#[Nishanth]: Will add this line after all of us fix on one.
+.. #[Nishanth]: Will add this line after all of us fix on one.
+
This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India
Hope you have enjoyed and found it useful.
diff --git a/getting_started_with_for.rst b/getting_started_with_for.rst
index f832319..bfa2ef2 100644
--- a/getting_started_with_for.rst
+++ b/getting_started_with_for.rst
@@ -21,6 +21,9 @@ Hello and welcome to the tutorial getting started with ``for`` loop.
In this tutorial we will see ``for`` loops in python, and also cover
the basics of indenting code in python.
+.. #[Nishanth]: Instead of saying basics of indenting code,
+ say How to define code blocks in Python
+
{{{ switch to next slide, about whitespaces }}}
In Python whitespace is significant, and the blocks are visually
@@ -30,21 +33,39 @@ stick on to one way of writing or beautifying the code rather than
debating over where to place the braces. This way it produces uniform
code than obscure or unreadable code.
+.. #[nishanth]: Simply tell how blocks are defined in python.
+ The details like braces are not used and its
+ advantages like neat code can be told after completely
+ explaining the indentation
+
A block may be defined by a suitable indentation level which can be
either be a tab or few spaces. And the best practice is to indent the
code using four spaces.
+.. #[Nishanth]: Even this detail may be skipped. Simply say use 4 spaces
+ for indentation. Do that while typing so that they can
+ actually see what is being typed.
+
Now let us move straight into ``for`` loop.
-{{{ switch to next slide, problem statement of exercise 1 }}}
+{{{ switch to next slide, problem statement of exercise 1 }}}
Write a for loop which iterates through a list of numbers and find the
square root of each number. Also make a new list with the square roots
and print it at the end.
+
+.. #[nishanth]: making new list with square roots induces extra complication
+ like appending which has no use case here
::
numbers are 1369, 7225, 3364, 7056, 5625, 729, 7056, 576, 2916
+.. #[Nishanth]: The problem focuses more on square root and creation
+ of list. The problem must be simple and focusing on
+ nothing more but the indentation and for loop.
+ May be change the problem to print squares than to
+ print square roots.
+
For the problem, first we need to create a ``list`` of numbers and
then iterate over the list and find the square root of each element in
it. And let us create a script, rather than typing it out in the
@@ -63,6 +84,14 @@ following.
print
print square_roots
+.. numbers = [1, 12, 3, 4, 21, 17]
+ for each in numbers:
+ print each, each * each
+
+.. #[nishanth]: I don't see a use case to append the sq_root to
+ square_roots. It is only complicating stuff.
+ Simply iterate and print.
+
{{{ save the script }}}
Now save the script, and run it from your IPython interpreter. I
@@ -74,6 +103,8 @@ Run the script as,
%run -i list_roots.py
+.. #[Nishanth]: you don't have to use the -i option here
+
{{{ run the script }}}
So that was easy! We didn't have to find the length of the string nor
@@ -85,12 +116,22 @@ element of list under consideration in each cycle of the ``for`` loop,
and then a variable ``sq_root`` for storing the square root in each
cycle of the ``for`` loop. The variable names can be chosen by you.
+.. #[Nishanth]: The details like we didn't have to find the length
+ are relevant for people who have programmed in C or
+ other languages earlier. But for a newbie it is more
+ of confusing extra info. That part may be skipped.
+ Simply go ahead and focus on the syntax of for loop.
+ And how the variable name is used inside the for loop.
+ If you modify the question to only print, the extra
+ variable sq_root can also be avoided. let it be more
+ about "each", "numbers" and "for". no other new names.
+
{{{ show the script which was created }}}
Note that three lines after ``for`` statement, are indented using four
spaces.
-{{{ highlight the threee lines after for statement }}}
+{{{ highlight the three lines after for statement }}}
It means that those three lines are part of the for loop. And it is
called a block of statements. And the seventh line or the immediate
@@ -132,6 +173,9 @@ after for statement, the prompt changes to four dots and the cursor is
not right after the four dots but there are four spaces from the
dots. The four dots tell you that you are inside a block. Now type the
rest of the ``for`` loop,
+
+.. #[Nishanth]: Tell that IPython does auto indentation.
+
::
sq_root = sqrt(each)
@@ -159,24 +203,37 @@ Start with,
for i in range(1,11):
and press enter once, and we will see that this time it shows four
-dots, but the cursor is close to the dots, so we have to intend the
+dots, but the cursor is close to the dots, so we have to indent the
block. So enter four spaces there and then type the following
::
- print "10 *",i,"=",i*10
+ print "10 x",i,"=",i*10
Now when we hit enter, we still see the four dots, to get out of the
-block type enter once.
+block, hit enter once again
+
+.. #[Nishanth]: Here also the overhead on print can be reduced.
+ Think of a simple print statement. This statement
+ will be confusing for a newbie.
+ We can focus more on indentation in python.
+
+.. #[nishanth]: Not sure if you must use range here. You can
+ define a list of numbers and iterate on it.
+ Then say this list can also be generated using
+ the range function and hence introduce range.
Okay! so the main thing here we learned is how to use Python
interpreter and IPython interpreter to specify blocks. But while we
were generating the multiplication table we used something new,
``range()`` function. ``range()`` is an inbuilt function in Python
which can be used to generate a ``list`` of integers from a starting
-range to an ending range. Note that the ending number that you specify
+number to an ending number. Note that the ending number that you specify
will not be included in the ``list``.
+.. #[Nishanth]: Show some examples of range without the step argument
+ May be give an exercise with negative numbers as arguments
+
Now, let us print all the odd numbers from 1 to 50. Let us do it in
our IPython interpreter for ease of use.
@@ -212,6 +269,6 @@ list and then the ``range()`` function.
Thank you!
.. Author: Anoop Jacob Thomas <anoop@fossee.in>
- Reviewer 1:
+ Reviewer 1: Nishanth
Reviewer 2:
External reviewer:
diff --git a/loading-data-from-files.rst b/loading-data-from-files.rst
index 04d6505..5196619 100644
--- a/loading-data-from-files.rst
+++ b/loading-data-from-files.rst
@@ -12,8 +12,10 @@ plotting them, against another sequence of points. But, this is not
what we do most often. We often require to plot points obtained from
experimental observations.
-#[punch: the initial part of the paragraph may be removed, to make
-this a more generic LO?]
+.. #[punch: the initial part of the paragraph may be removed, to make
+ this a more generic LO?]
+
+.. #[Nishanth]: The paragraph can be removed.
In this tutorial we shall learn to read data from files and save it
into sequences that can later be used to plot.
@@ -24,6 +26,9 @@ We shall use the ``loadtxt`` command to load data from files. We will
be looking at how to get multiple columns of data into multiple
sequences.
+.. #[Nishanth]: can be "How to read a file with multiple columns of
+ data and load each column of data into a sequence."
+
{{{ switch back to the terminal }}}
As usual, let us start IPython, using
@@ -35,7 +40,7 @@ Now, Let us begin with reading the file primes.txt, which contains
just a list of primes listed in a column, using the loadtxt command.
The file, in our case, is present in ``/home/fossee/primes.txt``.
-#[punch: do we need a slide for showing the path?]
+.. #[punch: do we need a slide for showing the path?]
We use the ``cat`` command to see the contents of this file.
@@ -44,6 +49,10 @@ to do it] ::
cat /home/fossee/primes.txt
+.. #[Nishanth]: A problem for windows users.
+ Should we simply open the file and show them the data
+ so that we can be fine with GNU/Linux ;) and windows?
+
Now let us read this list into the variable ``primes``.
::
@@ -71,6 +80,12 @@ This is how we look at the contents of the file, ``pendulum.txt``
cat /home/fossee/pendulum.txt
+.. #[Nishanth]: The first column is L values and second is T values
+ from a simle pelculum experiment.
+ Since you are using the variable names later in the
+ script.
+ Not necessary but can be included also.
+
Let us, now, read the data into the variable ``pend``. Again, it is
assumed that the file is in ``/home/fossee/``
::
@@ -90,12 +105,17 @@ two separate, simple sequences.
L, T = loadtxt('/home/fossee/pendulum.txt', unpack=True)
+.. #[Nishanth]: It has a sequence of items in which each item contains
+ two values. first is l and second is t
+
Let us now, print the variables L and T, to see what they contain.
::
print L
print T
+.. #[Nishanth]: Stress on ``unpack=True`` ??
+
Notice, that L and T now contain the first and second columns of data
from the data file, ``pendulum.txt``, and they are both simple
sequences.
@@ -115,12 +135,14 @@ finished, resume the video to look at the solution.
{{{ switch back to the terminal }}}
::
- L, T = loadtxt('/home/fossee/pendulum.txt', unpack``True, delimiter``';')
+ L, T = loadtxt('/home/fossee/pendulum.txt', unpack=True, delimiter=';')
print L
print T
+.. #[Nishanth]: L, T = loadtxt('/home/fossee/pendulum_semicolon.txt', ...)
+
This brings us to the end of this tutorial.
{{{ show the summary slide }}}
diff --git a/progress.org b/progress.org
index bb62800..4d2574b 100644
--- a/progress.org
+++ b/progress.org
@@ -8,16 +8,16 @@
| 1.7 LO: | additional features of IPython | 2 | Nishanth | Amit (Pending) | Madhu (Pending) |
| 1.8 LO: | module level assessment | 3 | Madhu | | |
|---------+----------------------------------------+-------+----------+---------------------+---------------------|
-| 2.2 LO: | loading data from files | 3 | Punch | | |
+| 2.2 LO: | loading data from files | 3 | Punch | Nishanth (Done) | Anoop (Pending) |
| 2.3 LO: | plotting the data | 3 | Amit | Anoop (Pending) | Punch (Pending) |
| 2.4 LO: | other types of plots | 3 | Anoop | | |
| 2.5 LO: | module level assessment | 3 | Nishanth | | |
|---------+----------------------------------------+-------+----------+---------------------+---------------------|
| 3.1 LO: | getting started with lists | 2 | Amit | Madhu (Pending) | Nishanth (Done) |
-| 3.2 LO: | getting started with =for= | 2 | Anoop | | |
+| 3.2 LO: | getting started with =for= | 2 | Anoop | Nishanth (Done) | Amit (Pending) |
| 3.3 LO: | getting started with strings | 2 | Madhu | | |
| 3.4 LO: | getting started with files | 3 | Punch | | |
-| 3.5 LO: | parsing data | 3 | Nishanth | Amit (Pending) | Punch (Pending) |
+| 3.5 LO: | parsing data | 3 | Nishanth | Amit (Done) | Punch (Pending) |
| 3.6 LO: | statistics | 2 | Amit | Anoop (Pending) | Puneeth (Pending) |
| 3.7 LO: | module level assessment | 3 | Madhu | | |
|---------+----------------------------------------+-------+----------+---------------------+---------------------|
diff --git a/symbolics.rst b/symbolics.rst
index 6ae4314..4edf013 100644
--- a/symbolics.rst
+++ b/symbolics.rst
@@ -7,19 +7,20 @@ by Fossee group.
{{{ Part of Notebook with title }}}
We would be using simple mathematical functions on the sage notebook
-for this tutorial .
+for this tutorial.
During the course of the tutorial we will learn
-
{{{ Part of Notebook with outline }}}
-To define symbolic expressions in sage . Use built-in costants and
-function. Integration , differentiation using sage . Defining
-matrices. Defining Symbolic functions . Simplifying and solving
-symbolic expressions and functions
-
+To define symbolic expressions in sage. Use built-in costants and
+function. Integration, differentiation using sage. Defining
+matrices. Defining Symbolic functions. Simplifying and solving
+symbolic expressions and functions.
+.. #[Nishanth]: The formatting is all messed up
+ First fix the formatting and compile the rst
+ The I shall review
Using sage we can perform mathematical operations on symbols .