Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 36bcc36

Browse files
authored
fix heatmap tiling after linalg refactor (#266)
* fix heatmap tiling after linalg refactor * I can't even do a simple fix properly * simpler nb example * change heatmap example nb
1 parent ea77e46 commit 36bcc36

File tree

2 files changed

+16
-41
lines changed

2 files changed

+16
-41
lines changed

examples/notebooks/heatmap.ipynb

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,15 @@
2020
"outputs": [],
2121
"source": [
2222
"import numpy as np\n",
23-
"import fastplotlib as fpl\n",
24-
"\n",
25-
"from tqdm import tqdm"
23+
"import fastplotlib as fpl"
2624
]
2725
},
2826
{
2927
"cell_type": "markdown",
3028
"id": "908f93f8-68c3-4a36-8f40-e0aab560955d",
3129
"metadata": {},
3230
"source": [
33-
"## Generate some random neural-like data"
31+
"## Generate some sine and cosine data"
3432
]
3533
},
3634
{
@@ -42,70 +40,47 @@
4240
},
4341
"outputs": [],
4442
"source": [
45-
"def generate_traces(n_components, n_frames):\n",
46-
" n_frames = n_frames + 50\n",
47-
" n_components = n_components\n",
48-
" \n",
49-
" out = np.zeros((n_components, n_frames), dtype=np.float16)\n",
50-
" \n",
51-
" xs = np.arange(0, 50, 1)\n",
52-
" # exponential decay\n",
53-
" _lambda = 0.1\n",
54-
" ys = np.e**-(_lambda * xs)\n",
55-
" \n",
56-
" for component_num in tqdm(range(n_components)):\n",
57-
" time_step = 0\n",
58-
" while time_step < n_frames - 50:\n",
59-
" firing_prop = np.random.randint(0, 20)\n",
60-
" if np.random.poisson() > firing_prop:\n",
61-
" out[component_num, time_step:min(time_step + 50, n_frames - 1)] = ys.astype(np.float16)\n",
62-
" time_step += 100\n",
63-
" else:\n",
64-
" time_step += 2\n",
65-
" \n",
66-
" return out[:, :n_frames - 50]"
67-
]
68-
},
69-
{
70-
"cell_type": "markdown",
71-
"id": "fc1070d9-f9e9-405f-939c-a130cc5c456a",
72-
"metadata": {},
73-
"source": [
74-
"Generate an array that is `10,000 x 30,000`, this may take a few minutes"
43+
"xs = np.linspace(0, 50, 10_000)\n",
44+
"\n",
45+
"sine_data = np.sin(xs)\n",
46+
"\n",
47+
"cosine_data = np.cos(xs)\n",
48+
"\n",
49+
"data = np.vstack([(sine_data, cosine_data) for i in range(5)])"
7550
]
7651
},
7752
{
7853
"cell_type": "code",
7954
"execution_count": null,
80-
"id": "8a1b83f6-c0d8-4237-abd6-b483e7d978ee",
55+
"id": "02b072eb-2909-40c8-8739-950f07efbbc2",
8156
"metadata": {
8257
"tags": []
8358
},
8459
"outputs": [],
8560
"source": [
86-
"temporal = generate_traces(10_000, 30_000)"
61+
"data.shape"
8762
]
8863
},
8964
{
9065
"cell_type": "code",
9166
"execution_count": null,
92-
"id": "f89bd740-7397-43e7-9e66-d6cfb14de884",
67+
"id": "84deb31b-5464-4cce-a938-694371011021",
9368
"metadata": {
9469
"tags": []
9570
},
9671
"outputs": [],
9772
"source": [
9873
"plot = fpl.Plot()\n",
9974
"\n",
100-
"plot.add_heatmap(temporal, cmap=\"viridis\")\n",
75+
"plot.add_heatmap(data, cmap=\"viridis\")\n",
10176
"\n",
10277
"plot.show(maintain_aspect=False)"
10378
]
10479
},
10580
{
10681
"cell_type": "code",
10782
"execution_count": null,
108-
"id": "84deb31b-5464-4cce-a938-694371011021",
83+
"id": "df3f8994-0f5b-4578-a36d-4cd9bf0733c0",
10984
"metadata": {},
11085
"outputs": [],
11186
"source": []

fastplotlib/graphics/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,8 @@ def __init__(
500500
img.row_chunk_index = chunk[0]
501501
img.col_chunk_index = chunk[1]
502502

503-
img.position_x = x_pos
504-
img.position_y = y_pos
503+
img.world.x = x_pos
504+
img.world.y = y_pos
505505

506506
self.world_object.add(img)
507507

0 commit comments

Comments
 (0)