summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMario Mulansky <mario.mulansky@gmx.net>2015-07-07 18:55:32 +0200
committerMario Mulansky <mario.mulansky@gmx.net>2015-07-07 18:55:32 +0200
commit5119d47d0f00c3f7203cf94460730b59a7e473ec (patch)
treef17eecd4d2cb7da865b6fe4a1b4faf268ab77334
parent0ece782e1579660cdb71e077cbaaf9f76e97bef4 (diff)
add disable_backend_warning property
Users can now disable the warning messages produced when the cython backend is not available by writing spk.disable_backend_warning = True in the beginning
-rw-r--r--examples/performance.py3
-rw-r--r--examples/plot.py1
-rw-r--r--pyspike/DiscreteFunc.py4
-rw-r--r--pyspike/PieceWiseConstFunc.py7
-rw-r--r--pyspike/PieceWiseLinFunc.py9
-rw-r--r--pyspike/__init__.py2
-rw-r--r--pyspike/isi_distance.py6
-rw-r--r--pyspike/spike_distance.py4
-rw-r--r--pyspike/spike_sync.py4
9 files changed, 30 insertions, 10 deletions
diff --git a/examples/performance.py b/examples/performance.py
index 1c31e8f..d0c3b91 100644
--- a/examples/performance.py
+++ b/examples/performance.py
@@ -14,6 +14,9 @@ from datetime import datetime
import cProfile
import pstats
+# in case you dont have the cython backends, disable the warnings as follows:
+# spk.disable_backend_warning = True
+
M = 100 # number of spike trains
r = 1.0 # rate of Poisson spike times
T = 1E3 # length of spike trains
diff --git a/examples/plot.py b/examples/plot.py
index c44afd1..1922939 100644
--- a/examples/plot.py
+++ b/examples/plot.py
@@ -16,6 +16,7 @@ import matplotlib.pyplot as plt
import pyspike as spk
+
spike_trains = spk.load_spike_trains_from_txt("PySpike_testdata.txt",
edges=(0, 4000))
diff --git a/pyspike/DiscreteFunc.py b/pyspike/DiscreteFunc.py
index 17153ee..a8c054e 100644
--- a/pyspike/DiscreteFunc.py
+++ b/pyspike/DiscreteFunc.py
@@ -6,6 +6,7 @@ from __future__ import print_function
import numpy as np
import collections
+import pyspike
##############################################################
@@ -202,7 +203,8 @@ class DiscreteFunc(object):
from cython.cython_add import add_discrete_function_cython as \
add_discrete_function_impl
except ImportError:
- print("Warning: add_discrete_function_cython not found. Make \
+ if not(pyspike.disable_backend_warning):
+ print("Warning: add_discrete_function_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.")
diff --git a/pyspike/PieceWiseConstFunc.py b/pyspike/PieceWiseConstFunc.py
index 2705443..23ff536 100644
--- a/pyspike/PieceWiseConstFunc.py
+++ b/pyspike/PieceWiseConstFunc.py
@@ -6,6 +6,7 @@ from __future__ import print_function
import numpy as np
import collections
+import pyspike
##############################################################
@@ -191,8 +192,10 @@ class PieceWiseConstFunc(object):
from cython.cython_add import add_piece_wise_const_cython as \
add_piece_wise_const_impl
except ImportError:
- print("Warning: add_piece_wise_const_cython not found. Make sure \
-that PySpike is installed by running\n 'python setup.py build_ext --inplace'! \
+ if not(pyspike.disable_backend_warning):
+ print("Warning: add_piece_wise_const_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 add_piece_wise_const_python as \
diff --git a/pyspike/PieceWiseLinFunc.py b/pyspike/PieceWiseLinFunc.py
index c0dd475..0d51c76 100644
--- a/pyspike/PieceWiseLinFunc.py
+++ b/pyspike/PieceWiseLinFunc.py
@@ -6,6 +6,7 @@ from __future__ import print_function
import numpy as np
import collections
+import pyspike
##############################################################
@@ -230,9 +231,11 @@ class PieceWiseLinFunc:
from cython.cython_add import add_piece_wise_lin_cython as \
add_piece_wise_lin_impl
except ImportError:
- print("Warning: add_piece_wise_lin_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.")
+ if not(pyspike.disable_backend_warning):
+ print("Warning: add_piece_wise_lin_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 add_piece_wise_lin_python as \
add_piece_wise_lin_impl
diff --git a/pyspike/__init__.py b/pyspike/__init__.py
index 3e836bd..2060f73 100644
--- a/pyspike/__init__.py
+++ b/pyspike/__init__.py
@@ -42,3 +42,5 @@ except DistributionNotFound:
__version__ = 'Please install this project with setup.py'
else:
__version__ = _dist.version
+
+disable_backend_warning = False
diff --git a/pyspike/isi_distance.py b/pyspike/isi_distance.py
index 5ea555d..e50f203 100644
--- a/pyspike/isi_distance.py
+++ b/pyspike/isi_distance.py
@@ -2,6 +2,7 @@
# Copyright 2014-2015, Mario Mulansky <mario.mulansky@gmx.net>
# Distributed under the BSD License
+import pyspike
from pyspike import PieceWiseConstFunc
from pyspike.generic import _generic_profile_multi, _generic_distance_multi, \
_generic_distance_matrix
@@ -34,8 +35,9 @@ def isi_profile(spike_train1, spike_train2):
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 \
+ if not(pyspike.disable_backend_warning):
+ print("Warning: isi_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 isi_distance_python \
diff --git a/pyspike/spike_distance.py b/pyspike/spike_distance.py
index dd6d4f8..feea0c1 100644
--- a/pyspike/spike_distance.py
+++ b/pyspike/spike_distance.py
@@ -2,6 +2,7 @@
# Copyright 2014-2015, Mario Mulansky <mario.mulansky@gmx.net>
# Distributed under the BSD License
+import pyspike
from pyspike import PieceWiseLinFunc
from pyspike.generic import _generic_profile_multi, _generic_distance_multi, \
_generic_distance_matrix
@@ -34,7 +35,8 @@ def spike_profile(spike_train1, spike_train2):
from cython.cython_profiles import spike_profile_cython \
as spike_profile_impl
except ImportError:
- print("Warning: spike_profile_cython not found. Make sure that \
+ if not(pyspike.disable_backend_warning):
+ 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
diff --git a/pyspike/spike_sync.py b/pyspike/spike_sync.py
index 40d98d2..10ebdc7 100644
--- a/pyspike/spike_sync.py
+++ b/pyspike/spike_sync.py
@@ -5,6 +5,7 @@
import numpy as np
from functools import partial
+import pyspike
from pyspike import DiscreteFunc
from pyspike.generic import _generic_profile_multi, _generic_distance_matrix
@@ -39,7 +40,8 @@ def spike_sync_profile(spike_train1, spike_train2, max_tau=None):
from cython.cython_profiles import coincidence_profile_cython \
as coincidence_profile_impl
except ImportError:
- print("Warning: spike_distance_cython not found. Make sure that \
+ if not(pyspike.disable_backend_warning):
+ 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