From 110d9c0e596c7a87fdc1c890e48732acd98375d7 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Tue, 4 Nov 2014 09:38:42 +0100 Subject: change "sort" parameter to "is_sorted" --- Readme.rst | 4 ++-- pyspike/spikes.py | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Readme.rst b/Readme.rst index b9f29e3..662cc1f 100644 --- a/Readme.rst +++ b/Readme.rst @@ -78,7 +78,7 @@ To quickly obtain spike trains from such files, PySpike provides the function :c This function expects the name of the data file as first parameter. Additionally, the time interval of the spike train measurement can be provided as a pair of start- and end-time values. If the time interval is provided (:code:`time_interval is not None`), auxiliary spikes at the start- and end-time of the interval are added to the spike trains. -Furthermore, the spike trains are ordered via :code:`np.sort` (disable this feature by providing :code:`sort=False` as a parameter to the load function). +Furthermore, the spike trains are sorted via :code:`np.sort` (disable this feature by providing :code:`is_sorted=True` as a parameter to the load function). As result, :code:`load_spike_trains_from_txt` returns a *list of arrays* containing the spike trains in the text file. If you load spike trains yourself, i.e. from data files with different structure, you can use the helper function :code:`add_auxiliary_spikes` to add the auxiliary spikes at the beginning and end of the observation interval. @@ -99,7 +99,7 @@ Computing bivariate distances profiles Spike trains are expected to be *sorted*! For performance reasons, the PySpike distance functions do not check if the spike trains provided are indeed sorted. - Make sure that all your spike trains are sorted. + Make sure that all your spike trains are sorted, which is ensured if you use the `load_spike_trains_from_txt` function with the parameter `is_sorted=False`. If in doubt, use :code:`spike_train = np.sort(spike_train)` to obtain a correctly sorted spike train. Furthermore, the spike trains should have auxiliary spikes at the beginning and end of the observation interval. diff --git a/pyspike/spikes.py b/pyspike/spikes.py index 6b6e2e7..f7172c9 100644 --- a/pyspike/spikes.py +++ b/pyspike/spikes.py @@ -48,15 +48,16 @@ def add_auxiliary_spikes(spike_train, time_interval): ############################################################ # spike_train_from_string ############################################################ -def spike_train_from_string(s, sep=' ', sort=True): +def spike_train_from_string(s, sep=' ', is_sorted=False): """ Converts a string of times into an array of spike times. :param s: the string with (ordered) spike times :param sep: The separator between the time numbers, default=' '. - :param sort: If True, the spike times are order via `np.sort`, default=True + :param is_sorted: if True, the spike times are not sorted after loading, + if False, spike times are sorted with `np.sort` :returns: array of spike times """ - if sort: + if not(is_sorted): return np.sort(np.fromstring(s, sep=sep)) else: return np.fromstring(s, sep=sep) -- cgit v1.2.3