Changeset 13484


Ignore:
Timestamp:
09/28/12 17:33:52 (12 years ago)
Author:
jschierm
Message:

CHG: Change handling of null matrices for python FetchData.

Location:
issm/trunk-jpl/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/python/io/FetchPythonData.cpp

    r13374 r13484  
    7575        M=dims[0]; N=dims[1];
    7676       
    77         /*retrieve internal value: */
    78         dmatrix=(double*)PyArray_DATA((PyArrayObject*)py_matrix);
    79 
    80         /*copy matrix: */
    81         matrix=xNew<double>(M*N);
    82         memcpy(matrix,dmatrix,(M*N)*sizeof(double));
     77        if (M && N) {
     78                /*retrieve internal value: */
     79                dmatrix=(double*)PyArray_DATA((PyArrayObject*)py_matrix);
     80
     81                /*copy matrix: */
     82                matrix=xNew<double>(M*N);
     83                memcpy(matrix,dmatrix,(M*N)*sizeof(double));
     84        }
     85        else
     86                matrix=NULL;
    8387
    8488        /*output: */
     
    107111        M=dims[0]; N=dims[1];
    108112       
    109         /*retrieve internal value: */
    110         dmatrix=(double*)PyArray_DATA((PyArrayObject*)py_matrix);
    111 
    112         /*transform into integer matrix: */
    113         matrix=xNew<int>(M*N);
    114         for(i=0;i<M*N;i++)matrix[i]=(int)dmatrix[i];
     113        if (M && N) {
     114                /*retrieve internal value: */
     115                dmatrix=(double*)PyArray_DATA((PyArrayObject*)py_matrix);
     116
     117                /*transform into integer matrix: */
     118                matrix=xNew<int>(M*N);
     119                for(i=0;i<M*N;i++)matrix[i]=(int)dmatrix[i];
     120        }
     121        else
     122                matrix=NULL;
    115123
    116124        /*output: */
     
    136144        M=dims[0];
    137145       
    138         /*retrieve internal value: */
    139         dvector=(double*)PyArray_DATA((PyArrayObject*)py_vector);
    140 
    141         /*copy vector: */
    142         vector=xNew<double>(M);
    143         memcpy(vector,dvector,(M)*sizeof(double));
     146        if (M) {
     147                /*retrieve internal value: */
     148                dvector=(double*)PyArray_DATA((PyArrayObject*)py_vector);
     149
     150                /*copy vector: */
     151                vector=xNew<double>(M);
     152                memcpy(vector,dvector,(M)*sizeof(double));
     153        }
     154        else
     155                vector=NULL;
    144156
    145157        /*output: */
  • issm/trunk-jpl/src/m/classes/bamggeom.py

    r13436 r13484  
    1212                self.Vertices=numpy.empty((0,3))
    1313                self.Edges=numpy.empty((0,3))
    14                 self.TangentAtEdges=numpy.empty((0,0))
     14                self.TangentAtEdges=numpy.empty((0,4))
    1515                self.Corners=numpy.empty((0,1))
    1616                self.RequiredVertices=numpy.empty((0,1))
Note: See TracChangeset for help on using the changeset viewer.