final for quarter
This commit is contained in:
		
							parent
							
								
									603a0b8d4c
								
							
						
					
					
						commit
						e7d57eefd8
					
				
					 2 changed files with 24 additions and 19 deletions
				
			
		|  | @ -96,7 +96,7 @@ | ||||||
|     "    # centered at origin, radius 1\n", |     "    # centered at origin, radius 1\n", | ||||||
|     "    result = circle_contains(1, origin, origin)\n", |     "    result = circle_contains(1, origin, origin)\n", | ||||||
|     "    assert result\n", |     "    assert result\n", | ||||||
|     "    assert circle_contains(1, origin, Point(.5, .5))\n", |     "    assert circle_contains(1, origin, Point(.5, .5)), \"circle should contain 0.5, 0.5\"\n", | ||||||
|     "\n", |     "\n", | ||||||
|     "def test_circle_contains_edge():\n", |     "def test_circle_contains_edge():\n", | ||||||
|     "    assert circle_contains(1, origin, Point(1, 0))  # on the circle\n", |     "    assert circle_contains(1, origin, Point(1, 0))  # on the circle\n", | ||||||
|  | @ -440,6 +440,7 @@ | ||||||
|     "    (\"abc\", \"abd\", 1),\n", |     "    (\"abc\", \"abd\", 1),\n", | ||||||
|     "    (\"abc\", \"abc\", 0),\n", |     "    (\"abc\", \"abc\", 0),\n", | ||||||
|     "    (\"abc\", \"xyz\", 3),\n", |     "    (\"abc\", \"xyz\", 3),\n", | ||||||
|  |     "    (\"abc\", \"abcd\", 1),\n", | ||||||
|     "])\n", |     "])\n", | ||||||
|     "def test_hamming_distance(str1, str2, expected):\n", |     "def test_hamming_distance(str1, str2, expected):\n", | ||||||
|     "    assert hamming_distance(str1, str2) == expected\n", |     "    assert hamming_distance(str1, str2) == expected\n", | ||||||
|  | @ -453,7 +454,11 @@ | ||||||
|    "execution_count": null, |    "execution_count": null, | ||||||
|    "metadata": {}, |    "metadata": {}, | ||||||
|    "outputs": [], |    "outputs": [], | ||||||
|    "source": [] |    "source": [ | ||||||
|  |     "test_hamming_distance[abc-abd-1]\n", | ||||||
|  |     "test_hamming_distance[abc-abc-0]\n", | ||||||
|  |     "test_hamming_distance[abc-xyz-3]" | ||||||
|  |    ] | ||||||
|   } |   } | ||||||
|  ], |  ], | ||||||
|  "metadata": { |  "metadata": { | ||||||
|  |  | ||||||
|  | @ -261,7 +261,7 @@ | ||||||
|    "source": [ |    "source": [ | ||||||
|     "import numpy as np\n", |     "import numpy as np\n", | ||||||
|     "print(np.array([1, 2, 3, 4, 5]))  \n", |     "print(np.array([1, 2, 3, 4, 5]))  \n", | ||||||
|     "print(np.array([1, 2, 3, 4., 5]))  # one float will make the entire array floats" |     "print(np.array([1, 2, 3, 4.0, 5]))  # one float will make the entire array floats" | ||||||
|    ] |    ] | ||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|  | @ -712,7 +712,7 @@ | ||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|    "cell_type": "code", |    "cell_type": "code", | ||||||
|    "execution_count": 19, |    "execution_count": 3, | ||||||
|    "id": "eb390bd2-00e6-452a-9ff6-a9bc8d39d8b8", |    "id": "eb390bd2-00e6-452a-9ff6-a9bc8d39d8b8", | ||||||
|    "metadata": {}, |    "metadata": {}, | ||||||
|    "outputs": [], |    "outputs": [], | ||||||
|  | @ -747,7 +747,7 @@ | ||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|    "cell_type": "code", |    "cell_type": "code", | ||||||
|    "execution_count": 20, |    "execution_count": 4, | ||||||
|    "id": "6037f4be-9df6-43a5-bc0e-28540fa9cea1", |    "id": "6037f4be-9df6-43a5-bc0e-28540fa9cea1", | ||||||
|    "metadata": {}, |    "metadata": {}, | ||||||
|    "outputs": [], |    "outputs": [], | ||||||
|  | @ -775,7 +775,7 @@ | ||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|    "cell_type": "code", |    "cell_type": "code", | ||||||
|    "execution_count": 21, |    "execution_count": 5, | ||||||
|    "id": "19fea8cf-93ee-422b-b8c1-93f868c1a1f8", |    "id": "19fea8cf-93ee-422b-b8c1-93f868c1a1f8", | ||||||
|    "metadata": {}, |    "metadata": {}, | ||||||
|    "outputs": [], |    "outputs": [], | ||||||
|  | @ -801,7 +801,7 @@ | ||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|    "cell_type": "code", |    "cell_type": "code", | ||||||
|    "execution_count": 25, |    "execution_count": 6, | ||||||
|    "id": "6aa5a845-a38f-41c0-8be4-a2a10c184511", |    "id": "6aa5a845-a38f-41c0-8be4-a2a10c184511", | ||||||
|    "metadata": {}, |    "metadata": {}, | ||||||
|    "outputs": [ |    "outputs": [ | ||||||
|  | @ -815,9 +815,9 @@ | ||||||
|       "│ ---            ┆ ---                 │\n", |       "│ ---            ┆ ---                 │\n", | ||||||
|       "│ str            ┆ f64                 │\n", |       "│ str            ┆ f64                 │\n", | ||||||
|       "╞════════════════╪═════════════════════╡\n", |       "╞════════════════╪═════════════════════╡\n", | ||||||
|       "│ Pure Python    ┆ 228.155336          │\n", |       "│ Pure Python    ┆ 238.297975          │\n", | ||||||
|       "│ Pandas         ┆ 88.117557           │\n", |       "│ Pandas         ┆ 86.9603             │\n", | ||||||
|       "│ Polars         ┆ 8.866674            │\n", |       "│ Polars         ┆ 10.461535           │\n", | ||||||
|       "└────────────────┴─────────────────────┘\n" |       "└────────────────┴─────────────────────┘\n" | ||||||
|      ] |      ] | ||||||
|     } |     } | ||||||
|  | @ -836,7 +836,7 @@ | ||||||
|     "    return timeit.timeit(lambda: func(*args), number=iterations) / iterations\n", |     "    return timeit.timeit(lambda: func(*args), number=iterations) / iterations\n", | ||||||
|     "\n", |     "\n", | ||||||
|     "# time each function\n", |     "# time each function\n", | ||||||
|     "ITERATIONS = 100\n", |     "ITERATIONS = 20\n", | ||||||
|     "python_time = avg_time(find_bills_pure_python, BILLS_FILE, LEGISLATORS_FILE, SPONSORSHIPS_FILE, TARGET_NAME, iterations=ITERATIONS)\n", |     "python_time = avg_time(find_bills_pure_python, BILLS_FILE, LEGISLATORS_FILE, SPONSORSHIPS_FILE, TARGET_NAME, iterations=ITERATIONS)\n", | ||||||
|     "pandas_time = avg_time(find_bills_pandas, BILLS_FILE, LEGISLATORS_FILE, SPONSORSHIPS_FILE, TARGET_NAME, iterations=ITERATIONS)\n", |     "pandas_time = avg_time(find_bills_pandas, BILLS_FILE, LEGISLATORS_FILE, SPONSORSHIPS_FILE, TARGET_NAME, iterations=ITERATIONS)\n", | ||||||
|     "polars_time = avg_time(find_bills_polars, BILLS_FILE, LEGISLATORS_FILE, SPONSORSHIPS_FILE, TARGET_NAME, iterations=ITERATIONS)\n", |     "polars_time = avg_time(find_bills_polars, BILLS_FILE, LEGISLATORS_FILE, SPONSORSHIPS_FILE, TARGET_NAME, iterations=ITERATIONS)\n", | ||||||
|  | @ -852,7 +852,7 @@ | ||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|    "cell_type": "code", |    "cell_type": "code", | ||||||
|    "execution_count": 35, |    "execution_count": 7, | ||||||
|    "id": "17c75df4-4d7b-45b5-be21-56fd80f81ff6", |    "id": "17c75df4-4d7b-45b5-be21-56fd80f81ff6", | ||||||
|    "metadata": {}, |    "metadata": {}, | ||||||
|    "outputs": [ |    "outputs": [ | ||||||
|  | @ -861,23 +861,23 @@ | ||||||
|       "text/html": [ |       "text/html": [ | ||||||
|        "\n", |        "\n", | ||||||
|        "<style>\n", |        "<style>\n", | ||||||
|        "  #altair-viz-8c673fa3f4124c978474f0b658f67ae4.vega-embed {\n", |        "  #altair-viz-7b3877bef0154bc3afbd3485f825bc8f.vega-embed {\n", | ||||||
|        "    width: 100%;\n", |        "    width: 100%;\n", | ||||||
|        "    display: flex;\n", |        "    display: flex;\n", | ||||||
|        "  }\n", |        "  }\n", | ||||||
|        "\n", |        "\n", | ||||||
|        "  #altair-viz-8c673fa3f4124c978474f0b658f67ae4.vega-embed details,\n", |        "  #altair-viz-7b3877bef0154bc3afbd3485f825bc8f.vega-embed details,\n", | ||||||
|        "  #altair-viz-8c673fa3f4124c978474f0b658f67ae4.vega-embed details summary {\n", |        "  #altair-viz-7b3877bef0154bc3afbd3485f825bc8f.vega-embed details summary {\n", | ||||||
|        "    position: relative;\n", |        "    position: relative;\n", | ||||||
|        "  }\n", |        "  }\n", | ||||||
|        "</style>\n", |        "</style>\n", | ||||||
|        "<div id=\"altair-viz-8c673fa3f4124c978474f0b658f67ae4\"></div>\n", |        "<div id=\"altair-viz-7b3877bef0154bc3afbd3485f825bc8f\"></div>\n", | ||||||
|        "<script type=\"text/javascript\">\n", |        "<script type=\"text/javascript\">\n", | ||||||
|        "  var VEGA_DEBUG = (typeof VEGA_DEBUG == \"undefined\") ? {} : VEGA_DEBUG;\n", |        "  var VEGA_DEBUG = (typeof VEGA_DEBUG == \"undefined\") ? {} : VEGA_DEBUG;\n", | ||||||
|        "  (function(spec, embedOpt){\n", |        "  (function(spec, embedOpt){\n", | ||||||
|        "    let outputDiv = document.currentScript.previousElementSibling;\n", |        "    let outputDiv = document.currentScript.previousElementSibling;\n", | ||||||
|        "    if (outputDiv.id !== \"altair-viz-8c673fa3f4124c978474f0b658f67ae4\") {\n", |        "    if (outputDiv.id !== \"altair-viz-7b3877bef0154bc3afbd3485f825bc8f\") {\n", | ||||||
|        "      outputDiv = document.getElementById(\"altair-viz-8c673fa3f4124c978474f0b658f67ae4\");\n", |        "      outputDiv = document.getElementById(\"altair-viz-7b3877bef0154bc3afbd3485f825bc8f\");\n", | ||||||
|        "    }\n", |        "    }\n", | ||||||
|        "\n", |        "\n", | ||||||
|        "    const paths = {\n", |        "    const paths = {\n", | ||||||
|  | @ -925,7 +925,7 @@ | ||||||
|        "        .catch(showError)\n", |        "        .catch(showError)\n", | ||||||
|        "        .then(() => displayChart(vegaEmbed));\n", |        "        .then(() => displayChart(vegaEmbed));\n", | ||||||
|        "    }\n", |        "    }\n", | ||||||
|        "  })({\"config\": {\"view\": {\"continuousWidth\": 300, \"continuousHeight\": 300}}, \"data\": {\"name\": \"data-0348f4391cf620461bf4db7f4550641a\"}, \"mark\": {\"type\": \"bar\"}, \"encoding\": {\"color\": {\"field\": \"Implementation\", \"legend\": null, \"type\": \"nominal\"}, \"x\": {\"field\": \"Execution Time (ms)\", \"title\": \"Execution Time (ms)\", \"type\": \"quantitative\"}, \"y\": {\"field\": \"Implementation\", \"sort\": null, \"type\": \"nominal\"}}, \"height\": 300, \"title\": {\"text\": \"Function Timing\", \"subtitle\": \"Averaged over 100 Runs - Lower is Better\"}, \"width\": 500, \"$schema\": \"https://vega.github.io/schema/vega-lite/v5.20.1.json\", \"datasets\": {\"data-0348f4391cf620461bf4db7f4550641a\": [{\"Implementation\": \"Pure Python\", \"Execution Time (ms)\": 228.1553362502018}, {\"Implementation\": \"Pandas\", \"Execution Time (ms)\": 88.11755665985402}, {\"Implementation\": \"Polars\", \"Execution Time (ms)\": 8.866673749871552}]}}, {\"mode\": \"vega-lite\"});\n", |        "  })({\"config\": {\"view\": {\"continuousWidth\": 300, \"continuousHeight\": 300}}, \"data\": {\"name\": \"data-c85f1199b30bf7141927b86fd4883333\"}, \"mark\": {\"type\": \"bar\"}, \"encoding\": {\"color\": {\"field\": \"Implementation\", \"legend\": null, \"type\": \"nominal\"}, \"x\": {\"field\": \"Execution Time (ms)\", \"title\": \"Execution Time (ms)\", \"type\": \"quantitative\"}, \"y\": {\"field\": \"Implementation\", \"sort\": null, \"type\": \"nominal\"}}, \"height\": 300, \"title\": {\"text\": \"Function Timing\", \"subtitle\": \"Averaged over 20 Runs - Lower is Better\"}, \"width\": 500, \"$schema\": \"https://vega.github.io/schema/vega-lite/v5.20.1.json\", \"datasets\": {\"data-c85f1199b30bf7141927b86fd4883333\": [{\"Implementation\": \"Pure Python\", \"Execution Time (ms)\": 238.29797500002314}, {\"Implementation\": \"Pandas\", \"Execution Time (ms)\": 86.96029999991879}, {\"Implementation\": \"Polars\", \"Execution Time (ms)\": 10.46153540009982}]}}, {\"mode\": \"vega-lite\"});\n", | ||||||
|        "</script>" |        "</script>" | ||||||
|       ], |       ], | ||||||
|       "text/plain": [ |       "text/plain": [ | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue