Skip to content

Commit

Permalink
[python] Fix numpy solution numbers and dtype deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
loichuder committed Nov 24, 2021
1 parent 798fed4 commit 500ba30
Showing 1 changed file with 27 additions and 28 deletions.
55 changes: 27 additions & 28 deletions python/numpy/introduction_to_numpy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@
},
"outputs": [],
"source": [
"numpy.zeros((3,), dtype=numpy.int)"
"numpy.zeros((3,), dtype=int)"
]
},
{
Expand All @@ -562,7 +562,7 @@
},
"outputs": [],
"source": [
"numpy.arange(3, dtype=numpy.float)"
"numpy.arange(3, dtype=float)"
]
},
{
Expand Down Expand Up @@ -623,7 +623,7 @@
"a = dict({'key1': 0})\n",
"b = [1, 2, 3]\n",
"c = \"element\"\n",
"numpy.array([a, b, c])"
"numpy.array([a, b, c], dtype=object)"
]
},
{
Expand Down Expand Up @@ -1520,7 +1520,7 @@
"outputs": [],
"source": [
"import exercicesolution\n",
"exercicesolution.show(\"ex3_1\")"
"exercicesolution.show(\"ex4_1\")"
]
},
{
Expand All @@ -1533,7 +1533,7 @@
},
"outputs": [],
"source": [
"exercicesolution.show(\"ex3_2\")"
"exercicesolution.show(\"ex4_2\")"
]
},
{
Expand Down Expand Up @@ -1565,7 +1565,6 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false,
"slideshow": {
"slide_type": "-"
}
Expand Down Expand Up @@ -1704,7 +1703,7 @@
"5.1: binning with a 1D array\n",
"\n",
" \n",
" * 5.1.1: Generate a 100x100 **1D** array with elements in increasing order\n",
" * 5.1.1: Generate a **1D** array with 100 elements in increasing order\n",
" * 5.1.2: Perform (1D) binning such that:\n",
" \n",
" raw data: `1 2 3 4`\n",
Expand Down Expand Up @@ -1753,7 +1752,7 @@
"outputs": [],
"source": [
"import exercicesolution\n",
"exercicesolution.show(\"ex4_1\")"
"exercicesolution.show(\"ex5_1\")"
]
},
{
Expand All @@ -1766,7 +1765,7 @@
},
"outputs": [],
"source": [
"exercicesolution.show(\"ex4_2\")"
"exercicesolution.show(\"ex5_2\")"
]
},
{
Expand All @@ -1779,7 +1778,7 @@
},
"outputs": [],
"source": [
"exercicesolution.show(\"ex4_2_alt\")"
"exercicesolution.show(\"ex5_2_alt\")"
]
},
{
Expand Down Expand Up @@ -2068,8 +2067,8 @@
"source": [
"# inefficient fill\n",
"import exercicesolution\n",
"exercicesolution.show(\"ex5_inefficient_fill\")\n",
"%timeit exercicesolution.ex5_inefficient_fill(1000, 1000)"
"exercicesolution.show(\"ex6_inefficient_fill\")\n",
"%timeit exercicesolution.ex6_inefficient_fill(1000, 1000)"
]
},
{
Expand All @@ -2083,8 +2082,8 @@
"outputs": [],
"source": [
"# naive fill\n",
"exercicesolution.show(\"ex5_naive_fill\")\n",
"%timeit exercicesolution.ex5_naive_fill(1000, 1000)"
"exercicesolution.show(\"ex6_naive_fill\")\n",
"%timeit exercicesolution.ex6_naive_fill(1000, 1000)"
]
},
{
Expand All @@ -2098,8 +2097,8 @@
"outputs": [],
"source": [
"# clever fill\n",
"exercicesolution.show(\"ex5_clever_fill\")\n",
"%timeit exercicesolution.ex5_clever_fill(1000, 1000)"
"exercicesolution.show(\"ex6_clever_fill\")\n",
"%timeit exercicesolution.ex6_clever_fill(1000, 1000)"
]
},
{
Expand All @@ -2113,8 +2112,8 @@
"outputs": [],
"source": [
"# practical fill\n",
"exercicesolution.show(\"ex5_practical_fill\")\n",
"%timeit exercicesolution.ex5_practical_fill(1000, 1000)"
"exercicesolution.show(\"ex6_practical_fill\")\n",
"%timeit exercicesolution.ex6_practical_fill(1000, 1000)"
]
},
{
Expand All @@ -2128,8 +2127,8 @@
"outputs": [],
"source": [
"# optimized fill\n",
"exercicesolution.show(\"ex5_optimized_fill\")\n",
"%timeit exercicesolution.ex5_optimized_fill(1000, 1000)"
"exercicesolution.show(\"ex6_optimized_fill\")\n",
"%timeit exercicesolution.ex6_optimized_fill(1000, 1000)"
]
},
{
Expand All @@ -2143,8 +2142,8 @@
"outputs": [],
"source": [
"# atleast_2d fill\n",
"exercicesolution.show(\"ex5_atleast_2d_fill\")\n",
"%timeit exercicesolution.ex5_atleast_2d_fill(1000, 1000)"
"exercicesolution.show(\"ex6_atleast_2d_fill\")\n",
"%timeit exercicesolution.ex6_atleast_2d_fill(1000, 1000)"
]
},
{
Expand All @@ -2161,12 +2160,12 @@
" \n",
"| Implementation | Duration (seconds) |\n",
"|----------------------|--------------------|\n",
"| ex5_inefficient_fill | 5.052937 |\n",
"| ex5_naive_fill | 0.886003 |\n",
"| ex5_clever_fill | 0.016836 |\n",
"| ex5_practical_fill | 0.014959 |\n",
"| ex5_optimized_fill | 0.004497 |\n",
"| ex5_atleast_2d_fill | 0.005262 |\n",
"| ex6_inefficient_fill | 5.052937 |\n",
"| ex6_naive_fill | 0.886003 |\n",
"| ex6_clever_fill | 0.016836 |\n",
"| ex6_practical_fill | 0.014959 |\n",
"| ex6_optimized_fill | 0.004497 |\n",
"| ex6_atleast_2d_fill | 0.005262 |\n",
"\n",
"Done on Intel(R) Xeon(R) CPU E5-1650 @ 3.50GHz"
]
Expand Down

0 comments on commit 500ba30

Please sign in to comment.