Skip to content

Commit 9e67193

Browse files
authored
Naming convention (binsize -> bin_size, etc.) (#316)
1 parent 9007517 commit 9e67193

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3619
-3117
lines changed

doc/style_guide.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ throughout Elephant.
4242

4343
.. code-block:: python
4444
45+
def pair_of_signals_example(spiketrain_i, spiketrain_j):
46+
# Add '_i' and '_j' suffixes to a pair of signals, spiketrains or any
47+
# other variables that come in pairs.
48+
4549
def perfect_naming_of_parameters(spiketrains, spiketrain, reference_spiketrain,
4650
target_spiketrain, signal, signals, max_iterations,
4751
min_threshold, n_bins, n_surrogates, bin_size, max_size,
@@ -119,9 +123,8 @@ throughout Elephant.
119123
Therefore, do not use terms as `n` or `n_surr`, that are not
120124
immediately understood.
121125
bin_size : pq.Quantity or int
122-
Separate the words by underscore. Do not use `binsize`. Old functions
123-
which use `binsize` will be gradually refactored to conform to the new
124-
convention.
126+
Separate the words by underscore. Do not use `bin_size`. Old functions
127+
which use `binsize` are deprecated.
125128
max_size : float
126129
Another example showing that words should be separated by underscores.
127130
This intersects with the naming convention for a maximum value.

doc/tutorials/asset.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@
185185
],
186186
"source": [
187187
"# 2.1.1) create ASSET analysis object\n",
188-
"# hint: try different binsizes, e.g. binsize=2.5, 3.5, 4.0 ms\n",
188+
"# hint: try different bin sizes, e.g. bin_size=2.5, 3.5, 4.0 ms\n",
189189
"asset_obj = asset.ASSET(spiketrains, bin_size=3*pq.ms)\n",
190190
"\n",
191191
"# 2.1.2) compute the intersection matrix\n",

doc/tutorials/parallel.ipynb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@
256256
"source": [
257257
"### Example 2. Custom functions and positional argument\n",
258258
"\n",
259-
"Sometimes you might want to iterate over the second (or third, etc.) argument of a function. To do this, you need to create a custom function that passes its first input argument into the right position of the original function. Below is an example of how to compute time histograms of spiketrains with different `binsize` values (the second argument)."
259+
"Sometimes you might want to iterate over the second (or third, etc.) argument of a function. To do this, you need to create a custom function that passes its first input argument into the right position of the original function. Below is an example of how to compute time histograms of spiketrains with different `bin_size` values (the second argument)."
260260
]
261261
},
262262
{
@@ -269,9 +269,9 @@
269269
"spiketrains = [homogeneous_poisson_process(rate, t_stop=10*pq.s) for _ in range(8)]\n",
270270
"\n",
271271
"# step 2: define your custom function\n",
272-
"def my_custom_function(binsize):\n",
272+
"def my_custom_function(bin_size):\n",
273273
" # specify all custom key-word options here\n",
274-
" return time_histogram(spiketrains, binsize, output='counts')"
274+
" return time_histogram(spiketrains, bin_size, output='counts')"
275275
]
276276
},
277277
{
@@ -282,9 +282,9 @@
282282
},
283283
"outputs": [],
284284
"source": [
285-
"binsize_list = np.linspace(0.1, 1, num=8) * pq.s\n",
285+
"bin_size_list = np.linspace(0.1, 1, num=8) * pq.s\n",
286286
"\n",
287-
"time_hist = ProcessPoolExecutor().execute(my_custom_function, binsize_list)"
287+
"time_hist = ProcessPoolExecutor().execute(my_custom_function, bin_size_list)"
288288
]
289289
},
290290
{
@@ -334,7 +334,7 @@
334334
"cell_type": "markdown",
335335
"metadata": {},
336336
"source": [
337-
"`time_hist` contains 8 AnalogSignals - one AnalogSignal per `binsize` from `binsize_list`.\n",
337+
"`time_hist` contains 8 AnalogSignals - one AnalogSignal per `bin_size` from `bin_size_list`.\n",
338338
"\n",
339339
"### Benchmark\n",
340340
"\n",
@@ -351,7 +351,7 @@
351351
"warnings.filterwarnings(\"ignore\")\n",
352352
"\n",
353353
"# initialize the iteration list\n",
354-
"binsize_list = np.linspace(0.1, 1, 100) * pq.s"
354+
"bin_size_list = np.linspace(0.1, 1, 100) * pq.s"
355355
]
356356
},
357357
{
@@ -369,7 +369,7 @@
369369
],
370370
"source": [
371371
"# sequential processing\n",
372-
"%timeit [time_histogram(spiketrains, binsize) for binsize in binsize_list]"
372+
"%timeit [time_histogram(spiketrains, bin_size) for bin_size in bin_size_list]"
373373
]
374374
},
375375
{
@@ -387,7 +387,7 @@
387387
],
388388
"source": [
389389
"# with parallelization\n",
390-
"%timeit ProcessPoolExecutor(max_workers=4).execute(my_custom_function, binsize_list)"
390+
"%timeit ProcessPoolExecutor(max_workers=4).execute(my_custom_function, bin_size_list)"
391391
]
392392
}
393393
],

doc/tutorials/unitary_event_analysis.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
},
9898
"outputs": [],
9999
"source": [
100-
"def plot_UE(data,Js_dict,Js_sig,binsize,winsize,winstep, pat,N,t_winpos,**kwargs):\n",
100+
"def plot_UE(data,Js_dict,Js_sig,bin_size,winsize,winstep, pat,N,t_winpos,**kwargs):\n",
101101
" \"\"\"\n",
102102
" Examples:\n",
103103
" ---------\n",
@@ -150,9 +150,9 @@
150150
" if len(x)>0:\n",
151151
" xx = []\n",
152152
" for j in sig_idx_win:\n",
153-
" xx =np.append(xx,x[np.where((x*binsize>=t_winpos[j]) &(x*binsize<t_winpos[j] + winsize))])\n",
153+
" xx =np.append(xx,x[np.where((x*bin_size>=t_winpos[j]) &(x*bin_size<t_winpos[j] + winsize))])\n",
154154
" plt.plot(\n",
155-
" np.unique(xx)*binsize, np.ones_like(np.unique(xx))*tr + n*(num_tr + 1) + 1,\n",
155+
" np.unique(xx)*bin_size, np.ones_like(np.unique(xx))*tr + n*(num_tr + 1) + 1,\n",
156156
" ms=arg_dict['marker_size'], marker = 's', ls = '',mfc='none', mec='r')\n",
157157
" plt.axhline((tr + 2)*(n+1) ,lw = 2, color = 'k')\n",
158158
" y_ticks_pos = np.arange(num_tr/2 + 1,N*(num_tr+1), num_tr+1)\n",
@@ -181,7 +181,7 @@
181181
" np.ones_like(data_tr[n].magnitude)*tr + n*(num_tr + 1) + 1,\n",
182182
" '.', markersize=0.5, color = 'k')\n",
183183
" plt.plot(\n",
184-
" np.unique(Js_dict['indices']['trial'+str(tr)])*binsize,\n",
184+
" np.unique(Js_dict['indices']['trial'+str(tr)])*bin_size,\n",
185185
" np.ones_like(np.unique(Js_dict['indices']['trial'+str(tr)]))*tr + n*(num_tr + 1) + 1,\n",
186186
" ls = '',ms=arg_dict['marker_size'], marker = 's', markerfacecolor='none', markeredgecolor='c')\n",
187187
" plt.axhline((tr + 2)*(n+1) ,lw = 2, color = 'k')\n",
@@ -300,10 +300,10 @@
300300
"outputs": [],
301301
"source": [
302302
"UE = ue.jointJ_window_analysis(\n",
303-
" spiketrains, binsize=5*pq.ms, winsize=100*pq.ms, winstep=10*pq.ms, pattern_hash=[3])\n",
303+
" spiketrains, bin_size=5*pq.ms, winsize=100*pq.ms, winstep=10*pq.ms, pattern_hash=[3])\n",
304304
"\n",
305305
"plot_UE(\n",
306-
" spiketrains, UE, ue.jointJ(0.05),binsize=5*pq.ms,winsize=100*pq.ms,winstep=10*pq.ms,\n",
306+
" spiketrains, UE, ue.jointJ(0.05),bin_size=5*pq.ms,winsize=100*pq.ms,winstep=10*pq.ms,\n",
307307
" pat=ue.inverse_hash_from_pattern([3], N=2), N=2,\n",
308308
" t_winpos=ue._winpos(0*pq.ms,spiketrains[0][0].t_stop,winsize=100*pq.ms,winstep=10*pq.ms))\n",
309309
"plt.show()"

0 commit comments

Comments
 (0)