Sven Schreiber schrieb:
Allin Cottrell schrieb:
> On Wed, 24 Feb 2010, Sven Schreiber wrote:
>
>> And slightly OT: As a pythonista I would of course be interested in
>> adding numerical Python (NumPy) to the list of supported foreign
>> languages. I'm ready to help with the import/export functions. What
>> exactly would be needed?
> Basically, two functions in the target language, one to import
> gretl matrices as written by mwrite(), and one to export matrices
> in the format readable by mread(). Plus one auxiliary function to
> return the gretl "dotdir". These get written out by gretl and
> somehow (depending on the language) get "sourced" at startup
> of "foreign" execution.
Ok that should be fairly easy. I may well have done something like that
already back when I cooked up "py4gretl". I'll also check that next week.
The attached python module contains the two functions
getNumpymatfromgretlmwrite() and putNumpymat4gretlmread() which work for
me (at least in a quick check). "Of course" one needs to have the NumPy
package installed in Python. In principle the functions should work
cross-platform (thanks to os.linesep), but I haven't tested that yet.
The "dotdir" thing is not 100% clear to me yet: Do you mean python
should be told when it's called where gretl's dotdir currently is? (That
wouldn't be a function, strictly speaking, except maybe a function that
parses the arguments included in the python call.)
thanks,
sven