summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMario Mulansky <mario.mulansky@gmx.net>2015-05-08 12:29:47 +0200
committerMario Mulansky <mario.mulansky@gmx.net>2015-05-08 12:29:47 +0200
commit619ffd7105203938a26075c79a77d63960da9922 (patch)
tree8809df98f9b5c8863398024a49ad5c88f8a62cd9
parentf44d78a5f0b4ab25bb443accdcb9fc1bd8ff57da (diff)
renamed cython_distance module -> cython_profiles
-rw-r--r--pyspike/cython/cython_profiles.pyx (renamed from pyspike/cython/cython_distance.pyx)28
-rw-r--r--pyspike/isi_distance.py10
-rw-r--r--pyspike/spike_distance.py16
-rw-r--r--pyspike/spike_sync.py15
-rw-r--r--setup.py8
5 files changed, 38 insertions, 39 deletions
diff --git a/pyspike/cython/cython_distance.pyx b/pyspike/cython/cython_profiles.pyx
index 6ee0181..59a8d30 100644
--- a/pyspike/cython/cython_distance.pyx
+++ b/pyspike/cython/cython_profiles.pyx
@@ -3,9 +3,9 @@
#cython: cdivision=True
"""
-cython_distances.pyx
+cython_profiles.pyx
-cython implementation of the isi- and spike-distance
+cython implementation of the isi-, spike- and spike-sync profiles
Note: using cython memoryviews (e.g. double[:]) instead of ndarray objects
improves the performance of spike_distance by a factor of 10!
@@ -20,11 +20,11 @@ Distributed under the BSD License
To test whether things can be optimized: remove all yellow stuff
in the html output::
- cython -a cython_distance.pyx
+ cython -a cython_profiles.pyx
which gives::
- cython_distance.html
+ cython_profiles.html
"""
@@ -40,10 +40,10 @@ ctypedef np.float_t DTYPE_t
############################################################
-# isi_distance_cython
+# isi_profile_cython
############################################################
-def isi_distance_cython(double[:] s1, double[:] s2,
- double t_start, double t_end):
+def isi_profile_cython(double[:] s1, double[:] s2,
+ double t_start, double t_end):
cdef double[:] spike_events
cdef double[:] isi_values
@@ -173,10 +173,10 @@ cdef inline double isi_avrg_cython(double isi1, double isi2) nogil:
############################################################
-# spike_distance_cython
+# spike_profile_cython
############################################################
-def spike_distance_cython(double[:] t1, double[:] t2,
- double t_start, double t_end):
+def spike_profile_cython(double[:] t1, double[:] t2,
+ double t_start, double t_end):
cdef double[:] spike_events
cdef double[:] y_starts
@@ -342,7 +342,7 @@ def spike_distance_cython(double[:] t1, double[:] t2,
############################################################
-# coincidence_python
+# get_tau
############################################################
cdef inline double get_tau(double[:] spikes1, double[:] spikes2,
int i, int j, double max_tau):
@@ -364,10 +364,10 @@ cdef inline double get_tau(double[:] spikes1, double[:] spikes2,
############################################################
-# coincidence_cython
+# coincidence_profile_cython
############################################################
-def coincidence_cython(double[:] spikes1, double[:] spikes2,
- double t_start, double t_end, double max_tau):
+def coincidence_profile_cython(double[:] spikes1, double[:] spikes2,
+ double t_start, double t_end, double max_tau):
cdef int N1 = len(spikes1)
cdef int N2 = len(spikes2)
diff --git a/pyspike/isi_distance.py b/pyspike/isi_distance.py
index 8b1e9bf..164378d 100644
--- a/pyspike/isi_distance.py
+++ b/pyspike/isi_distance.py
@@ -31,18 +31,18 @@ def isi_profile(spike_train1, spike_train2):
# load cython implementation
try:
- from cython.cython_distance import isi_distance_cython \
- as isi_distance_impl
+ from cython.cython_profiles import isi_profile_cython \
+ as isi_profile_impl
except ImportError:
print("Warning: isi_distance_cython not found. Make sure that PySpike \
is installed by running\n 'python setup.py build_ext --inplace'!\n \
Falling back to slow python backend.")
# use python backend
from cython.python_backend import isi_distance_python \
- as isi_distance_impl
+ as isi_profile_impl
- times, values = isi_distance_impl(spike_train1.spikes, spike_train2.spikes,
- spike_train1.t_start, spike_train1.t_end)
+ times, values = isi_profile_impl(spike_train1.spikes, spike_train2.spikes,
+ spike_train1.t_start, spike_train1.t_end)
return PieceWiseConstFunc(times, values)
diff --git a/pyspike/spike_distance.py b/pyspike/spike_distance.py
index 499ab77..3567585 100644
--- a/pyspike/spike_distance.py
+++ b/pyspike/spike_distance.py
@@ -31,20 +31,20 @@ def spike_profile(spike_train1, spike_train2):
# cython implementation
try:
- from cython.cython_distance import spike_distance_cython \
- as spike_distance_impl
+ from cython.cython_profiles import spike_profile_cython \
+ as spike_profile_impl
except ImportError:
- print("Warning: spike_distance_cython not found. Make sure that \
+ print("Warning: spike_profile_cython not found. Make sure that \
PySpike is installed by running\n 'python setup.py build_ext --inplace'!\n \
Falling back to slow python backend.")
# use python backend
from cython.python_backend import spike_distance_python \
- as spike_distance_impl
+ as spike_profile_impl
- times, y_starts, y_ends = spike_distance_impl(spike_train1.spikes,
- spike_train2.spikes,
- spike_train1.t_start,
- spike_train1.t_end)
+ times, y_starts, y_ends = spike_profile_impl(spike_train1.spikes,
+ spike_train2.spikes,
+ spike_train1.t_start,
+ spike_train1.t_end)
return PieceWiseLinFunc(times, y_starts, y_ends)
diff --git a/pyspike/spike_sync.py b/pyspike/spike_sync.py
index 7d429e4..107734d 100644
--- a/pyspike/spike_sync.py
+++ b/pyspike/spike_sync.py
@@ -36,24 +36,23 @@ def spike_sync_profile(spike_train1, spike_train2, max_tau=None):
# cython implementation
try:
- from cython.cython_distance import coincidence_cython \
- as coincidence_impl
+ from cython.cython_profiles import coincidence_profile_cython \
+ as coincidence_profile_impl
except ImportError:
print("Warning: spike_distance_cython not found. Make sure that \
PySpike is installed by running\n 'python setup.py build_ext --inplace'!\n \
Falling back to slow python backend.")
# use python backend
from cython.python_backend import coincidence_python \
- as coincidence_impl
+ as coincidence_profile_impl
if max_tau is None:
max_tau = 0.0
- times, coincidences, multiplicity = coincidence_impl(spike_train1.spikes,
- spike_train2.spikes,
- spike_train1.t_start,
- spike_train1.t_end,
- max_tau)
+ times, coincidences, multiplicity \
+ = coincidence_profile_impl(spike_train1.spikes, spike_train2.spikes,
+ spike_train1.t_start, spike_train1.t_end,
+ max_tau)
return DiscreteFunc(times, coincidences, multiplicity)
diff --git a/setup.py b/setup.py
index 289d521..d687240 100644
--- a/setup.py
+++ b/setup.py
@@ -22,7 +22,7 @@ else:
use_cython = True
if os.path.isfile("pyspike/cython/cython_add.c") and \
- os.path.isfile("pyspike/cython/cython_distance.c"):
+ os.path.isfile("pyspike/cython/cython_profiles.c"):
use_c = True
else:
use_c = False
@@ -33,13 +33,13 @@ ext_modules = []
if use_cython: # Cython is available, compile .pyx -> .c
ext_modules += [
Extension("pyspike.cython.cython_add", ["pyspike/cython/cython_add.pyx"]),
- Extension("pyspike.cython.cython_distance", ["pyspike/cython/cython_distance.pyx"]),
+ Extension("pyspike.cython.cython_profiles", ["pyspike/cython/cython_profiles.pyx"]),
]
cmdclass.update({'build_ext': build_ext})
elif use_c: # c files are there, compile to binaries
ext_modules += [
Extension("pyspike.cython.cython_add", ["pyspike/cython/cython_add.c"]),
- Extension("pyspike.cython.cython_distance", ["pyspike/cython/cython_distance.c"]),
+ Extension("pyspike.cython.cython_profiles", ["pyspike/cython/cython_profiles.c"]),
]
# neither cython nor c files available -> automatic fall-back to python backend
@@ -78,7 +78,7 @@ train similarity',
'Programming Language :: Python :: 2.7',
],
package_data={
- 'pyspike': ['cython/cython_add.c', 'cython/cython_distance.c'],
+ 'pyspike': ['cython/cython_add.c', 'cython/cython_profiles.c'],
'test': ['Spike_testdata.txt']
}
)