Changeset 1910 for inundation/utilities
- Timestamp:
- Oct 14, 2005, 6:00:56 AM (19 years ago)
- Location:
- inundation/utilities
- Files:
-
- 4 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/utilities/compile.py
r1908 r1910 240 240 """ 241 241 242 from config import use_extensions242 #from config import use_extensions 243 243 244 244 from os.path import splitext … … 247 247 248 248 C=False 249 if use_extensions: 249 250 try: 251 s = 'import %s' %root 252 #print s 253 exec(s) 254 except: 250 255 try: 251 s = 'import %s' %root 252 #print s 253 exec(s) 256 open(filename) 254 257 except: 258 msg = 'C extension %s cannot be opened' %filename 259 print msg 260 else: 261 print '------- Trying to compile c-extension %s' %filename 262 255 263 try: 256 open(filename)264 compile(filename) 257 265 except: 258 msg = 'C extension %s cannot be opened' %filename 259 print msg 260 else: 261 print '------- Trying to compile c-extension %s' %filename 262 266 print 'WARNING: Could not compile C-extension %s'\ 267 %filename 268 else: 263 269 try: 264 compile(filename)270 exec('import %s' %root) 265 271 except: 266 print 'WARNING: Could not compile C-extension %s'\ 267 %filename 272 msg = 'C extension %s seems to compile OK, ' 273 msg += 'but it can still not be imported.' 274 raise msg 268 275 else: 269 try: 270 exec('import %s' %root) 271 except: 272 msg = 'C extension %s seems to compile OK, ' 273 msg += 'but it can still not be imported.' 274 raise msg 275 else: 276 C=True 277 else: 278 C=True 276 C=True 277 else: 278 C=True 279 279 280 280 if not C: -
inundation/utilities/polygon.py
r1906 r1910 1 2 3 4 5 ##################################### 6 #POLYGON STUFF 7 # 8 #FIXME: All these should be put into new module polygon.py 9 10 1 #!/usr/bin/env python 2 """Polygon manipulations 3 4 """ 5 6 from utilities.numerical_tools import ensure_numeric 11 7 12 8 def point_on_line(x, y, x0, y0, x1, y1): … … 284 280 M = points.shape[0] #Number of points 285 281 286 from util_ext import separate_points_by_polygon282 from polygon_ext import separate_points_by_polygon 287 283 288 284 if verbose: print 'Allocating array for indices' … … 351 347 352 348 def __call__(self, x, y): 353 from util import inside_polygon354 349 from Numeric import ones, Float, concatenate, array, reshape, choose 355 350 -
inundation/utilities/polygon_ext.c
r1906 r1910 245 245 246 246 247 PyObject *gradient(PyObject *self, PyObject *args) {248 //249 // a,b = gradient(x0, y0, x1, y1, x2, y2, q0, q1, q2)250 //251 252 double x0, y0, x1, y1, x2, y2, q0, q1, q2, a, b;253 PyObject *result;254 255 // Convert Python arguments to C256 if (!PyArg_ParseTuple(args, "ddddddddd", &x0, &y0, &x1, &y1, &x2, &y2,257 &q0, &q1, &q2))258 return NULL;259 260 261 // Call underlying routine262 _gradient(x0, y0, x1, y1, x2, y2,263 q0, q1, q2, &a, &b);264 265 // Return values a and b266 result = Py_BuildValue("dd", a, b);267 return result;268 }269 270 PyObject *gradient2(PyObject *self, PyObject *args) {271 //272 // a,b = gradient2(x0, y0, x1, y1, q0, q1)273 //274 275 double x0, y0, x1, y1, q0, q1, a, b;276 PyObject *result;277 278 // Convert Python arguments to C279 if (!PyArg_ParseTuple(args, "dddddd", &x0, &y0, &x1, &y1, &q0, &q1))280 return NULL;281 282 283 // Call underlying routine284 _gradient2(x0, y0, x1, y1, q0, q1, &a, &b);285 286 // Return values a and b287 result = Py_BuildValue("dd", a, b);288 return result;289 }290 291 247 // Method table for python module 292 248 static struct PyMethodDef MethodTable[] = { … … 296 252 */ 297 253 298 //{"rotate", (PyCFunction)rotate, METH_VARARGS | METH_KEYWORDS, "Print out"},299 {"gradient", gradient, METH_VARARGS, "Print out"},300 {"gradient2", gradient2, METH_VARARGS, "Print out"},301 254 {"point_on_line", point_on_line, METH_VARARGS, "Print out"}, 302 255 {"separate_points_by_polygon", separate_points_by_polygon, … … 308 261 309 262 // Module initialisation 310 void init util_ext(void){263 void initpolygon_ext(void){ 311 264 Py_InitModule("polygon_ext", MethodTable); 312 265
Note: See TracChangeset
for help on using the changeset viewer.