Changeset bcef5c in git


Ignore:
Timestamp:
Sep 16, 2019, 1:05:01 PM (5 years ago)
Author:
Murray Heymann <heymann.murray@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
Children:
50fb15949d9519d601bdaaa9bf8bbb49921c95a7
Parents:
f0dcd61d6b40b59408860cf1bdbc88f0d558a871
Message:
Put list of predictions in Singular list
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Singular/iparith.cc

    rf0dcd6 rbcef5c  
    78027802static BOOLEAN jjPREDHELP0(leftv res, leftv)
    78037803{
    7804         char buffer[30];
     7804        char *buffer[5];
     7805        int lengths[5];
    78057806        char filename[15] = "~/.history";
    78067807        int i;
    78077808        lists L = (lists)omAllocBin(slists_bin);
    78087809
    7809         buffer[0] = '\0';
     7810        buffer[0] = NULL;
     7811        buffer[1] = NULL;
     7812        buffer[2] = NULL;
     7813        buffer[3] = NULL;
     7814        buffer[4] = NULL;
    78107815
    78117816        if(write_history(NULL)) {
     
    78217826        }
    78227827
    7823         ml_make_prediction(filename, 30, buffer, &i);
    7824         printf("prediction %s\n", buffer);
    7825 
    7826         L->Init(1);
    7827 
    7828         L->m[0].rtyp = STRING_CMD;
    7829         L->m[0].data = omStrDup("SomeString");
     7828        ml_make_prediction(filename, buffer, lengths, _omStrDup);
     7829
     7830        L->Init(5);
     7831
     7832        for (i = 0; i < 5; i++) {
     7833                //printf("prediction %d: %s\n", i, buffer[i]);
     7834                L->m[i].rtyp = STRING_CMD;
     7835                L->m[i].data = buffer[i];
     7836        }
    78307837
    78317838        // pass the resultant list to the res datastructure
  • machine_learning/mlpredict.c

    rf0dcd6 rbcef5c  
    212212int ml_make_prediction(char *filename,
    213213                       char *prediction_buffers[],
    214                        int *pred_len)
     214                       int *pred_len,
     215                       char *(*custom_strdup)(const char *))
    215216{
    216217        PyObject *pFName = NULL;
     
    261262        if (PyList_Size(pValue) != 5) {
    262263                printf("List length is supposed to be five, but is %d.\n",
    263                                 PyList_Size(pValue));
     264                                (int)PyList_Size(pValue));
    264265                Py_DECREF(pValue);
    265266                return 0;
     
    268269        for (i = 0; i < 5; i++) {
    269270                pString = PyObject_Str(PyList_GetItem(pValue, i));
    270                 prediction_buffers[i] = strdup(PyString_AsString(pString));
     271                prediction_buffers[i] = custom_strdup(PyString_AsString(pString));
    271272                //pTemp = PyUnicode_AsASCIIString(pString);
    272                 //prediction_buffers[i] = strdup(PyBytes_AsString(pTemp));
     273                //prediction_buffers[i] = custom_strdup(PyBytes_AsString(pTemp));
    273274                pred_len[i] = strlen(prediction_buffers[i]);
    274275                Py_DECREF(pString);
  • machine_learning/mlpredict.h

    rf0dcd6 rbcef5c  
    6161int ml_make_prediction(char *filename,
    6262                       char *prediction_buffers[],
    63                        int *pred_len);
     63                       int *pred_len,
     64                       char *(*custom_strdup)(const char *));
    6465
    6566#ifdef __cplusplus
  • machine_learning/tests/test_bufsize.c

    rf0dcd6 rbcef5c  
    2121        if (i != 0)                             return 1;
    2222
    23         i = ml_make_prediction("test.txt", buffer, length);
     23        i = ml_make_prediction("test.txt", buffer, length, strdup);
    2424        printf("Returnvalue for ml_make_prediciton: \t%d\n", i);
    2525        for (k = 0; k < 5; k++) {
  • machine_learning/tests/test_init_ml.c

    rf0dcd6 rbcef5c  
    135135
    136136        i = ml_finalise();
    137         printf("Returnvalue for ml_finalise: \t%d\n", i);
     137        printf("Returnvalue for ml_finalise: \t\t%d\n", i);
    138138        if (i != 1)     return 1;
    139139
Note: See TracChangeset for help on using the changeset viewer.