Claridge-Chang Lab
  • About
  • People
  • Papers
  • Join
  • Blog
  • Contact

Installing octave for ipython

12/17/2014

0 Comments

 
In late 2014, to install Octave and Oct2py for use in IPython on a Mac, take the following steps.

  1. Download the Octave binary package from Octave Forge and install

  2. Then install oct2py, by opening a terminal window and entering
    $ pip install oct2py
    as per this page.

  3. Python and oct2py are still not aware of Octave's location. To make them aware, edit your bash profile. As per this page, open a terminal window and enter
    $ touch ~/.bash_profile; open ~/.bash_profile
    This will open your bash profile in TextEdit.

  4. To the bash profile use the method from this page; add the following line of text
    export PATH=/usr/local/octave/3.8.0/bin:$PATH
    You may need to adjust this text as per the version of Octave you are using.

  5. Now as per this page you should be ready to either call Octave as a library of IPython, e.g.
    >>> from oct2py import octave as oc
    >>> x = oc.zeros(3,3)
    >>> print x, x.dtype
    [[ 0.  0.  0.]
     [ 0.  0.  0.]
    [ 0.  0.  0.]] float64

  6. Or you can use oct2py in IPython magic mode like
    In [1]: %load_ext oct2py.ipython
    In [2]: x = %octave [1 2; 3 4];
    x
    Out[2]: array([[ 1.,  2.],
           [ 3.,  4.]])
    as per this page.

Yes this would have been better as a Notebook ;)

0 Comments

about ipython notebookS

12/7/2014

0 Comments

 
An example of an IPython Notebook that converts Python plots into fun, annotated cartoons, suitable for presenting pseudo-quantitative hypotheses: XKCD plots in Matplotlib. It demonstrates some of the beauty of the IPython Notebook format (.ipynb), by being a blog post as python code (or vice versa?). The dual identity of .ipynb files and their mixed-media format solves many problems with other data analysis software: the lack of narrative, the difficulty of sharing and the challenge of 'provenance' - knowing how a result was arrived at, from what data and which analytic methods.

A post by Fernando Perez, the founder of IPython, describes the philosophical aims of the Notebook model (e.g. transparency, easy shareability), and gives some more substantial examples: "Literate computing" and computational reproducibility: IPython in the age of data-driven journalism. In particular, he describes how massive economic pain was inflicted by governments with support from some economists' buggy Excel spreadsheet (Reinhart-Rogoff), and how that this is something that would not have happened with a shared .ipynb file. Such a file was produced in 3 hours by a member of the Python community!

In my view the clear superiority of Python over Matlab is based on things that did not exist when I first reviewed switching in mid-2011. Both the Notebook interface of IPython and the Pandas data analysis library were released with around the end of 2011, and since then both tools have gathered an incredible ecosystem around them. Furthermore, the IPython Notebook now also has 'magic' functions that allow one to call Octave (a free Matlab-like language) and R (a major language for stats) commands in a notebook, features that have evolved dramatically in recent years. Indeed, the first book about IPython was only released in April 2013.

Update: Other great (new-ish?) features of Python are pip install and StackOverflow - they make things much easier than my experience in 2011.
0 Comments

Moving to Python

12/3/2014

0 Comments

 
Picture
I am pretty sick of seeing the above, the Matlab license checkout error message. It comes up when my work copy of Matlab is open. Since my Matlab license only gives permission to use a single copy, the license server prevents me from using it on my work laptop at home. 

Within 20 minutes of seeing this error message, I had downloaded and installed the Anaconda distribution of Python, and used it to do the calculation I wanted to do (a simple linear regression), even though I am not familiar with the Python language. Google served as my help search tool.

It was fewer lines of code, more straightforward than the Matlab script I was going to use and has a better interface (the IPython Notebook). From now on, the lab will be moving away from Matlab and working to use Python wherever possible. We are installing the Anaconda distribution on the server next to our data - so we also avoid having to move files across the network just to analyze.

-Adam
Update, 6th December 2014. 
I just updated my browser to Yosemite, and now Matlab 2012b is completely broken on my laptop.
Picture
0 Comments

    Author

    ACCLab

    Archives

    September 2022
    March 2022
    February 2022
    October 2021
    September 2021
    September 2019
    March 2019
    June 2018
    May 2018
    April 2018
    March 2018
    August 2017
    January 2017
    December 2016
    October 2016
    September 2016
    August 2016
    July 2016
    May 2016
    August 2015
    July 2015
    June 2015
    May 2015
    January 2015
    December 2014
    March 2014

    Categories

    All

    RSS Feed