So I’ve been watching a lot of OO refactoring screencasts and reading posts and I’m able to say I’ve implemented some of the advice I’ve heard. Life’s all about learning eh?
So the main example I want to talk about here is Null objects.
Null objects In dynamic languages, and Ruby in particular1 the concept of the lack of something needs to be encapsulated. For example: you’re wrapping the database and no entry exists; what to you return?
Tag: python
Scipy contains functions for fitting equations with Python, in its scipy.optimize module. The two main ones I’ve used in the past are leastsq and curve_fit, which in itself is a convenience wrapper around leastsq.
curve_fit For this operation you require three (four) things:
a function to fit of form f(x, *params) x data y data Optionally error data You can also supply an initial guess with the p0 argument.
Often when developing complex client side apps, a simple python -m SimpleHTTPServer
can host the html. For a node backend though, a second server has to be run to host the REST api, which must be on a different domain. For example the python server is on port 8000
, whereas the REST server is run on port 3000
.
Combining Python with LaTeX is a powerful combination. It allows for arbitrary code to be executed which either gives the results of expressions, or can be used to embed programatically certain things e.g. the paths of files or images.
By downloading python.sty and including it in a usepackage block, python code can be run.
I was having trouble getting this to work as it seems I was using an invalid version of python.
This is a problem that has been challenging me for a while: my c++ code uses vectors everywhere so how can I wrap these classes and functions into python easily? I’ve tried many many times with e.g. swig or boost::python to no avail. That is until today…
Quite often at work I have to generate colour maps of certain things, which are generally not sampled evenly in coordinate space. I am also a huge fan of Python, so I thought to myself: can I combine these things? Well until now I didnt think you could. Matplotlibs contour plots require evenly spaced x and y points with z points to match. This is until I found a way
I’m constantly opening an iPython interpreter and having to import my common modules (for me pyfits mostly).
The easiest way to import modules on iPython startup is to look in your
~/.ipython/ipy_user_conf.py file which is a nice easy way to add python code into your ipython startup (as opposed to the ipythonrc file which is about colours etc.).
In the main function, just add a line such as
ip.ex("import pyfits") This will allow custom code to be run at startup.