Sunday 16 June 2013

GSoC - Coding period starts!


The GSoC coding period starts from 17th June (today!). The last week has been quite enjoyable. The best part of GSoC is that it offers you the opportunity to learn many many new and useful things. This week I have mostly been trying my hand at refactoring the irsa_dust module in astroquery as per the API finalized last week.

One very useful software that I had mainly heard about but never used myself is the IPython Notebook. It is great for creating examples to demonstrate functionality and can be shared using gists and nbviewer It has very handy features like auto-completion - and I am glad that I have it installed and running now!

Another very useful thing I learnt is testing in python. Astropy uses pytest as its main testing framework. It is very simple to write tests in this. In-fact its catch line is No API!. Given its superb test discovery rules and features - it sure is fun to get started writing tests using pytest.

One very useful trick my mentor showed me is to use the @pytest.mark.parametrize decorator. This is very useful if say you want to test a function for several different values of a parameter(s). Rather than writing redundant tests you could do something like :

This will then test the funtion for each value of the parameters coordinate and radius and check that the output is as expected.

Another feature that I also learnt about is monkeypatching. This can be used to create dummy objects, that can mimic the behavior of a real resource - for instance HTTP response and request objects. This can be used in astroquery to create patches that replace actual responses/requests to the remote server.

Also this week I received  a one-year student membership to ACM (that includes a subscription to the digital library) as a part of GSoC!


No comments:

Post a Comment