On Wed, 27 Feb 2013, Sven Schreiber wrote:
ok I'm really sorry that adding Python support now leads to
additional
bugs and problems, but I hope these are just toothing pains:
Yeah, I think so.
First, a prelim question: In the gretl_io.py file that gretl writes
out,
why use this function
<python>
def gretl_dotdir():
dotdir = "C:/Users/svenne/AppData/Roaming/gretl/"
return dotdir
</python>
instead of just a plain string definition 'gretl_dotdir =
"<whatever>"'?
Because we don't like global variables? Actually, I'm not sure
about python and globals, but it seems safer/cleaner, though
admittedly more complex, to have a function.
Secondly, in the 'gretl_export()' function (also in
gretl_io.py) the
seemingly innocuous line
'r, c = M.shape'
might be problematic for vectors (given the next issue this is currently
hard to test, but I will). The point is that in numpy vectors may be
represented as 1-dim-arrays; their 'shape' tuple will be '(n,)' and thus
have only length one. I guess there are two solutions; either do a check
like 'len(M.shape)==1', or force M to be a numpy-matrix which is
guaranteed to be 2-dim like gretl matrices. Let me test and then think
about it.
Could we just wrap M as numpy.matrix(M) ? (The gretl_export
function depends on numpy anyway, via savetxt.)
Third, a real problem: The gretltmp.py file written by gretl does
not
preserve the indentation from within gretl's foreign block! Since Python
uses indentation/whitespace as a syntax element, this is completely
broken. Allin, your example in ch. 39 doesn't have any indented blocks
it seems, and so you didn't notice.
True, that rather important point (and silly feature of
python!) had totally escaped me, doh. Should now be fixed in
CVS.
And finally, another indentation-related less severe problem:
gretl's
script editor's on-the-fly indentation is a little annoying when writing
in Python because it does it wrong (understandably). Could this be
somehow turned off inside foreign blocks?
Yes, I'll work on that.
Allin