Skip to main content

Posts

Showing posts from April, 2016

My last day as an Intern at Enthought, India.

For those of you who don't know about Enthought, which is probably all of you, it's provides "Scientific Computing Solutions" and I have been lucky enough to land an internship in the India office. It's been an amazing two months during which I have personally accomplished a lot! Two projects that I have wanted to work on for a very long time finally bore fruit over the last two month.

The first was my interest in making a map that showed the locations of universities around the world where astronomical research is pursued. I wanted to,  and will in the near future, add information about admission deadlines, application fees, expected GPA/GRE/TOEFL scores and what not for the universities and a way for people to select a date range or score range to decide what places to apply to. The months I spent looking and deciding on what universities to apply to could've been put to better use had there been a better way than to visit each department to look for the a…

Pocket Reading List : Week 2.2 of April

How We Found the Dinosaur Doomsday Site : Please tell me that I wasn't the only person who didn't know that scientists were fairly convinced of the location of the asteroid that supposedly killed off the dinosaurs! And the scientists are now conducting an expedition to drill and extract tons of rock from the location on the sea floor to study the rock and understand the event that even toddlers know about!

You have no idea where camels really come from : Science is an amazing thing! It's surprising how every day there's something new to learn. Today, you'll learn that the erstwhile camels that are ubiquitous in the deserts might actually be from the arctic! Hooves thought to have evolved to help them move in the slippery sand could have actually evolved to help them walk on snow! Humps that were supposed to have evolved to help them store water and energy in the desert could have actually evolved to do the same in a frozen arctic!

Mind-Blowing Magic Magnets - Smarter…

Pocket Reading List : Week 2 of April

Study Finds Jack Shit : This story just might hit close to home for a lot of people in science/academia/research. Although it is a satirical piece by the Onion on how a study ended without producing any meaningful results and what the opinions and mood of the researchers involved are, a lot of what's written actually happens. A lot of the time research, addressing a question simply leads to another. Money goes down the drain. Years spent analysing data or conducting the survey turn to dust. People are driven into depression. So, the next time you come across that scientist friend of yours, hug him and tell him that it'll be alright!

“Moon Hoax Not”: Short Film Explains Why It Was Impossible to Fake the Moon Landing : I strongly believe in the fact that NASA landed man on the moon. Multiple times. It's not even belief at this moment. It's blind faith, much like religious faith of a large portion of my family. I've argued with people who don't believe in the moon …

Writing a calculator using stacks in Python

I wrote a calculator in Python. Again. But this time, I didn't write the UI layer. Because principles! Here at Enthought, it's advised to have a clear seperation between the Model and the View and what you see below is the Model part of the calculator. It also makes life easier in two ways. First, it makes testing the underlying model and it's methods easier. Secondly, I can implement the UI however I want to, i.e using traitsUI, raw Qt, Jigna. Whatever!

If you don't understand what's going on in the code, let me explain things a little. There is a standard Python list called inputstack, and it uses as a stack, that stores all of the input characters, let them be numbers or an operator. And the eval_stack method will traverse the inputstack checking for numbers or operators.

Also, this Github repository contains all the calculator codes I've written so far! Again, as always, the code was highlighted and embedded into this blogpost as raw html using hilite.me! Try…

Writing tests for functions and classes in Python

Here's a simple example code that I wrote to test a mathOps class in Python. I use the unittest package which is part of the Python Standard Library.

As you can see, the mathOps class has two attributes, a,b, and there are methods defined that take care of addition, subtraction, multiplication and division. Now, I want to write a code, that tests mathOps class objects to make sure that the methods are giving the output we desire.

One interesting thing to note is the last function/test defined in the mathOpsTest class. The decorator @unittest.expectedFailure tells the testing framework that this test is expected to fail, given that we're passing vectors/arrays to the add method, expecting it to perform vector addition, where as the add method expects input of type Float. The traits package does this type-checking to make sure that the inputs we give are of the right kind!

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36…

Downloading your Google data

I've wanted to download all of my (Google) mails and look at things like how frequently I get mails, how frequently I send mails, how long it takes for me to reply to mails, how long my mails are and how long the mails I get are. Well, start pondering on what all interesting things your mails archive can reveal and i'm sure you'll come up with more interesting questions. The only problem is that the Google mail archive is bound to be a large one, especially given the fact that I've been actively using GMail for over 7 years now. Sometime in the middle, I found the link to create and download my Gmail archive and a day later, Google notified me that it was 4.7 GB in size. Note the GB. As I was at home, I didn't (rather couldn't) download that monster.

I finally got reminded of it yesterday in the evening when I was chatting with one of my mentors here at Enthought India about why I'm interested in learning and using programming. And when I went looking for …

Pocket reading list : Week 1 of April

These Astronomical Glass Plates Made History : For those of you who are old enough, you will remember that before there were digital cameras, photos were recorded on films and there was a studio where the films had to be taken to have them developed into pictures. Before CCDs (the chips inside digital cameras that made the films obsolete) revolutionised astronomy, astronomers used to use films, rather plates, to record images of astronomical objects and their spectra. This is an account of such plates that made history, that record some of the biggest and paradigm-shifting discoveries in astronomy.

The fall… and rise and rise and rise of chat networks : The first chat network that I ever used was google chat, which is now google hangout, and yahoo messenger. I don't know why but I wasn't into MSN Messenger. But there was a time before mine when chat networks were smaller, less technologically advanced and more geeky, so to say. This is a brilliant account of how chat networks c…

Arxiv author affiliations using Python - Part III

After a very long time, I was reminded of this project on Friday. I stopped working on this pet project of mine because I couldn't find a library that let me convert a dataset to a network. I probably (definitely) search hard enough and I would've found a solution had I kept working on the problem for long enough (because look, I have a solution!)!


 The following is the network of affiliations. You can read the last two blogposts I wrote on this topic here and here. You can find the relevant codes in this Github repository. Note that the make_graph.py file in the Github repository will generate this interactive image, containing the network.

Also note that there are a couple of dependencies to be able to run the code. Firstly, the code is written in Python. Secondly, you will need to have the following libraries installed - BeautifulSoup and graph-canvas.

As I've mentioned, albeit briefly, in the previous blog posts, the Python code uses the arXiv API to scrape the most r…

A good resource to understand relative imports in Python

I got to learn that there is such a thing as relative imports in Python. As I understand it, relative imports are used when one part of the package wants to import another part of the package, using the intrinsic file architecture of the package.

While I understood this superficially, I had trouble running codes with relative import statements and as always, StackOverflow came to the rescue! I'm just going to stop here and urge you to read the answer from the SO question, for a better understanding. I'm also leaving this here for further reference for myself.

Making a calculator in Python using pyface and raw Qt.

I wrote yesterday about making a calculator GUI using enthought's traitsUI package. Well, for fun, I rewrote the whole damn thing using Enthought's pyface package in raw Qt. The main difference is that we have lost the ability to automatically monitor the changes in the attributes i.e monitor when the buttons are being pressed. So, we have to now manually connect the QPushButton objects to functions that handle what to do when one of the buttons is pressed. And the layout of the buttons is a little harder to define as well. Well, harder for me because I still haven't been able to wrap my head around Qt.

Anyway, that's all for today I guess. Ohh, also, the 0 button isn't behaving well and I don't think the . button is either! I wanted to write unittests to automate checking whether or not the app/program is working as its supposed to. I'm still trying to learn how to write unittests, for GUI elements, after a failed attempt a couple of days back.

Again, the…