This repository has been archived by the owner on Dec 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #214 from FrancescElies/fe/extension/documentation
documentation upgrades
- Loading branch information
Showing
8 changed files
with
226 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Bcolz extension basic example | ||
============================= | ||
Install needed packages:: | ||
|
||
$ pip install cython | ||
$ pip install numpy | ||
$ pip install bcolz | ||
|
||
Build me | ||
-------- | ||
Build the Bcolz Cython extension:: | ||
|
||
$ python setup.py build_ext --inplace | ||
|
||
Test me | ||
------- | ||
|
||
Start your python session:: | ||
|
||
>>> import bcolz as bz | ||
>>> import my_extension.example_ext as my_mod | ||
>>> c = bz.carray([i for i in range(1000)], dtype='i8') | ||
>>> my_mod.my_function(c) | ||
499500 | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import cython | ||
import bcolz as bz | ||
from bcolz.carray_ext cimport carray | ||
from numpy cimport ndarray, npy_int64 | ||
|
||
@cython.overflowcheck(True) | ||
@cython.boundscheck(False) | ||
@cython.wraparound(False) | ||
cpdef my_function(carray ca): | ||
""" | ||
Function for example purposes | ||
>>> import bcolz as bz | ||
>>> import my_extension.example_ext as my_mod | ||
>>> c = bz.carray([i for i in range(1000)], dtype='i8') | ||
>>> my_mod.my_function(c) | ||
499500 | ||
""" | ||
|
||
cdef: | ||
ndarray ca_segment | ||
Py_ssize_t len_ca_segment | ||
npy_int64 sum=0 | ||
|
||
for ca_segment in bz.iterblocks(ca): | ||
len_ca_segment = len(ca_segment) | ||
for i in range(len_ca_segment): | ||
sum = sum + ca_segment[i] | ||
|
||
return sum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cython>=0.20 | ||
numpy>=1.7.0 | ||
bcolz>=0.8.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from setuptools import setup, Extension | ||
from Cython.Distutils import build_ext | ||
from numpy.distutils.misc_util import get_numpy_include_dirs | ||
|
||
|
||
# Sources | ||
sources = ["my_extension/example_ext.pyx"] | ||
|
||
setup( | ||
name="my_package", | ||
description='My description', | ||
license='MY_LICENSE', | ||
ext_modules=[ | ||
Extension( | ||
"my_extension.example_ext", | ||
sources=sources, | ||
), | ||
], | ||
cmdclass={"build_ext": build_ext}, | ||
packages=['my_extension'], | ||
) |
Oops, something went wrong.