Changeset 8968


Ignore:
Timestamp:
Sep 9, 2013, 9:01:13 PM (11 years ago)
Author:
steve
Message:

Changes to util_ext for contiguous tests

Location:
trunk/anuga_core/source/anuga
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/neighbour_mesh.py

    r8809 r8968  
    10381038
    10391039
    1040     def statistics(self):
     1040    def statistics(self, nbins=10):
    10411041        """Output statistics about mesh
    10421042        """
     
    10511051
    10521052        #Setup 10 bins for area histogram
     1053        #print "nbins",nbins
    10531054        bins = create_bins(areas, 10)
     1055        #print "size bins",bins
    10541056        #m = max(areas)
    10551057        #bins = arange(0., m, m/10)
     
    10811083        N = len(areas)
    10821084        if N > 10:
    1083             str += '    Percentiles (10%):\n'
     1085            str += '    Percentiles (%g percent):\n' % (100/nbins)
    10841086            areas = areas.tolist()
    10851087            areas.sort()
  • trunk/anuga_core/source/anuga/operators/run_collect_max_stage_operator.py

    r8962 r8968  
    3232
    3333domain.set_name() # based on script name
     34
     35print domain.mesh.statistics(nbins=50)
    3436
    3537#------------------------------------------------------------------------------
  • trunk/anuga_core/source/anuga/utilities/util_ext.h

    r8813 r8968  
    2828#define P_ERROR_BUFFER_SIZE 65
    2929
     30
     31// check that numpy array objects are C contiguous memory
     32#define CHECK_C_CONTIG(varname) if (!PyArray_ISCONTIGUOUS(varname)) { \
     33                                    char msg[1024]; \
     34                                    sprintf(msg, \
     35                                            "%s(): file %s, line %d: " \
     36                                            "'%s' object is not C contiguous memory", \
     37                                             __func__, __FILE__, __LINE__, #varname); \
     38                                    PyErr_SetString(PyExc_RuntimeError, msg); \
     39                                    return NULL; \
     40                                }
     41
     42
     43
     44
     45
     46
     47
    3048void report_python_error(const char *location, const char *msg)
    3149{
     
    303321    return NULL;
    304322  }     
    305  
     323
     324
     325  CHECK_C_CONTIG(B);
     326  A = B;
    306327  //Convert to consecutive array
    307   A = (PyArrayObject*) PyArray_ContiguousFromObject((PyObject*) B,
    308                                                     B -> descr -> type, 0, 0);   // New Reference
    309  
    310   Py_DECREF(B); //FIXME: Is this really needed??
     328  //A = (PyArrayObject*) PyArray_ContiguousFromObject((PyObject*) B,
     329  //                                                B -> descr -> type, 0, 0);   // New Reference
     330 
     331  //Py_DECREF(B); //FIXME: Is this really needed??
    311332 
    312333  if (!A) {
     
    409430
    410431
    411 // check that numpy array objects are C contiguous memory
    412 #define CHECK_C_CONTIG(varname) if (!PyArray_ISCONTIGUOUS(varname)) { \
    413                                     char msg[1024]; \
    414                                     sprintf(msg, \
    415                                             "%s(): file %s, line %d: " \
    416                                             "'%s' object is not C contiguous memory", \
    417                                              __func__, __FILE__, __LINE__, #varname); \
    418                                     PyErr_SetString(PyExc_RuntimeError, msg); \
    419                                     return NULL; \
    420                                 }
    421 
    422 
    423 #endif
     432#endif /* ANUGA_UTIL_EXT_H */
Note: See TracChangeset for help on using the changeset viewer.