Changeset: 48953002afcc for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=48953002afcc Modified Files: monetdb5/extras/pyapi/Tests/pyapi00.malC monetdb5/extras/pyapi/pyapi.c monetdb5/mal/mal_listing.c Branch: pyapi Log Message:
Python API mc diffs (69 lines): diff --git a/monetdb5/extras/pyapi/Tests/pyapi00.malC b/monetdb5/extras/pyapi/Tests/pyapi00.malC --- a/monetdb5/extras/pyapi/Tests/pyapi00.malC +++ b/monetdb5/extras/pyapi/Tests/pyapi00.malC @@ -12,7 +12,7 @@ bat.append(b,1189641421); io.print(b); -r:bat[:oid,:dbl] := pyapi.eval(nil:ptr,"This string is somehow not arriving at the C function, why?",b); +r:bat[:oid,:int] := pyapi.eval(nil:ptr,"int(arg1/1000)",b); io.print(r); diff --git a/monetdb5/extras/pyapi/pyapi.c b/monetdb5/extras/pyapi/pyapi.c --- a/monetdb5/extras/pyapi/pyapi.c +++ b/monetdb5/extras/pyapi/pyapi.c @@ -158,7 +158,8 @@ str PyAPIeval(MalBlkPtr mb, MalStkPtr st //if ( v == int_nil) // PyList_SET_ITEM(varlist, j, ); //else - PyList_SET_ITEM(varlist, j, PyInt_FromLong(v)); + // TODO: use numpy arrays here, readonly, ignore NULLs for now? + PyList_SET_ITEM(varlist, j, PyInt_FromLong(v)); } break; // TODO: implement other types @@ -200,12 +201,12 @@ str PyAPIeval(MalBlkPtr mb, MalStkPtr st PyObject *pFunc, *pModule, *pResult; pModule = PyImport_Import(PyString_FromString("__main__")); - pyret = PyRun_SimpleString("def pyfun(x):\n return list(([e+1 for e in x],1))"); + pyret = PyRun_SimpleString("def pyfun(x):\n print(x)\n return list(([e+1 for e in x],1))"); pFunc = PyObject_GetAttrString(pModule, "pyfun"); if (pyret != 0 || !pModule || !pFunc || !PyCallable_Check(pFunc)) { // TODO: include parsed code - msg = createException(MAL, "pyapi.eval", "could not parse blubb"); + msg = createException(MAL, "pyapi.eval", "could not parse Python code %s", rcall); goto wrapup; // shudder } @@ -216,16 +217,12 @@ str PyAPIeval(MalBlkPtr mb, MalStkPtr st msg = createException(MAL, "pyapi.eval", "invalid result object"); goto wrapup; } - - // delete the function again PyRun_SimpleString("del pyfun"); - } // collect the return values for (i = 0; i < pci->retc; i++) { - //SEXP ret_col = VECTOR_ELT(retval, i); int bat_type = ATOMstorage(getColumnType(getArgType(mb,pci,i))); cnt = (BUN) ret_rows; diff --git a/monetdb5/mal/mal_listing.c b/monetdb5/mal/mal_listing.c --- a/monetdb5/mal/mal_listing.c +++ b/monetdb5/mal/mal_listing.c @@ -96,7 +96,7 @@ renderTerm(MalBlkPtr mb, MalStkPtr stk, len++; } showtype =closequote > TYPE_str || ((isVarUDFtype(mb,varid) || isVarTypedef(mb,varid)) && isVarConstant(mb,varid)) || - (isaBatType(getVarType(mb,varid) && idx < p->retc)); + (isaBatType(getVarType(mb,varid)) && idx < p->retc); if (stk && isaBatType(getVarType(mb,varid)) && abs(stk->stk[varid].val.ival) ){ BAT *d= BBPquickdesc(abs(stk->stk[varid].val.ival),TRUE); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list