Hello and welcome to thoughtwisps! This is a personal collection of notes and thoughts on software engineering, machine
learning and the technology industry and community. For my professional website, please see
race-conditions.
Thank you for visiting!
11 Mar 2015
LinuxChix London is coming back!
I have an exciting announcement: I will be restarting LinuxChix meetups in the London area.
The LinuxChix community has given me a lot of wonderful support and encouragement over the
years and I would love to give something back to the community.
I will posting details of mailing lists and Meetup pages soon!
07 Mar 2015
Some things I learned today:
-
I still suck at working with Git on shared repositories. Merge conflicts, arrgh! In particular I need to improve in the
following scenarios: (1) Knowing how to pull correctly when someone has pushed changes to a remote repo
in the same branch that I am using. (2) Establishing an effective workflow for developing new
features without messing up the main branch
-
Setting up even a simple app with Flask is way beyond me.
-
Something about Python decorators
-
A Python Flask app process does not die when I execute the standard kill
-
The with
statement in Python
04 Mar 2015
Yesterday, I attended the 10th Pydata London Meetup at Lyst.
The venue was packed by the time I arrived: I never realised there
were so many data obsessed Pythonistas in town!
The Talks
During the course of the night, the audience was treated to two great talks:
Kim Nilsson talked about building great data analyst teams and Evgeniy Burovskiy
talked about cool things you can do with Numpy. I’d like to take a moment to write
down some very interesting pointers I took away from the talks.
Data Geeks Unite! Communication and Team-building 101 for Scientists, Analysts and Engineers.
I hate to say this, but I am usually very prejudiced against ‘soft skills’ talks at meetups.
They inevitably remind me of some Agile retrospective’s that I’ve attended, where people
promise to do a lot of things to improve how the team works, but never actually get around
to implementing those ideas in practice. I am happy to say Kim’s talk proved me 100% wrong.
Here are some interesting things I took away form the talk:
- if you are transitioning from an academic role into a business role, be prepared for culture shock
My own experience matches pretty well with this. I graduated last fall and immediately accepted a job
at software engineering house. All of my experiences for the first few months were isolating and foreign.
- business deadlines are shorter than the deadlines in academia
In academia, deadlines are often well defined and far away in the future. For example, your thesis might be
due in 12 months. Many tech business, (at least in agile software engineering teams) operate in sprints and
one usually releases something every few weeks.
- collaboration with your co-workers is more ‘intense’ than in academia
When I was completing my Master’s degree, I attended maybe 10 hours worth of lectures and tutorials and
the rest of the time was devoted for research. An academic job allows you to hack away on your code
pretty much without interference save for the occasional meeting with a supervisor and perhaps some seminars.
Coding at a business is different. There are daily stand-ups and sprint demos. Your co-workers will likely
pair up with you and code review what you do. In other, words you will spend a lot more time with your co-workers.
- spend some time researching how to build a great team
Kim talked about Belbin’s 9 different team roles and how an effective team can be structured
by placing different personalities in different roles at key stages in constructing
the product (or data model).
- allow time for learning and playing
One of the most amazing things about writing code for a living is that one has the opportunity to learn
something nnew every day. At my current job, there has not been a day that I have not picked up
at least one new amazing thing about a programming language, a software engineering design principle
or computer architecture. In fact, the flow of useful and important information was so high, I felt
compelled to start this blog and a learning journal! I highly recommend it to other
programmers and data scientists. Reflecting on what you learned solidifies the concepts in your mind.
Even better if you can teach it to someone else later on!
“SciPy Roadmap discussion (with short intro to numpy/scipy)”
Evgeniy’s talk was a menagerie of Numpy and Scipy gotchas and a bunch of useful tips
for Numpy newbies such as myself. Some of the most important points I took away from the talk:
- Numpy runs on arrays. Know your arrays and use them.
import numpy as np
array=np.arange(10)
print array
#array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
Applying an expression on (to?) the variable array
will apply it
on every element in the array.
array1=array+1
print array1
#array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
- Broadcasting can introduce memory and performance issues
I have to admit, I am not a big expert on broadcasting, but is certainly
something that would be cool to explore further!
- You achieve in-place operations on Numpy array by piping the output back into the input
random_array=np.random.random_sample(10)
np.exp(random_array, out=random_array)
There is a great series of exercises compiled by Nicolas Rougier, which will take you
all the way from Neophyte to Numpy master. I’m still working my way through
the Neophyte level :)
- You can write Conway’s Game of Life in only a few lines of Numpy.
This looks like a great weekend project!
04 Mar 2015
Learning braindump entries are not meant to be fully fleshed out blog posts. Instead they represent my attempt to form a consistent mental model of the issue I am trying to master. As such, they may not be always entirely clear or well-written. Apologies!
Generic Types in Java (the super basics)
Generic Types are Java classes or interfaces, which allow the programmer to pass types (ie. other classes and interfaces) as parameters. This is useful, because it allows the same class to be reused with multiple different types.
The Java tutorial track on Generics provides a very helpful example, the Box
class.
Suppose we want to have a class that can hold and manipulate a range of other Java classes.
To implement this idea without using generics, we may have to result to something like the following:
public class Box{
private Object object;
public Box(Object object){
this.object=object;
}
}
With generics, we can pass the type as a parameter.
For example, we could rewrite the Box class to use generic type parameters as follows:
public class Box<T>{
private T object;
}
The type parameter can be used to flesh out the implementation of the class
public class Box<T>{
private T object;
public Box(T object){
this.object=object;
}
}
What types can the type variable take?
A type variable can be any non-primitive type: interface, class, array type or another type variable. (At the moment, having another type variable as the type of a type variable is a bit unclear)
How do I create an instance of a generic type?
Creating an instance of a generic type is called generic type invocation. During invocation you would ideally supply the type you want the generic type to use. Simply put, replace the T in Box with another type.
For example,
//create a Box that holds Strings
Box<String> stringBox = new Box<String>(String helloWorld)
What is a raw type and how do I create one?
It is possible to create an instance of a generic type without supplying type arguments. In the Box example, this would look something like the code snippet below:
//create a raw Box type
Box randomBox = new Box();
However, Eclipse will probably give you friendly nudges if you do this.
18 Feb 2015
This is an on-going series of notes on writing functions in Python. Most of these posts are based on Mark Lutz’s excellent book Learning Python (5th Edition)
A function is a single group of statements that makes our Python code
more reusable and structured! So there is every reason to learn how
to write functions effectively and to know the various ways in which functions can be created in Python.
The def
statement
The most common way to create functions in Python is using def
.
The def
statement simply creates the function object and assigns it to
the name written after def
.
For example,
def average(a,b):
"""
Computes the average of a and b and returns it
"""
return (a+b)/2.0
print average(3,4)
>>> 3.5
The name average
points to the block of code that computes the average of the two numbers.
However, we can do all sorts of things to a function’s name.
For example, we can
python_functions=[]
python_functions.append(average)
#call the function from the list and print the result
print python_functions[0](6,5)
>>> 5.5
- assign it to another name and use the name to refer to it in the future
average_of_two_numbers=average
print average_of_two_numbers(9,8)
>>> 8.5
def is executable
… which means that any function you write will not exist until the Python interpreter
reads the def
statement that first creates the function. We can easily test this
by writing two functions and calling the second function from the first function.
def print_geometric_series():
"""
Prints a geometric series in a nice way
:return None:
"""
geometric_series=compute_geometric_series(2,2,10)
for integer in geometric_series:
print integer
print_geometric_series()
def compute_geometric_series(initial, quotient, n):
"""
Returns a geometric series of length n
:param initial:
:param quotient:
:param n:
:return:
"""
return [initial*quotient**x for x in range(n)]
>>>NameError: global name 'compute_geometric_series' is not defined
As we can see from the NameError that Python throws, the function compute_geometric_series
does
not exist at the time when print_geometric_series
calls it. If you are coming from a Java background,
this may seem bizarre, because of course in Java, the order in which the methods appear in the file
doesnot matter.