Skip to content

Commit d816da7

Browse files
Fix deprecated numpy aliases of builtin types
A fresh install of kCSD installs the latest numpy (1.25+), which breaks kCSD because [`np.complex` was deprecated in Numpy 1.20](https://numpy.org/doc/stable/release/1.20.0-notes.html#using-the-aliases-of-builtin-types-like-np-int-is-deprecated) Fixes #141
1 parent 1393ac9 commit d816da7

13 files changed

Lines changed: 56 additions & 56 deletions

figures/kCSD_properties/different_error_maps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def grid(x, y, z):
2626
x = x.flatten()
2727
y = y.flatten()
2828
z = z.flatten()
29-
xi, yi = np.mgrid[min(x):max(x):np.complex(0, 100),
30-
min(y):max(y):np.complex(0, 100)]
29+
xi, yi = np.mgrid[min(x):max(x):complex(0, 100),
30+
min(y):max(y):complex(0, 100)]
3131
zi = griddata((x, y), z, (xi, yi), method='linear')
3232
return xi, yi, zi
3333

figures/kCSD_properties/kCSD_with_reliability_map_2D.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ def grid(x, y, z, resX=100, resY=100):
171171
x = x.flatten()
172172
y = y.flatten()
173173
z = z.flatten()
174-
xi, yi = np.mgrid[min(x):max(x):np.complex(0, resX),
175-
min(y):max(y):np.complex(0, resY)]
174+
xi, yi = np.mgrid[min(x):max(x):complex(0, resX),
175+
min(y):max(y):complex(0, resY)]
176176
zi = griddata((x, y), z, (xi, yi), method='linear')
177177
return xi, yi, zi
178178

figures/kCSD_properties/tutorial3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def grid(x, y, z):
2727
x = x.flatten()
2828
y = y.flatten()
2929
z = z.flatten()
30-
xi, yi = np.mgrid[min(x):max(x):np.complex(0, 100),
31-
min(y):max(y):np.complex(0, 100)]
30+
xi, yi = np.mgrid[min(x):max(x):complex(0, 100),
31+
min(y):max(y):complex(0, 100)]
3232
zi = griddata((x, y), z, (xi, yi), method='linear')
3333
return xi, yi, zi
3434

figures/kCSD_properties/tutorial_basic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def grid(x, y, z):
2828
x = x.flatten()
2929
y = y.flatten()
3030
z = z.flatten()
31-
xi, yi = np.mgrid[min(x):max(x):np.complex(0, 100),
32-
min(y):max(y):np.complex(0, 100)]
31+
xi, yi = np.mgrid[min(x):max(x):complex(0, 100),
32+
min(y):max(y):complex(0, 100)]
3333
zi = griddata((x, y), z, (xi, yi), method='linear')
3434
return xi, yi, zi
3535

figures/kCSD_properties/tutorial_basic_3d.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ def generate_csd_3D(csd_profile, csd_seed,
1919
"""
2020
Gives CSD profile at the requested spatial location, at 'res' resolution
2121
"""
22-
csd_at = np.mgrid[start_x:end_x:np.complex(0,res_x),
23-
start_y:end_y:np.complex(0,res_y),
24-
start_z:end_z:np.complex(0,res_z)]
22+
csd_at = np.mgrid[start_x:end_x:complex(0,res_x),
23+
start_y:end_y:complex(0,res_y),
24+
start_z:end_z:complex(0,res_z)]
2525
f = csd_profile(csd_at, seed=csd_seed)
2626
f = f / np.max(np.abs(f))
2727
return csd_at, f
@@ -42,9 +42,9 @@ def generate_electrodes(xlims=[0.1,0.9], ylims=[0.1,0.9], zlims=[0.1,0.9], res=5
4242
"""
4343
Places electrodes in a square grid
4444
"""
45-
ele_x, ele_y, ele_z = np.mgrid[xlims[0]:xlims[1]:np.complex(0,res),
46-
ylims[0]:ylims[1]:np.complex(0,res),
47-
zlims[0]:zlims[1]:np.complex(0,res)]
45+
ele_x, ele_y, ele_z = np.mgrid[xlims[0]:xlims[1]:complex(0,res),
46+
ylims[0]:ylims[1]:complex(0,res),
47+
zlims[0]:zlims[1]:complex(0,res)]
4848
ele_x = ele_x.flatten()
4949
ele_y = ele_y.flatten()
5050
ele_z = ele_z.flatten()
@@ -70,7 +70,7 @@ def make_plots(fig_title,
7070
gs = gridspec.GridSpec(z_steps+1, 4, height_ratios=height_ratios)
7171
t_max = np.max(np.abs(true_csd))
7272
levels = np.linspace(-1*t_max, t_max, 16)
73-
ind_interest = np.mgrid[0:t_csd_z.shape[2]:np.complex(0,z_steps+2)]
73+
ind_interest = np.mgrid[0:t_csd_z.shape[2]:complex(0,z_steps+2)]
7474
ind_interest = np.array(ind_interest, dtype=int)[1:-1]
7575
for ii, idx in enumerate(ind_interest):
7676
ax = plt.subplot(gs[ii, 0])
@@ -130,7 +130,7 @@ def make_plots(fig_title,
130130
# #KCSD - pre_cv
131131
t_max = np.max(np.abs(pre_cv[:,:,:,0]))
132132
levels_kcsd = np.linspace(-1*t_max, t_max, 16)
133-
ind_interest = np.mgrid[0:k_csd_z.shape[2]:np.complex(0,z_steps+2)]
133+
ind_interest = np.mgrid[0:k_csd_z.shape[2]:complex(0,z_steps+2)]
134134
ind_interest = np.array(ind_interest, dtype=int)[1:-1]
135135
for ii, idx in enumerate(ind_interest):
136136
ax = plt.subplot(gs[ii, 2])
@@ -158,7 +158,7 @@ def make_plots(fig_title,
158158
# kCSD post CV
159159
t_max = np.max(np.abs(est_csd[:,:,:,0]))
160160
levels_kcsd = np.linspace(-1*t_max, t_max, 16)
161-
ind_interest = np.mgrid[0:k_csd_z.shape[2]:np.complex(0,z_steps+2)]
161+
ind_interest = np.mgrid[0:k_csd_z.shape[2]:complex(0,z_steps+2)]
162162
ind_interest = np.array(ind_interest, dtype=int)[1:-1]
163163
for ii, idx in enumerate(ind_interest):
164164
ax = plt.subplot(gs[ii, 3])

figures/kCSD_properties/tutorial_broken_electrodes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ def grid(x, y, z):
5252
x = x.flatten()
5353
y = y.flatten()
5454
z = z.flatten()
55-
xi, yi = np.mgrid[min(x):max(x):np.complex(0, 100),
56-
min(y):max(y):np.complex(0, 100)]
55+
xi, yi = np.mgrid[min(x):max(x):complex(0, 100),
56+
min(y):max(y):complex(0, 100)]
5757
zi = griddata((x, y), z, (xi, yi), method='linear')
5858
return xi, yi, zi
5959

figures/kCSD_properties/tutorial_broken_electrodes_diff_err.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ def grid(x, y, z):
5050
x = x.flatten()
5151
y = y.flatten()
5252
z = z.flatten()
53-
xi, yi = np.mgrid[min(x):max(x):np.complex(0, 100),
54-
min(y):max(y):np.complex(0, 100)]
53+
xi, yi = np.mgrid[min(x):max(x):complex(0, 100),
54+
min(y):max(y):complex(0, 100)]
5555
zi = griddata((x, y), z, (xi, yi), method='linear')
5656
return xi, yi, zi
5757

figures/kCSD_properties/tutorial_noisy_electrodes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def grid(x, y, z):
2828
x = x.flatten()
2929
y = y.flatten()
3030
z = z.flatten()
31-
xi, yi = np.mgrid[min(x):max(x):np.complex(0, 100),
32-
min(y):max(y):np.complex(0, 100)]
31+
xi, yi = np.mgrid[min(x):max(x):complex(0, 100),
32+
min(y):max(y):complex(0, 100)]
3333
zi = griddata((x, y), z, (xi, yi), method='linear')
3434
return xi, yi, zi
3535

figures/npx/Neuropixels_for_NEURON.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@
136136
" letter='C', filt=False)\n",
137137
" \n",
138138
" ax4 = plt.subplot(244, aspect='equal')\n",
139-
" xx, yy = np.mgrid[xmin:xmax:np.complex(0, true_csd.shape[0]),\n",
140-
" ymin:ymax:np.complex(0, true_csd.shape[1])]\n",
139+
" xx, yy = np.mgrid[xmin:xmax:complex(0, true_csd.shape[0]),\n",
140+
" ymin:ymax:complex(0, true_csd.shape[1])]\n",
141141
" tcf.plot_csd_smooth(ax4, xmin, xmax, ymin, ymax, true_csd[:, :],\n",
142142
" xx, yy, letter='D')\n",
143143
"\n",

figures/npx/traub_data_kcsd_column_figure.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ def plot_all_currents(ax, xmin, xmax, ymin, ymax, all_x, all_y, all_z, all_val,
264264
def plot_csd_slice(ax, xmin, xmax, ymin, ymax, all_x, all_y, all_z, all_val,
265265
letter='', title=''):
266266
nx, ny = int(800/50), int(2500/50)
267-
vx, vy = np.mgrid[-400:400:np.complex(0, nx+1),
268-
-2000:500:np.complex(0, ny+1)]
267+
vx, vy = np.mgrid[-400:400:complex(0, nx+1),
268+
-2000:500:complex(0, ny+1)]
269269
voxels_csd = np.zeros((nx, ny))
270270

271271
counter = 0
@@ -308,7 +308,7 @@ def plot_dense_potentials(ax, h, pop_names, time_pts, time_pt_interest,
308308
z = 0
309309
tot_ele = nx * ny
310310
zz = np.ones((tot_ele, 1)) * z
311-
xx, yy = np.mgrid[-450:450:np.complex(0, nx), -2000:500:np.complex(0, ny)]
311+
xx, yy = np.mgrid[-450:450:complex(0, nx), -2000:500:complex(0, ny)]
312312
xx = xx.reshape(tot_ele, 1)
313313
yy = yy.reshape(tot_ele, 1)
314314
elec_pos = np.hstack((xx, yy, zz))
@@ -352,7 +352,7 @@ def prepare_electrodes():
352352
dist_from_center_axis = 1.5*22.5+20
353353
od, do = 0, -(10+22.5)*ny
354354
xx, yy = np.mgrid[-dist_from_center_axis:dist_from_center_axis:
355-
np.complex(0, nx), od:do:np.complex(0, ny)]
355+
complex(0, nx), od:do:complex(0, ny)]
356356
xx = xx.reshape(tot_ele, 1)
357357
yy = yy.reshape(tot_ele, 1)
358358
elec4 = np.hstack((xx, yy, zz))
@@ -372,14 +372,14 @@ def prepare_electrodes():
372372
left_border = -30
373373

374374
od, do = 500, -(40*ny/2 - 500)
375-
x1, y1 = np.mgrid[left_border:left_border+2*dist_h:np.complex(0, nx/2),
376-
od:do:np.complex(0, ny/2)]
375+
x1, y1 = np.mgrid[left_border:left_border+2*dist_h:complex(0, nx/2),
376+
od:do:complex(0, ny/2)]
377377
x1 = x1.reshape(int(tot_ele/2), 1)
378378
y1 = y1.reshape(int(tot_ele/2), 1)
379379

380380
x2, y2 = np.mgrid[left_border+dist_h:left_border +
381-
3*dist_h:np.complex(0, nx/2),
382-
od-dist_v:do-dist_v:np.complex(0, ny/2)]
381+
3*dist_h:complex(0, nx/2),
382+
od-dist_v:do-dist_v:complex(0, ny/2)]
383383
x2 = x2.reshape(int(tot_ele/2), 1)
384384
y2 = y2.reshape(int(tot_ele/2), 1)
385385

@@ -434,8 +434,8 @@ def make_column_plot(h, pop_names, time_pts, time_pt_interest, elec_pos_list, na
434434
letter='C', filt=False)
435435

436436
ax4 = plt.subplot(244, aspect='equal')
437-
xx, yy = np.mgrid[xmin:xmax:np.complex(0, true_csd.shape[0]),
438-
ymin:ymax:np.complex(0, true_csd.shape[1])]
437+
xx, yy = np.mgrid[xmin:xmax:complex(0, true_csd.shape[0]),
438+
ymin:ymax:complex(0, true_csd.shape[1])]
439439
plot_csd_smooth(ax4, xmin, xmax, ymin, ymax, true_csd[:, :],
440440
xx, yy, letter='D')
441441

0 commit comments

Comments
 (0)