[SciPy-user] LiberMate was Re: Automating Matlab

josef.pktd@gmai... josef.pktd@gmai...
Mon Feb 23 10:02:35 CST 2009


> Eric Schug wrote:
>> For those interested, my new project has been uploaded sourceforge at,
>> http://sourceforge.net/projects/libermate/
>>
>> Latest version now supports simple command expressions (e.g hold on)
>>

I tried it out on some simple matlab files. I didn't try to run the
translated files yet, but two translations make the code less readable

* translation of integers to floats, e.g. for array indices or for arange
* multiplication of scalar with array is translated with dot, eg
  m:  randn(n,k-1)*10 ->  py: = dot(randn(n, k-1.), 10.)

string array in matlab came out as empty numpy array

m:
vnames=['yvar',
        'iota',
        'x1  ',
        'x2  '];
-> py:
vnames = array(r_[])


Importing everything is a source of possible errors (e.g. pylab
overwrites numpy names)

from numpy import *
import scipy
# if available import pylab (from matlibplot)
try:
    from pylab import *
except ImportError:
    pass

I would prefer the current standard
import numpy as np
import matplotlib.pylab as plt

and keep the name space as part of the name, e.g. np.dot, np.exp, ...

But it looks like it will save a lot of typing and editing, even
though it will need careful proof reading.

Thanks,
Josef


More information about the SciPy-user mailing list