From 1d1be84566f8319f4c6ad511a472a4cb5eb0bf87 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Thu, 29 Jun 2023 03:03:49 -0400 Subject: [PATCH 1/4] fix heatmap tiling after linalg refactor --- fastplotlib/graphics/image.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fastplotlib/graphics/image.py b/fastplotlib/graphics/image.py index 2ddf5b4cf..906fc717e 100644 --- a/fastplotlib/graphics/image.py +++ b/fastplotlib/graphics/image.py @@ -500,8 +500,8 @@ def __init__( img.row_chunk_index = chunk[0] img.col_chunk_index = chunk[1] - img.position_x = x_pos - img.position_y = y_pos + img.world.position.x = x_pos + img.world.position.y = y_pos self.world_object.add(img) From 5ef8d763f1300d32182466253a34718ede344041 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Thu, 29 Jun 2023 03:19:26 -0400 Subject: [PATCH 2/4] I can't even do a simple fix properly --- fastplotlib/graphics/image.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fastplotlib/graphics/image.py b/fastplotlib/graphics/image.py index 906fc717e..cb44e2ff2 100644 --- a/fastplotlib/graphics/image.py +++ b/fastplotlib/graphics/image.py @@ -500,8 +500,8 @@ def __init__( img.row_chunk_index = chunk[0] img.col_chunk_index = chunk[1] - img.world.position.x = x_pos - img.world.position.y = y_pos + img.world.x = x_pos + img.world.y = y_pos self.world_object.add(img) From eb0a4442aeb6263ab7e20c7a0b78e5ce67a32532 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Fri, 30 Jun 2023 16:46:36 -0400 Subject: [PATCH 3/4] simpler nb example --- examples/notebooks/heatmap.ipynb | 53 +++++++++----------------------- 1 file changed, 14 insertions(+), 39 deletions(-) diff --git a/examples/notebooks/heatmap.ipynb b/examples/notebooks/heatmap.ipynb index d1c512661..4ec601404 100644 --- a/examples/notebooks/heatmap.ipynb +++ b/examples/notebooks/heatmap.ipynb @@ -20,9 +20,7 @@ "outputs": [], "source": [ "import numpy as np\n", - "import fastplotlib as fpl\n", - "\n", - "from tqdm import tqdm" + "import fastplotlib as fpl" ] }, { @@ -30,7 +28,7 @@ "id": "908f93f8-68c3-4a36-8f40-e0aab560955d", "metadata": {}, "source": [ - "## Generate some random neural-like data" + "## Generate some sine and cosine data" ] }, { @@ -42,54 +40,31 @@ }, "outputs": [], "source": [ - "def generate_traces(n_components, n_frames):\n", - " n_frames = n_frames + 50\n", - " n_components = n_components\n", - " \n", - " out = np.zeros((n_components, n_frames), dtype=np.float16)\n", - " \n", - " xs = np.arange(0, 50, 1)\n", - " # exponential decay\n", - " _lambda = 0.1\n", - " ys = np.e**-(_lambda * xs)\n", - " \n", - " for component_num in tqdm(range(n_components)):\n", - " time_step = 0\n", - " while time_step < n_frames - 50:\n", - " firing_prop = np.random.randint(0, 20)\n", - " if np.random.poisson() > firing_prop:\n", - " out[component_num, time_step:min(time_step + 50, n_frames - 1)] = ys.astype(np.float16)\n", - " time_step += 100\n", - " else:\n", - " time_step += 2\n", - " \n", - " return out[:, :n_frames - 50]" - ] - }, - { - "cell_type": "markdown", - "id": "fc1070d9-f9e9-405f-939c-a130cc5c456a", - "metadata": {}, - "source": [ - "Generate an array that is `10,000 x 30,000`, this may take a few minutes" + "xs = np.linspace(0, 50, 10_000)\n", + "\n", + "sine_data = np.sin(xs)\n", + "\n", + "cosine_data = np.cos(xs)\n", + "\n", + "data = np.vstack([(sine_data, cosine_data) for i in range(5)])" ] }, { "cell_type": "code", "execution_count": null, - "id": "8a1b83f6-c0d8-4237-abd6-b483e7d978ee", + "id": "02b072eb-2909-40c8-8739-950f07efbbc2", "metadata": { "tags": [] }, "outputs": [], "source": [ - "temporal = generate_traces(10_000, 30_000)" + "data.shape" ] }, { "cell_type": "code", "execution_count": null, - "id": "f89bd740-7397-43e7-9e66-d6cfb14de884", + "id": "84deb31b-5464-4cce-a938-694371011021", "metadata": { "tags": [] }, @@ -97,7 +72,7 @@ "source": [ "plot = fpl.Plot()\n", "\n", - "plot.add_heatmap(temporal, cmap=\"viridis\")\n", + "plot.add_image(data, cmap=\"viridis\")\n", "\n", "plot.show(maintain_aspect=False)" ] @@ -105,7 +80,7 @@ { "cell_type": "code", "execution_count": null, - "id": "84deb31b-5464-4cce-a938-694371011021", + "id": "df3f8994-0f5b-4578-a36d-4cd9bf0733c0", "metadata": {}, "outputs": [], "source": [] From 35be10ae9dbf8e4630b0dda436b0082965f16ee5 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Wed, 5 Jul 2023 09:54:07 -0400 Subject: [PATCH 4/4] change heatmap example nb --- examples/notebooks/heatmap.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/notebooks/heatmap.ipynb b/examples/notebooks/heatmap.ipynb index 4ec601404..82583b1df 100644 --- a/examples/notebooks/heatmap.ipynb +++ b/examples/notebooks/heatmap.ipynb @@ -72,7 +72,7 @@ "source": [ "plot = fpl.Plot()\n", "\n", - "plot.add_image(data, cmap=\"viridis\")\n", + "plot.add_heatmap(data, cmap=\"viridis\")\n", "\n", "plot.show(maintain_aspect=False)" ]