Commits

Panagiotis Mavrogiorgos committed 8f1560b

Added cython files for lines.py

  • Participants
  • Parent commits e7a508c

Comments (0)

Files changed (2)

+#! /usr/bin/env python2
+# -*- coding: utf-8 -*-
+# module : lines.pxd
+##------------------------------------------------------------------------------
+
+##------------------------------------------------------------------------------
+# Author : P. Mavrogiorgos (pmav99 >at< gmail >dot< com)
+# Licence : GPL v3
+##------------------------------------------------------------------------------
+
+"""
+Cython declaration file.
+"""
+
+cimport cython
+cimport numpy
+from cpython cimport bool
+
+@cython.locals(pred = double,
+               item = double)
+cpdef bool isascending(list seq,
+                  bool strictly = *)
+
+@cython.locals(pred = double,
+               item = double)
+cpdef bool isdescending(list seq,
+                  bool strictly = *)
+
+@cython.locals(area = double,
+               i = int)
+cpdef double calc_area(list a,
+                       list b)
+
+@cython.locals(y0 = double,
+               i = int,
+               np = int)
+cpdef double interpolation(numpy.ndarray[double, ndim=1] xp,
+                           numpy.ndarray[double, ndim=1] yp,
+                           double x0)
+import sys
+
+# setup.py
+from distutils.core import setup
+from distutils.extension import Extension
+from Cython.Distutils import build_ext
+import numpy
+
+# make setup build extension modules in place
+sys.argv.append("build_ext")
+sys.argv.append("--inplace")
+
+# for notes on compiler flags see:
+# http://docs.python.org/install/index.html
+
+cmdclass = {"build_ext": build_ext}
+
+include_dirs = [numpy.get_include()]
+
+ext_modules = [Extension("lines",
+                         ["lines.py"],
+                         extra_compile_args=["-O3"],
+                         )
+               ]
+
+for e in ext_modules:
+    e.pyrex_directives = {"embedsignature": True}
+
+setup(
+    cmdclass = cmdclass,
+    include_dirs = include_dirs,
+    ext_modules = ext_modules
+)