On Fri, 12 Jul 2019, Allin Cottrell wrote:
On Fri, 12 Jul 2019, Sven Schreiber wrote:
> Something else: BTW, the guide mentions that --send-data is not
> available with Ox, but is silent for the Python case. Actually Artur and
> I are working (not too hard) on more tools for passing stuff to Python,
> but enabling --send-data would also be nice. What Python/numpy functions
> would you need to make this work?
Basically just a CSV reading function -- and presumably a target
structure that handles variable names, to make a distinction with just
sending data in matrix form.
In fact, I was thinking about this some time ago: our --send-data
apparatus goes back to a time when we didn't have all the data types we
have now, particularly bundles. It would be really cool if we could pass
bundles to languages that support some variant of associative arrays, eg
R, where they call them lists, or Python, where they call them
dicrtionaries (IIRC). That would give us enormnous flexibility. Of course,
(a) we'd have to write import-export functions for those languages and
(b) we'dd introduce some dependencies in the target languages, but I
reckon that, given the mechanism we have for serialising a bundle as an
xml file, that would be doable.
Proof-of-concept:
<hansl>
bwrite(defbundle("x", 42, "s", "foo"), "b.xml")
foreign language=R
library(XML);
b = xmlToList(xmlParse("b.xml"));
l <- length(b);
for (i in (1:l)) {
type <- b[[i]]$.attrs["type"];
payload <- b[[i]]$text;
print(type);
switch(type,
scalar={print(as.numeric(payload))},
string={print(payload)})
}
end foreign
</hansl>
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------