Blogs

SciPy.in 09 Videos

Videos of keynote by Dr. Travis Oliphant and interviews of various invited guests are now available here. We are yet to get videos of various talks of other participants(processing of videos has delayed things).
There are some problems with videos also, the keynote address and introduction seems to be playing sound only with right speaker. And then in interview videos, the introduction soundtrack for interviews is really sparky. /me says, Alll izzz Well

Gnunify 10

This year we got one workshop on SciPy-Image processing selected for Gnunify. We were waiting for schedule eagerly and when it came out we were totally confused. There were almost 6 parallel tracks. So we reached to Pune at night and after dropping the luggage headed straight to event place to make sure we can get Lab setup properly. There were lots of volunteers running around fixing up things, making sure that "all izz well" for next day.
We had talk scheduled on first day itself that too at 10 AM. All the rest of talks and workshops were staring at 10:30, we were the odd one out, and even that didn't help. It was Friday, a working day so I think many students and professionals might have skipped first day. By 9:50 everything was very relaxed, no hurry no rush, people were turning in slowly and figuring out what sessions they would be attending. But for us it was going to be tough to lure attendees. By 10:10 we had two participants turned up and to make things worse, we had Kushal Das covering basic Python right next door. That talk was to start at 10:30 and students were lined up from half hour before itself. We were thinking of going around advertising the workshop to get more people, or changing workshop to a informal session of hands on, but then suddenly out of no where we got precious interested attendees, decent 20 odd turn up. But still we made the anchor(they introduces speakers to audience) also to participate.
Now the workshop requirement was that participants should have basics understanding of Python, but we got students still griped in evil clutches of TurboC++(Bhagwaan sab ko sadbuddhi de). So we changed the pace and plan of workshop, we covered basics image reading, displaying, numpy arrays, slicing and striding concepts, and then processing image by using filters, dropping information and other fundas. Thankfully we did not notice any one dozing off, they were responding to small exercises, and doing hands on. All in all it went well.
But I think, Gnunify management could have scheduled talks considering kind of audience registrations they had. I think, if this workshop would had been scheduled after introductory workshops and talks we could have got more and better literate participants, hence we could had covered more. Okay would have, could had are always there, lets hope we next time it is better.

Vim as Python IDE

Vim Forever...
It all started when I saw Venkatesh Choppella working without taking his fingers off the keyboard to do many things which usually required shifting my hand between keyboard and my tailed friend, mouse. I knew for sure that he was using emacs. It was cool and I was fascinated about this cute little tool. My friend Puneeth uses it all the time for editing. He also has some crazy extension on firefox that troubles me while using. It is emacs extension.
Anyways now I wanted to use something cool like that. I know for sure that Vi is the competitor and so I started by googling for editor wars. I found many links that support emacs. So I started learning emacs rather looking at emacs. First thing I didnt like was the use of control key so often which required shifting of my fingers way down the home row. Then I had problem shifting my fingers to use the arrow keys for navigating through the file.
So here I am left with no other option than vi. I have used vi for quite a while and am pretty comfortable with it. But all I do in vi is first get into insert mode and edit the file as if I am using notepad. I started searching for tutorials on vi and found one that is so simple yet so amazing. I thank Swaroop CH, yes the same guy who wrote the book "A Byte of Python", for another amazing book "A Byte of Vim". It was so amazing and I started using vi like a novice vimmer.
Now editing a text file is something I do only once in a while. Most of the time I either code in Python or browse on Firefox. Ofcourse watching stuff and listening to music is also there but doesn't make sense in this context. So now what is this emacs plugin for firefox and is there something similar for Vim???. Yes there is one and it is called Vimperator. It transforms firefox into something that behaves similar to Vim editor and hence very seldom do I need the mouse. It is a totally different experience using firefox in Vim mode.
Now comes the most important job. Making Vim an ide for Python.
Let me start by listing a few things one does on a typical ide.

  1. A file browser that stays on left of screen and enables opening files on one click
  2. Ability to show multiple files in one screen
  3. Syntax highlighting and code folding
  4. Taglist that displays all the functions, classes and stuff in one place
  5. Auto Indentation
  6. Code completion
  7. Debugging

Phew!! finally the list ended.Lets start with the first, The File browserVim has a very simple and light file browser plugin called NERDTree.Installing is as simple as extracting the files into ~/.vim directory.Using :NERDTree brings up the nerdtree and a tree structure is displayed.Moving between files is the same as it is in normal mode. The usual hjkl work and <CR> or the enter key is used to expand or collapse a directory. Clicking enter on a file opens the file in edit mode. 'o' key can also be used to do the same. <ctrl+w> <ctrl+w> is used to switch context between nerdtree and the file buffer. 'i' opens the file in a new screen.
Showing multiple files.This is as simple as splitting the screen into parts and showing different files on each screen.:sp splits the screen horizontally and :vsp splits vertically.If you notice, we have seen something similar while using nerdtree. What it is doing is simply opening another buffer for itself.<ctrl+w> <ctrl+w> can be used to switch context. The usual vim way of prepending a number also works here. so 4 <ctrl+w> would execute <ctrl+w> command four times. can also be mixed with hjkl.
syntax highlighting and code foldingvim takes care of syntax and all we have to do is :syntax on. You can also download a syntax file from here or write one of your own and name it python.vim. Installing is as simple as placing it in ~/.vim/syntax folder.code folding is a little different for different contexts. For python, the obvious is indentation. First do :foldmethod=indent. Then scroll to your block of code and za toggles the folding of code.
taglist is a plugin for vim that supports many languages. It requires a package called "exuberate ctags" which should be directly available on repo for any distro. Then download the zip file and extract contents to ~/.vim and you have your plugin.The visibility of taglist can be toggled using :TlistToggle and it works similar to nerdtree.
Autoindentationfollowing pep8, here are a few settings that should make your life easy.

  • set expandtab
  • set textwidth=79
  • set tabstop=8
  • set softtabstop=4
  • set shiftwidth=4
  • set autoindent

at this point you will notice that you have to type the 4 spaces or tab for the first time and then the code is auto indented from the next line.Wouldn't it be great if we didn't have to bother about even touching the tab key and the editor does that depending on the context. All that is just one step away. Download this script and place it in ~/.vim/indent folder. Now use the command ":filetype plugin indent on" or add the line "filetype plugin indent on" to your .vimrc file in home folder and there you go. Vim does all your indenting.
If you would have noticed, we have to type in all these conf settings every time we start vim. We don't want vi to do these settings for all the files either. What if we could set things only for files that end in .py. There is a very simple way of accomplishing that. Change the "set" to "setlocal" and put all your settings in a python.vim file and place it in ~/.vim/ftplugin.So your python.vim would look like this:

setlocal expandtab
setlocal textwidth=79
setlocal tabstop=8
setlocal softtabstop=4
setlocal shiftwidth=4
setlocal autoindent

Your ~/.vimrc file would like

" a comment
" display line numbers
set nu
" do indenting and stuff based on filetype
filetype plugin on

Fun and Pain with Django

Phew, yesterday, rather today was a crazy night. I was trying to put up a django application for registrations of various users. Start was good and quickly within two days I got a decent application with captcha and other required fields. I uploaded it, and without much pain I got registration page up yAy.
We always have a local Point Of Contact from college where we are organizing the workshop. Now it will be nice feature if we can allow him/her also to view the registrations. And even better would be, he/she is limited to all the registrations they are in charge of, not of all the registrations. So again django views are simply great and I wrote simple view to limit user to particular list only. Nishanth is also learning django for his PyTasks so I thought it would be good idea to work together for some while to enable this view. He will get idea of how things work and I can get help from his learnings. He came up with this awesome one-liner to read a file, line by line, split it on particular delimiter and then create dictionary out of two fields

dictionary = dict([line.strip().split('|') for line in open('filename')])

Okay so everything working as expected, we tried to run the code locally and it was smooth and impressive(heh some time self-appreciation is good :P).
Now we pushed the code to the server, made sure everything was okay and in place, reloaded the apache and refreshed the page and BOOM gone. The normal registration itself vanished and we were getting error message of django not able to load views.py function from the app. It was bad, and people are still using it for registrations. It was already 1 am, we thought it would be over by 1:05, we will have some snacks and a good night sleep. But this BOOM really scared me. So we sshed into server, tried using django shell, loaded views and it was working fine. Nishanth tried extensive googling to search for some solution and came across a thread which mentioned about some problem with django, wsgi and reloading of views when something is changed. He said lets restart apache which I ignored for a while. We kept on trying making some changes and hoping that this time it will work. We were about to revert back to previous working version of site repo(Yeah hg always helps in such grave situations) when Nishanth said, "lets try restarting apache". We did that and yAy we got the app up again and running. Although it was not fault of django directly, but still I will give it also some credits. Phew by that time it was already 2:30 in night and we were like, dude we should hurry up, H-8 canteen is about to close and we wont get anything to eat if we are late.

Scipy.in Talks

The first version of Indian Scipy Conference was inaugurated on 12th December by Dr. Prabhu Ramachandran , Dr. Travis Oliphant (President, Enthought) , Mr. R Narayan (Vice President TCS Learning and Development), Prof. Elizabeth Sherly and Mr. Jarrod Millman in Technopark, Trivandrum . The Conference was organized by FOSSEE, Space-Kerala and SIG-FOSS. The aim of the conference was to create awareness and spread the use of Python in the Indian Scientific community . Also it tried to get the developers from India and abroad to tell about how they were using Scipy and Python for their research needs . They also brainstormed and sprinted on improving scipy documentation and code .

Mr. R. Narayan, former Vice-President TCS(Learning and development) started the conference by talking about object-oriented programming language paradigm and how high level languages like Python have made programming more accessible to people from different backgrounds. Then Prof. Elizabeth Sherly talked about importance of FOSS in Education.

Dr. Travis Oliphant of Enthought and one of the chief architects of Numpy kicked off the talks about how he started using Python for his research needs in the year 1998 . He traced the development of Numpy starting from Jim Hugunin's work on numeric . He also talked how open source development works and multiple people from different geographical locations collaborated to create Numpy by contributing small projects they were developing. He also showed that how Scipy and his company Enthought was working in diverse fields like embedded systems to Oil industry and food industry.

Prof. Kannan Moudgalya talked about his work with spoken tutorials at IIT Bombay. He shared his vision of freeing computer education through FOSS tools and spoken tutorials delivered in all the regional languages. Spoken tutorials could be used to bridge the digital divide. After that Chandrashekhar Kaushik talked about his Python based SPH framework and how it can be used to do simulations of particle interactions.

The second days talks were started by Christopher Burns from University of California, Berkley. He talked about NiPY, an open source neuro imaging tool developed in Python. NiPY project is an environment for the analysis of structural and functional neuro imaging data. He believed that Scipy and Python can function as great tools for scientific computing and hoped that more scientists and engineers will start using Python . David Cournapeau, the maintainer of Numpy project talked about the progress made in building numpy on different distributions and the feature set that will be added in the next few versions . He also introduced people to toydist a build system he was writing which tried to rectify the problems in building code using setuptools and distutils .The Chaco talk by Dr. Travis Oliphant on the second day got a lot of interest among people because of its ability to create very useful and interactive plots. He showed the power of Chaco by plotting the frequency of his voice using Chaco. Farhat Habib of IISER talked about using Python in Data Mining and Data Visualization especially in relation to gene regulation. Dr. Prabhu Ramachandran introduced people to Mayavi, a 3D visualization tool written by him. He also introduced Sage , an open source mathematical software. He showed Sage notebook's features like solving symbolic expressions and creating plots within the notebook. He also told people about the upcoming Sage days 25, India in August. In the end he thanked all the speakers, organizers and participants for making Scipy India successful.

TCE FOSS work culture: way to go

We attended a Faculty Development Program(FDP) held at Thiagarajar College of Engineering. It covered various FOSS topics for one of the elective subjects. During our stay we met the HOD of Computer Science Department Dr.S.Mercy Shalinie. She is a great teacher, she told us (Puneeth and me) about their various activities related to campus wide network management, website development and computing related infrastructure, which were very apt for creating active student community.

She asked her students to show us the features of tcenet and other initiatives for student participation and development. First of all, they declined to take services from their hardware (servers, routers etc.) providers, so that students can setup things on their own and get a chance to work on live projects. Faculty members also play a very minimal role in these activities. Students are given the freedom to try, test and fix. Then they told us about their hierarchy and work-flow. Their website, intranet, and mailing lists, are all managed by students (passed-out and present). They have an svn repository for all these projects. A few fourth year students have the commit rights and some alumni who were involved previously have commit rights from outside the campus. They have a trac based system for project management, and active mailing lists for discussions related to all these projects. Students from second year are encouraged to participate, initially they are required to submit patches for fixing bugs, and then just like all other open source projects they also have to prove themselves to get commit rights (AMAZING).

Not only that, they also provide an svn repository for all the final year students for their Major projects, even for non CS/IT students. For beginners, they had a poster system with sticky notes to paste the tickets and tasks so that they can get hang of version control systems and trac. All students, current and passed out, are provided shell access (feature which I find really essential and handy to try out some things which are not possible cause of work restrictions). Continuation of a previously done major project by new final year students is encouraged, so that code keeps on building and improving, which makes sense to me. Student sitting around in the lab, during the hands-on sessions were all into Python and Emacs whose limitless powers were unknown to me until recently.

To add to this, Shalinie madam was visibly taking pride in the achievements of her students when she was mentioning all this. She never forgot to mention that all this was new even for her and she hung around with her students to learn all of this. For each tech-fest and event, they try to invite passed out students to interact with current students and work together to fix issues, which is really ideal thing to create efficient learning atmosphere.

All this perfectly fits a Chinese proverb used in kurose-ross computer network book which goes like this:
Tell me and I'll forget; show me and I may remember; involve me and I'll understand.

Py in the Sci

Hello,
I must first warn you that this is a long post!
In the midst of a slightly misguided discussion at BangPypers, there was a comment made on the nature of what SciPy is all about. It occurred to me that folks outside the scientific computing community may be unaware of the nature of issues that concern the scientific community and their significant "mainstream" Python contributions. Let me add that I mean "Scientific computing" and "Python" in the larger sense, not just the "scipy" package.
So, what has the Sci brought to Py?
Scientific computing has an extremely large audience -- at least in terms of the sheer number of students. There are probably 10 times as many people who do not do IT/CSE than those who do. The problems they have to deal with are typically quite complex! Many of them have to perform serious numeric computation, symbolic computation, make plots of complex data in 2D and 3D, perform effective visualization, build user interfaces, be web aware and most importantly work with other languages in the interest of performance. They also have some of the largest computational needs anywhere.
Secondly, it is a fact that many of the mainstream scientific computing tools today that are written in Python are actually really sophisticated beasts. I will illustrate several of these with specific examples. I am detailing several packages whose internals embody very interesting tools and techniques and often these have crossed over to mainstream Python.
Probably the most popular Python interpreter used world over is IPython , which was started by a good friend of mine (Fernando Perez) who is actually a physicist by training and currently working on neuro-imaging at Berkeley today. Guess what, his motivation was to write the tool we all love today? -- the need for a powerful interactive interpreter like Matlab/IDEAL and Mathematica. Technically there is a ton of interesting stuff going on under the hood -- working with a curses-based terminal and getting that working in a cross platform fashion is a big task. IPython happens to interact really well with the underlying shell and provides several threaded environments (-wthread, -q4thread, -gthread, -pylab). IPython is also breaking interesting ground in the area of distributed/parallel computing with their newer versions. In addition to this they also broke somewhat new ground in the "Python for scientific computing" community by using DVCS very early. It is very likely that Fernando will be here with us for SciPy.in 2009.
Sage is a huge package that brings together a very large collection of other tools written in a variety of languages under one Python based platform along with a very cool web based interactive notebook. The target audience being mathematicians, scientists and engineers. Sage also has a very large developer base, and follow the principle of "release very early and very often". They have some great documentation and a really solid development policy. They have over 75% test coverage (and growing) -- for a tool that large, that is really quite something. The sage project also forked a branch from Pyrex that has led to a very important piece of the scientific computing puzzle, namely high performance Python via Cython. This is one project that will probably make best use of any type annotation additions to Python.
Keep your eyes open for a potential "Sage days" (a Sage conference) in August in India next year that FOSSEE will be organizing with the Sage lead, Prof. William Stein.
The NumPy package is the backbone of most Python based numerical computing packages and has actually motivated the need for enhancing the buffer protocol in Python3. Incidentally, Travis Oliphant, the architect of numpy and the buffer protocol for Python 3 is the keynote speaker at SciPy.in this year.
The SciPy package itself builds atop numpy and a suite of well established algorithms written both in C/C++ and FORTRAN to provide Pythonistas a mechanism for serious number crunching.
matplotlib library is the leading 2D plotting Python package in business today. Almost everyone uses it, all over the place.
The tools that I've been personally working on, for the last several years also deserve mention for their sheer technical qualities. The Enthought Tool Suite (ETS) boasts a huge array of useful packages along with very interesting technology (all of which is BSD licensed BTW). Traits forms the cornerstone of this tool stack. Traits allows us to write code with a strong emphasis on focusing on your model, strongly encourages MVC and allows for inversion of control. I like to think of traits as Python attributes on steroids (without side effects)! It makes it extremely easy to create simple and fairly complex UI's with little or no UI code (save a declarative specification of what elements you want to see). Traits also provides two UI backends for wxPython and Qt4. Gael Varoquaux has written an excellent tutorial on the topic.
ETS features Envisage which is a Python-based framework for building extensible applications. The applications can be extended by using plugins. Think of it as an Eclipse-like application framework for Python.
Sitting atop this is Mayavi which features several interesting features. It provides powerful traits based 3D visualization that is at accessible as an application, a pure library, a one-line (matlab-like) convenience wrapper usable like matplotlib's pylab from an IPython session (or pure Python scripts), envisage plugin and a pluggable widget for traits based apps. Mayavi also features some really neat features like automatic script recording.
ETS also features a powerful interactive 2D and flexible 2D plotting via Chaco.
Clearly, there is a lot of very interesting stuff in the few tools that I've listed above that have a significant impact to both folks in the scientific computing community and outside.
Incidentally, did you know that GvR was the keynote at SciPy07 and Alex Martelli was the keynote last year at SciPy08? And do you know who the keynote was at SciPy09? Peter Norvig! These conferences were held at Caltech.
From this, it should be evident to those who are in the community that really the Scientific computing community is not a fringe community in relation to the mainstream Python community.
Since Python is such a powerful programming toolkit for scientists and engineers, we wish to spread the adoption of Python in the college curriculum and thereby improve the quality of education at the college level.

Drupal?

There has been a bit of a lively discussion at BangPypers over our choice of drupal and also on the skill levels of our team member etc. Of course it is the inalienable right of anyone to make such comments, express their opinions and to tell us what we should be doing and take us to task when we say or do something that is incorrect. The feedback part is welcome.
Of course there is some confusion there as people have assumed that the site scipy.in is in drupal and on that mistaken assumption have given kind advice about how we may lose our credibility in that conference.
scipy.in is developed in django
fossee.in a site that represents a larger project namely python + scilab + .... is in drupal.
Let me try to explain what and why we did.
We are a group formed with the goal of aiding and enabling the use of python in the teaching of Engineering subjects, maths and science. It is part of a larger project to enable the use of open source tools (of which python is only one) in education.
All the python group members have been recruited with this goal and in our communications with them we have stressed that they will be contributing to this end, by

  • designing and developing courses for students and faculty to learn python
  • helping faculty modify existing courses by replacing examples that use commercial software with python based tools
  • contributing to the documentation of open source python projects that we use in the tasks above
  • contributing code to the python projects

Of course in the early days of the project there were and are many, many things to do. And these things related to the larger fossee projects not just to its python part. And all the team members have been 'volunteered' to do those.
Building a website was one such task. We had expected to hire a good web developer in the first batch but it did not happen. So some members volunteered to do that. I asked that we do a website in Plone as I have some plans for using Plone to build an app around the dissemination, marshalling and publishing of the content we will be producing.
Unfortunately in the time available to us, remember we had to get the courses designed, developed etc, we could not develop the site using plone. Of course it has nothing to do with the tool. Since PyCon was looming large I decided to let the site be done in Drupal. And we essentially did a hurried job without even clearly separating the python.fossee.in and the main fossee.in
Now to sum up:

  • Was Drupal our first choice? No
  • Are we committed to drupal? No
  • Do we plan to change? Yes
  • When? As soon as we get the python framework person in
  • What tool? It will be what our resident expert to be hired is good in

Before I sign off

  • We are hiring! So if you are good in django/zope/plone/tg/pylons/yopf do get in touch. pasokan { AT } fossee.in will reach me
  • There was a comment of how Py is SciPy. Prabhu Ramachandran will be writing a detailed blog on the use of Python in Scientfic Computing

FOSSEE Undercover

We have official FOSSEE t-shirts now! So, yay!

We are about 2 months into the project - baby steps leading hopefully to humongous leaps soon. And what better way to celebrate, spread joy, and share our enthusiasm, than through ... t-shirts? :)

We are serious. We are here to stay. We are a fun team. We like geek humor. The t-shirt embodies all these. Have a look for yourself (image is attached to this post) and tell us what you think.

For now, the t-shirts are designed in two colors - black, and white. The image is that of the white sample (pardon the stating of the obvious :)

They will soon be up for grabs in conferences and workshops near you, apart from any project tasks you contribute to. We distributed about 70 t-shirts at PyCon India (which was held in IISc Bengaluru, recently) and we ran out of them in a matter of minutes, like water in a picnic (so to speak :)!

So, cheers and let thy cup runneth over!

Live Python 9.0x: Behind the Scenes

This all started with training programme for teachers of Amravati University, PR(aka Prabhu) asked, "Can we have a LiveCD kind of setup with all Python goodies packaged together?". The motivation was to have a handy DVD for conducting workshops in better way. Rather then fixing systems with all packages for all participants, lets have this, which can be booted directly. And once they are comfortable, they can install also.
I had already done similar kind of work previously at Sarai. I was very much impressed by working and ease of Ubuntu customization. Documentation available is really well written. Following it, one can roll out one's own Ubuntu release in no time. Though there are GUI tools available, I was more comfortable with this approach. After following basics I wrote a simple script with all commands to make things very fast.

The biggest challenge was to satisfy PR, once I presented him the first "in-house" DVD on Virtual Box, he got really excited. Then started deep hacking of the DVD to fit in various tools and latest release of packages. It was really extensive and feed back and requirements from PR were very frequent. We used to sit together and hack this media for hours.
Some of the beasts we put in this DVD were sage binary(at present 32 bit) 4.1.1, latest Mayavi-3.3.0, entire ets(Enthought Tool Suit), documentations for respective packages and lot more. Complete list is available here.
After this we had really long bike-shedding on how to package this, how to name different versions. And Madhu, PR and Vattam came up with awesome idea of using "zen of python" quotes per release. Then we had punchagan who created this great DVD cover:

But still we were missing something. It needed more hacks. We had all packages but they were all hidden behind scary but awesome linux terminal. Hence we thought of introducing a new menu entry. We created a new /usr/share/desktop-directories/Python.directory file, and added entries to /usr/share/applications/ to come up with:

One more addition was adding videos to DVD itself, so that it is a complete bundle. One wants to get started with Python, there are 8 hours videos bundled inside DVD itself. For that we tweaked /etc/skel/examples.desktop :)

PS: people were asking me to write a blog, and here I ended up with a "ramayan."

Syndicate content