From dcf4ae0ec6da9d3fcf48f0db6902cad5cd4f3203 Mon Sep 17 00:00:00 2001 From: ran Date: Tue, 2 May 2023 02:01:57 +0800 Subject: [PATCH 1/3] Fix the bug inserted in the middle --- content.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/content.js b/content.js index 017551a..913b666 100644 --- a/content.js +++ b/content.js @@ -252,7 +252,7 @@ function getCellContentTextRequiredForBigCode(activeCell) { // in active cell, LeftContext refers to the left side of the pointer, and vice versa, If both are null, it is determined that the pointer is not at the far right const [leftContext, rightContext] = getActiveCellPointerCode(activeCell) - if(!leftContext && !rightContext){ + if(!leftContext){ return null } @@ -261,11 +261,15 @@ function getCellContentTextRequiredForBigCode(activeCell) { const startIndex = activeCellIndex - 3 < 0 ? 0 : activeCellIndex - 3; for (let i = startIndex; i <= activeCellIndex; i++) { + if(i == activeCellIndex){ + combinedContent += `${leftContext}`; + continue + } + const cellElement = cellElements[i]; if (cellElement.classList.contains('code_cell')) { const code = extractTextFromCell(cellElement); - combinedContent += `${code}`; const outputElement = cellElement.querySelector('.output_subarea'); if (outputElement) { @@ -303,13 +307,11 @@ function extractTextFromCell(cell) { codeMirrorLines.forEach((line) => { content.push(line.textContent); }); - const content_str = content.join('\n'); - return content_str; + return content.join('\n'); } - // 开始等待动画,有30s等待时间,如果等待时间过了,出现“error”字体,返回两个值如下,接收:"const [animationInterval, animationElement] = startWaitingAnimation(activeCall)" // 1. animationInterval(interval, 动画计时器),可使用clearInterval(animationInterval)消除动画, 每次请求完毕必须要关掉 // 2. animationElement (dom, 动画字体节点), animationElement.innerHTML = xxx 来赋值 From 51f1bfae49f70cbc495770351cbaf93ff4927ff9 Mon Sep 17 00:00:00 2001 From: ran Date: Tue, 2 May 2023 02:28:42 +0800 Subject: [PATCH 2/3] remove a part todo --- content.js | 2 +- examples/sklearn_digits.ipynb | 71 +++++++++++++++++++++++++++++++---- 2 files changed, 65 insertions(+), 8 deletions(-) diff --git a/content.js b/content.js index 913b666..6fe2303 100644 --- a/content.js +++ b/content.js @@ -256,7 +256,7 @@ function getCellContentTextRequiredForBigCode(activeCell) { return null } - TODO: "The following code needs to add 'leftContext' and 'rightContext'" + TODO: "The following code needs to add 'rightContext'" // Iterate through the last 3 cells before the active cell const startIndex = activeCellIndex - 3 < 0 ? 0 : activeCellIndex - 3; diff --git a/examples/sklearn_digits.ipynb b/examples/sklearn_digits.ipynb index c5736c0..aa5e976 100644 --- a/examples/sklearn_digits.ipynb +++ b/examples/sklearn_digits.ipynb @@ -2,12 +2,15 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "id": "1114df89", "metadata": {}, "outputs": [], "source": [ - "# load Digits Dataset from sklearn\n" + "def hello_word():\n", + " print(\"Hello World\")\n", + "hello_word()Hello World \n", + "hello_word()\n" ] }, { @@ -22,11 +25,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "c164026e", "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(1797, 8, 8)\n", + "(1797,)\n" + ] + } + ], + "source": [ + "# print the shape of the images and labels data\n", + "print(digits.images.shape)\n", + "print(digits.target.shape)" + ] }, { "cell_type": "markdown", @@ -40,9 +56,50 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "20657b9d", "metadata": {}, + "outputs": [ + { + "ename": "ModuleNotFoundError", + "evalue": "No module named 'plt'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[8], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mnumpy\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mnp\u001b[39;00m\u001b[38;5;241m,\u001b[39m \u001b[38;5;21;01mplt\u001b[39;00m\n\u001b[0;32m 3\u001b[0m \u001b[38;5;66;03m# display the first image in the dataset\u001b[39;00m\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28mprint\u001b[39m(digits\u001b[38;5;241m.\u001b[39mimages[\u001b[38;5;241m0\u001b[39m])\n", + "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'plt'" + ] + } + ], + "source": [ + "import numpy as np, plt\n", + "\n", + "# display the first image in the dataset\n", + "print(digits.images[0])\n", + "# display the label for the first image\n", + "print(digits.target[0])\n", + "# display the first 100 images in the dataset\n", + "# rescale the image data\n", + "digits.images = digits.images.astype(np.float64)\n", + "digits.images /= 16\n", + "\n", + "# plot 100 images\n", + "fig, axes = plt.subplots(10, 10, figsize=(8, 8),\n", + " subplot_kw={'xticks':[], 'yticks':[]},\n", + " gridspec_kw=dict(hspace=0.1, wspace=0.1))\n", + "for i, ax in enumerate(axes.flat):\n", + " ax.imshow(digits.images[i], cmap='binary', interpolation='nearest')\n", + " \n", + "# display the first 100 labels\n", + "print(digits.target[:100])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1868c445", + "metadata": {}, "outputs": [], "source": [] } @@ -63,7 +120,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.10" + "version": "3.10.11" } }, "nbformat": 4, From 77af767fcb8821db1df07b05e058c303497cfe77 Mon Sep 17 00:00:00 2001 From: ran Date: Tue, 2 May 2023 02:31:49 +0800 Subject: [PATCH 3/3] Initialize the test ipynb file to the default state --- examples/sklearn_digits.ipynb | 71 ++++------------------------------- 1 file changed, 7 insertions(+), 64 deletions(-) diff --git a/examples/sklearn_digits.ipynb b/examples/sklearn_digits.ipynb index aa5e976..c5736c0 100644 --- a/examples/sklearn_digits.ipynb +++ b/examples/sklearn_digits.ipynb @@ -2,15 +2,12 @@ "cells": [ { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "id": "1114df89", "metadata": {}, "outputs": [], "source": [ - "def hello_word():\n", - " print(\"Hello World\")\n", - "hello_word()Hello World \n", - "hello_word()\n" + "# load Digits Dataset from sklearn\n" ] }, { @@ -25,24 +22,11 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "id": "c164026e", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(1797, 8, 8)\n", - "(1797,)\n" - ] - } - ], - "source": [ - "# print the shape of the images and labels data\n", - "print(digits.images.shape)\n", - "print(digits.target.shape)" - ] + "outputs": [], + "source": [] }, { "cell_type": "markdown", @@ -54,51 +38,10 @@ "This section is really just to show what the images and labels look like. It usually helps to visualize your data to see what you are working with.\n" ] }, - { - "cell_type": "code", - "execution_count": 8, - "id": "20657b9d", - "metadata": {}, - "outputs": [ - { - "ename": "ModuleNotFoundError", - "evalue": "No module named 'plt'", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[1;32mIn[8], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mnumpy\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mnp\u001b[39;00m\u001b[38;5;241m,\u001b[39m \u001b[38;5;21;01mplt\u001b[39;00m\n\u001b[0;32m 3\u001b[0m \u001b[38;5;66;03m# display the first image in the dataset\u001b[39;00m\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28mprint\u001b[39m(digits\u001b[38;5;241m.\u001b[39mimages[\u001b[38;5;241m0\u001b[39m])\n", - "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'plt'" - ] - } - ], - "source": [ - "import numpy as np, plt\n", - "\n", - "# display the first image in the dataset\n", - "print(digits.images[0])\n", - "# display the label for the first image\n", - "print(digits.target[0])\n", - "# display the first 100 images in the dataset\n", - "# rescale the image data\n", - "digits.images = digits.images.astype(np.float64)\n", - "digits.images /= 16\n", - "\n", - "# plot 100 images\n", - "fig, axes = plt.subplots(10, 10, figsize=(8, 8),\n", - " subplot_kw={'xticks':[], 'yticks':[]},\n", - " gridspec_kw=dict(hspace=0.1, wspace=0.1))\n", - "for i, ax in enumerate(axes.flat):\n", - " ax.imshow(digits.images[i], cmap='binary', interpolation='nearest')\n", - " \n", - "# display the first 100 labels\n", - "print(digits.target[:100])" - ] - }, { "cell_type": "code", "execution_count": null, - "id": "1868c445", + "id": "20657b9d", "metadata": {}, "outputs": [], "source": [] @@ -120,7 +63,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.8.10" } }, "nbformat": 4,