diff --git a/your-code/main.ipynb b/your-code/main.ipynb index 46f5aa1..20e08c3 100644 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -16,11 +16,12 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ - "### [your code here]\n" + "### [your code here]\n", + "import numpy as np" ] }, { @@ -34,11 +35,116 @@ }, { "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [], + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2.2.5\n", + "{\n", + " \"Compilers\": {\n", + " \"c\": {\n", + " \"name\": \"msvc\",\n", + " \"linker\": \"link\",\n", + " \"version\": \"19.29.30159\",\n", + " \"commands\": \"cl\"\n", + " },\n", + " \"cython\": {\n", + " \"name\": \"cython\",\n", + " \"linker\": \"cython\",\n", + " \"version\": \"3.0.12\",\n", + " \"commands\": \"cython\"\n", + " },\n", + " \"c++\": {\n", + " \"name\": \"msvc\",\n", + " \"linker\": \"link\",\n", + " \"version\": \"19.29.30159\",\n", + " \"commands\": \"cl\"\n", + " }\n", + " },\n", + " \"Machine Information\": {\n", + " \"host\": {\n", + " \"cpu\": \"x86_64\",\n", + " \"family\": \"x86_64\",\n", + " \"endian\": \"little\",\n", + " \"system\": \"windows\"\n", + " },\n", + " \"build\": {\n", + " \"cpu\": \"x86_64\",\n", + " \"family\": \"x86_64\",\n", + " \"endian\": \"little\",\n", + " \"system\": \"windows\"\n", + " }\n", + " },\n", + " \"Build Dependencies\": {\n", + " \"blas\": {\n", + " \"name\": \"scipy-openblas\",\n", + " \"found\": true,\n", + " \"version\": \"0.3.28\",\n", + " \"detection method\": \"pkgconfig\",\n", + " \"include directory\": \"C:/Users/runneradmin/AppData/Local/Temp/cibw-run-065080rt/cp313-win_amd64/build/venv/Lib/site-packages/scipy_openblas64/include\",\n", + " \"lib directory\": \"C:/Users/runneradmin/AppData/Local/Temp/cibw-run-065080rt/cp313-win_amd64/build/venv/Lib/site-packages/scipy_openblas64/lib\",\n", + " \"openblas configuration\": \"OpenBLAS 0.3.28 USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS=24\",\n", + " \"pc file directory\": \"D:/a/numpy/numpy/.openblas\"\n", + " },\n", + " \"lapack\": {\n", + " \"name\": \"scipy-openblas\",\n", + " \"found\": true,\n", + " \"version\": \"0.3.28\",\n", + " \"detection method\": \"pkgconfig\",\n", + " \"include directory\": \"C:/Users/runneradmin/AppData/Local/Temp/cibw-run-065080rt/cp313-win_amd64/build/venv/Lib/site-packages/scipy_openblas64/include\",\n", + " \"lib directory\": \"C:/Users/runneradmin/AppData/Local/Temp/cibw-run-065080rt/cp313-win_amd64/build/venv/Lib/site-packages/scipy_openblas64/lib\",\n", + " \"openblas configuration\": \"OpenBLAS 0.3.28 USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS=24\",\n", + " \"pc file directory\": \"D:/a/numpy/numpy/.openblas\"\n", + " }\n", + " },\n", + " \"Python Information\": {\n", + " \"path\": \"C:\\\\Users\\\\runneradmin\\\\AppData\\\\Local\\\\Temp\\\\build-env-19lia66t\\\\Scripts\\\\python.exe\",\n", + " \"version\": \"3.13\"\n", + " },\n", + " \"SIMD Extensions\": {\n", + " \"baseline\": [\n", + " \"SSE\",\n", + " \"SSE2\",\n", + " \"SSE3\"\n", + " ],\n", + " \"found\": [\n", + " \"SSSE3\",\n", + " \"SSE41\",\n", + " \"POPCNT\",\n", + " \"SSE42\",\n", + " \"AVX\",\n", + " \"F16C\",\n", + " \"FMA3\",\n", + " \"AVX2\"\n", + " ],\n", + " \"not found\": [\n", + " \"AVX512F\",\n", + " \"AVX512CD\",\n", + " \"AVX512_SKX\",\n", + " \"AVX512_CLX\",\n", + " \"AVX512_CNL\",\n", + " \"AVX512_ICL\"\n", + " ]\n", + " }\n", + "}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "c:\\Users\\Alejandro Zahinos\\AppData\\Local\\Programs\\Python\\Python313\\Lib\\site-packages\\numpy\\__config__.py:155: UserWarning: Install `pyyaml` for better output\n", + " warnings.warn(\"Install `pyyaml` for better output\", stacklevel=1)\n" + ] + } + ], "source": [ - "### [your code here]\n" + "### [your code here]\n", + "print(np.__version__)\n", + "np.show_config()" ] }, { @@ -51,11 +157,47 @@ }, { "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [], + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[[0.26235372 0.75747483 0.31045207 0.92916286 0.35010032]\n", + " [0.75464651 0.83587243 0.71857409 0.34163054 0.71456439]\n", + " [0.04489696 0.48562375 0.64408764 0.66442038 0.39403221]]\n", + "\n", + " [[0.99654849 0.62141833 0.451934 0.89301115 0.35072306]\n", + " [0.77615259 0.40548301 0.99171326 0.92226949 0.16813904]\n", + " [0.04280546 0.65113488 0.3078791 0.5553119 0.66103685]]]\n", + "[[[ 0.83372355 -0.43823599 0.43250737 -0.15554991 0.58846496]\n", + " [-0.75817337 0.26027204 -1.14947339 1.28608148 0.48246648]\n", + " [-0.66101259 1.09980256 0.6723016 -0.8258994 -1.25320391]]\n", + "\n", + " [[-1.00026292 0.56642525 -2.68859756 -0.58575723 0.25495492]\n", + " [-1.5777449 -0.52612932 0.85361199 0.42693837 -0.94403173]\n", + " [ 0.21722797 0.50644894 -1.23654657 0.42006698 -0.34651514]]]\n", + "[[[0.77101383 0.9255275 0.84134437 0.76036702 0.80013514]\n", + " [0.17994848 0.34902474 0.39108747 0.66248947 0.16643875]\n", + " [0.0738344 0.60410084 0.36146203 0.82021557 0.62302784]]\n", + "\n", + " [[0.23717904 0.38472514 0.75625165 0.16736728 0.45786044]\n", + " [0.7432222 0.55646538 0.02400635 0.92509301 0.72875658]\n", + " [0.25931357 0.03715614 0.15602546 0.31708151 0.27178115]]]\n" + ] + } + ], "source": [ - "### [your code here]\n" + "### [your code here]\n", + "A1 = np.random.rand(2, 3, 5)\n", + "print(A1)\n", + "\n", + "A2 = np.random.randn(2, 3, 5)\n", + "print(A2)\n", + "\n", + "A3 = np.random.random_sample((2, 3, 5))\n", + "print(A3)" ] }, { @@ -68,11 +210,42 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 19, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[[0.26235372 0.75747483 0.31045207 0.92916286 0.35010032]\n", + " [0.75464651 0.83587243 0.71857409 0.34163054 0.71456439]\n", + " [0.04489696 0.48562375 0.64408764 0.66442038 0.39403221]]\n", + "\n", + " [[0.99654849 0.62141833 0.451934 0.89301115 0.35072306]\n", + " [0.77615259 0.40548301 0.99171326 0.92226949 0.16813904]\n", + " [0.04280546 0.65113488 0.3078791 0.5553119 0.66103685]]]\n", + "[[[ 0.83372355 -0.43823599 0.43250737 -0.15554991 0.58846496]\n", + " [-0.75817337 0.26027204 -1.14947339 1.28608148 0.48246648]\n", + " [-0.66101259 1.09980256 0.6723016 -0.8258994 -1.25320391]]\n", + "\n", + " [[-1.00026292 0.56642525 -2.68859756 -0.58575723 0.25495492]\n", + " [-1.5777449 -0.52612932 0.85361199 0.42693837 -0.94403173]\n", + " [ 0.21722797 0.50644894 -1.23654657 0.42006698 -0.34651514]]]\n", + "[[[0.77101383 0.9255275 0.84134437 0.76036702 0.80013514]\n", + " [0.17994848 0.34902474 0.39108747 0.66248947 0.16643875]\n", + " [0.0738344 0.60410084 0.36146203 0.82021557 0.62302784]]\n", + "\n", + " [[0.23717904 0.38472514 0.75625165 0.16736728 0.45786044]\n", + " [0.7432222 0.55646538 0.02400635 0.92509301 0.72875658]\n", + " [0.25931357 0.03715614 0.15602546 0.31708151 0.27178115]]]\n" + ] + } + ], "source": [ - "### [your code here]\n" + "### [your code here]\n", + "print(A1)\n", + "print(A2)\n", + "print(A3) " ] }, { @@ -85,11 +258,12 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 36, "metadata": {}, "outputs": [], "source": [ - "### [your code here]\n" + "### [your code here]\n", + "B = np.ones((5, 3, 2))" ] }, { @@ -102,11 +276,38 @@ }, { "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [], + "execution_count": 37, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[[1. 1.]\n", + " [1. 1.]\n", + " [1. 1.]]\n", + "\n", + " [[1. 1.]\n", + " [1. 1.]\n", + " [1. 1.]]\n", + "\n", + " [[1. 1.]\n", + " [1. 1.]\n", + " [1. 1.]]\n", + "\n", + " [[1. 1.]\n", + " [1. 1.]\n", + " [1. 1.]]\n", + "\n", + " [[1. 1.]\n", + " [1. 1.]\n", + " [1. 1.]]]\n" + ] + } + ], "source": [ - "### [your code here]\n" + "### [your code here]\n", + "print(B)" ] }, { @@ -119,11 +320,21 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 22, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n" + ] + } + ], "source": [ - "### [your code here]\n" + "### [your code here]\n", + "Same_Size = A1.size == B.size\n", + "print(Same_Size)" ] }, { @@ -136,11 +347,13 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 24, "metadata": {}, "outputs": [], "source": [ - "### [your code here]\n" + "### [your code here]\n", + "#AB = A1 + B\n", + "#You cant do this because the shapes are not compatible" ] }, { @@ -154,11 +367,21 @@ }, { "cell_type": "code", - "execution_count": 27, - "metadata": {}, - "outputs": [], + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(2, 3, 5)\n" + ] + } + ], "source": [ - "### [your code here]\n" + "### [your code here]\n", + "C = B.transpose(2, 1, 0)\n", + "print(C.shape)" ] }, { @@ -171,11 +394,27 @@ }, { "cell_type": "code", - "execution_count": 28, - "metadata": {}, - "outputs": [], + "execution_count": 40, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[[1.26235372 1.75747483 1.31045207 1.92916286 1.35010032]\n", + " [1.75464651 1.83587243 1.71857409 1.34163054 1.71456439]\n", + " [1.04489696 1.48562375 1.64408764 1.66442038 1.39403221]]\n", + "\n", + " [[1.99654849 1.62141833 1.451934 1.89301115 1.35072306]\n", + " [1.77615259 1.40548301 1.99171326 1.92226949 1.16813904]\n", + " [1.04280546 1.65113488 1.3078791 1.5553119 1.66103685]]]\n" + ] + } + ], "source": [ - "### [your code here]\n" + "### [your code here]\n", + "D = A1 + C\n", + "print(D)" ] }, { @@ -188,12 +427,35 @@ }, { "cell_type": "code", - "execution_count": 29, - "metadata": {}, - "outputs": [], + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[[0.26235372 0.75747483 0.31045207 0.92916286 0.35010032]\n", + " [0.75464651 0.83587243 0.71857409 0.34163054 0.71456439]\n", + " [0.04489696 0.48562375 0.64408764 0.66442038 0.39403221]]\n", + "\n", + " [[0.99654849 0.62141833 0.451934 0.89301115 0.35072306]\n", + " [0.77615259 0.40548301 0.99171326 0.92226949 0.16813904]\n", + " [0.04280546 0.65113488 0.3078791 0.5553119 0.66103685]]]\n", + "[[[1.26235372 1.75747483 1.31045207 1.92916286 1.35010032]\n", + " [1.75464651 1.83587243 1.71857409 1.34163054 1.71456439]\n", + " [1.04489696 1.48562375 1.64408764 1.66442038 1.39403221]]\n", + "\n", + " [[1.99654849 1.62141833 1.451934 1.89301115 1.35072306]\n", + " [1.77615259 1.40548301 1.99171326 1.92226949 1.16813904]\n", + " [1.04280546 1.65113488 1.3078791 1.5553119 1.66103685]]]\n" + ] + } + ], "source": [ "### [your code here]\n", - "\n" + "print(A1)\n", + "print(D)\n", + "#The only diference is A1 has values between 0 and 1 and D has values between 1 and 2 " ] }, { @@ -206,11 +468,27 @@ }, { "cell_type": "code", - "execution_count": 30, - "metadata": {}, - "outputs": [], + "execution_count": 43, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[[0.26235372 0.75747483 0.31045207 0.92916286 0.35010032]\n", + " [0.75464651 0.83587243 0.71857409 0.34163054 0.71456439]\n", + " [0.04489696 0.48562375 0.64408764 0.66442038 0.39403221]]\n", + "\n", + " [[0.99654849 0.62141833 0.451934 0.89301115 0.35072306]\n", + " [0.77615259 0.40548301 0.99171326 0.92226949 0.16813904]\n", + " [0.04280546 0.65113488 0.3078791 0.5553119 0.66103685]]]\n" + ] + } + ], "source": [ - "### [your code here]\n" + "### [your code here]\n", + "E = A1 * C\n", + "print(E)" ] }, { @@ -224,12 +502,27 @@ }, { "cell_type": "code", - "execution_count": 31, - "metadata": {}, - "outputs": [], + "execution_count": 54, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[[ True True True True True]\n", + " [ True True True True True]\n", + " [ True True True True True]]\n", + "\n", + " [[ True True True True True]\n", + " [ True True True True True]\n", + " [ True True True True True]]]\n" + ] + } + ], "source": [ "### [your code here]\n", - "\n" + "Does_A1_equal_D = E == A1\n", + "print(Does_A1_equal_D)\n" ] }, { @@ -243,12 +536,28 @@ }, { "cell_type": "code", - "execution_count": 32, - "metadata": {}, - "outputs": [], + "execution_count": 55, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1.996548487818827\n", + "1.0428054588894584\n", + "1.5667817774534274\n" + ] + } + ], "source": [ "### [your code here]\n", - "\n" + "D_max = D.max()\n", + "D_min = D.min()\n", + "D_mean = D.mean()\n", + "\n", + "print(D_max)\n", + "print(D_min)\n", + "print(D_mean)\n" ] }, { @@ -261,11 +570,27 @@ }, { "cell_type": "code", - "execution_count": 33, - "metadata": {}, - "outputs": [], + "execution_count": 56, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[[0.26235372 0.75747483 0.31045207 0.92916286 0.35010032]\n", + " [0.75464651 0.83587243 0.71857409 0.34163054 0.71456439]\n", + " [0.04489696 0.48562375 0.64408764 0.66442038 0.39403221]]\n", + "\n", + " [[0.99654849 0.62141833 0.451934 0.89301115 0.35072306]\n", + " [0.77615259 0.40548301 0.99171326 0.92226949 0.16813904]\n", + " [0.04280546 0.65113488 0.3078791 0.5553119 0.66103685]]]\n" + ] + } + ], "source": [ - "### [your code here]\n" + "### [your code here]\n", + "F = np.empty(D.shape)\n", + "print(F)" ] }, { @@ -287,11 +612,25 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 61, "metadata": {}, "outputs": [], "source": [ - "### [your code here]\n" + "### [your code here]\n", + "for i in range(D.shape[0]):\n", + " for j in range(D.shape[1]): \n", + " for k in range(D.shape[2]): \n", + " value = D[i][j][k]\n", + " if value == D_min:\n", + " F[i][j][k] = 0\n", + " elif value == D_max:\n", + " F[i][j][k] = 100\n", + " elif value == D_mean:\n", + " F[i][j][k] = 50\n", + " elif D_min < value < D_mean:\n", + " F[i][j][k] = 25\n", + " elif D_mean < value < D_max:\n", + " F[i][j][k] = 75" ] }, { @@ -325,11 +664,34 @@ }, { "cell_type": "code", - "execution_count": 35, - "metadata": {}, - "outputs": [], + "execution_count": 60, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[[1.26235372 1.75747483 1.31045207 1.92916286 1.35010032]\n", + " [1.75464651 1.83587243 1.71857409 1.34163054 1.71456439]\n", + " [1.04489696 1.48562375 1.64408764 1.66442038 1.39403221]]\n", + "\n", + " [[1.99654849 1.62141833 1.451934 1.89301115 1.35072306]\n", + " [1.77615259 1.40548301 1.99171326 1.92226949 1.16813904]\n", + " [1.04280546 1.65113488 1.3078791 1.5553119 1.66103685]]]\n", + "[[[ 25. 75. 25. 75. 25.]\n", + " [ 75. 75. 75. 25. 75.]\n", + " [ 25. 25. 75. 75. 25.]]\n", + "\n", + " [[100. 75. 25. 75. 25.]\n", + " [ 75. 25. 75. 75. 25.]\n", + " [ 0. 75. 25. 25. 75.]]]\n" + ] + } + ], "source": [ - "### [your code here]\n" + "### [your code here]\n", + "print(D)\n", + "print(F)" ] }, { @@ -350,11 +712,43 @@ }, { "cell_type": "code", - "execution_count": 36, - "metadata": {}, - "outputs": [], + "execution_count": 63, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[['B' 'D' 'B' 'D' 'B']\n", + " ['D' 'D' 'D' 'B' 'D']\n", + " ['B' 'B' 'D' 'D' 'B']]\n", + "\n", + " [['D' 'D' 'B' 'D' 'B']\n", + " ['D' 'B' 'D' 'D' 'B']\n", + " ['A' 'D' 'B' 'B' 'D']]]\n" + ] + } + ], "source": [ - "### [your code here]" + "### [your code here]\n", + "F = np.empty(D.shape, dtype=str)\n", + "\n", + "for i in range(D.shape[0]):\n", + " for j in range(D.shape[1]): \n", + " for k in range(D.shape[2]): \n", + " value = D[i][j][k]\n", + " if value == D_min:\n", + " F[i][j][k] = \"A\"\n", + " elif value == D_max:\n", + " F[i][j][k] = \"D\"\n", + " elif value == D_mean:\n", + " F[i][j][k] = \"C\"\n", + " elif D_min < value < D_mean:\n", + " F[i][j][k] = \"B\"\n", + " elif D_mean < value < D_max:\n", + " F[i][j][k] = \"D\"\n", + "\n", + "print(F)" ] } ], @@ -374,7 +768,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.0" + "version": "3.13.3" } }, "nbformat": 4,