Skip to content

Commit

Permalink
deploy: 39df470
Browse files Browse the repository at this point in the history
  • Loading branch information
javlintor committed Nov 14, 2023
1 parent 7278801 commit 72d803f
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 39 deletions.
16 changes: 16 additions & 0 deletions _sources/notebooks/introduction-python/exercises.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,22 @@
"metadata": {
"id": "-xt1nDKN0wuN"
}
},
{
"cell_type": "markdown",
"source": [
":::{exercise} :label: return-none\n",
"Lee [este blog](https://stackoverflow.com/questions/15300550/return-return-none-and-no-return-at-all) sobre en una función que devuelve `None` es mejor\n",
"\n",
"- No incluir `return`\n",
"- Incuir solamente `return`\n",
"- Incluir `return None`\n",
"\n",
"Y pon ejemplos de cuándo deberíamos usar cada uno de ellos."
],
"metadata": {
"id": "HA3ELD5xrOH_"
}
}
],
"metadata": {
Expand Down
13 changes: 13 additions & 0 deletions notebooks/introduction-python/exercises.html
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,19 @@ <h1>Ejercicios de Introducción a Python<a class="headerlink" href="#ejercicios-
</ul>
</section>
</div>
<div class="exercise admonition" id="notebooks/introduction-python/exercises-exercise-5">

<p class="admonition-title"><span class="caption-number">Exercise 46 </span> (:label: return-none)</p>
<section id="exercise-content">
<p>Lee <a class="reference external" href="https://stackoverflow.com/questions/15300550/return-return-none-and-no-return-at-all">este blog</a> sobre en una función que devuelve <code class="docutils literal notranslate"><span class="pre">None</span></code> es mejor</p>
<ul class="simple">
<li><p>No incluir <code class="docutils literal notranslate"><span class="pre">return</span></code></p></li>
<li><p>Incuir solamente <code class="docutils literal notranslate"><span class="pre">return</span></code></p></li>
<li><p>Incluir <code class="docutils literal notranslate"><span class="pre">return</span> <span class="pre">None</span></code></p></li>
</ul>
<p>Y pon ejemplos de cuándo deberíamos usar cada uno de ellos.</p>
</section>
</div>
</section>

<script type="text/x-thebe-config">
Expand Down
2 changes: 1 addition & 1 deletion notebooks/matplotlib/introduction-matplotlib.html
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ <h2>Gráficas simples con <em>plot</em><a class="headerlink" href="#graficas-sim
</div>
<div class="exercise admonition" id="matplotlib-cumsum">

<p class="admonition-title"><span class="caption-number">Exercise 57 </span></p>
<p class="admonition-title"><span class="caption-number">Exercise 58 </span></p>
<section id="exercise-content">
<p>Crea 4 vectores obtenidos de muestras de una variable aleatoria normal de media 0 y desviación típica 1. Pinta en un gráfico la suma acumulada de los cuatro vectores frente al número de sumandos, utilizando diferentes colores y estilos de línea para cada uno. Añade</p>
<ul class="simple">
Expand Down
4 changes: 2 additions & 2 deletions notebooks/numpy/basic-operations.html
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ <h2>Expresiones condicionales vectorizadas con <em>where</em><a class="headerlin
</div>
<div class="exercise admonition" id="basic-operations-masks">

<p class="admonition-title"><span class="caption-number">Exercise 52 </span></p>
<p class="admonition-title"><span class="caption-number">Exercise 53 </span></p>
<section id="exercise-content">
<p>Crea una función que transforme un array para aplicar elemento a elemento la siguiente función</p>
<div class="math notranslate nohighlight">
Expand All @@ -809,7 +809,7 @@ <h2>Expresiones condicionales vectorizadas con <em>where</em><a class="headerlin
</div>
<div class="solution dropdown admonition" id="notebooks/numpy/basic-operations-solution-1">

<p class="admonition-title">Solution to<a class="reference internal" href="#basic-operations-masks"> Exercise 52</a></p>
<p class="admonition-title">Solution to<a class="reference internal" href="#basic-operations-masks"> Exercise 53</a></p>
<section id="solution-content">
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">fun</span><span class="p">(</span><span class="n">arr</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">):</span>
<span class="n">ret</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">select</span><span class="p">(</span>
Expand Down
16 changes: 8 additions & 8 deletions notebooks/numpy/exercises.html
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ <h1>Ejercicios<a class="headerlink" href="#ejercicios" title="Permalink to this
<h2>Convoluciones de arrays<a class="headerlink" href="#convoluciones-de-arrays" title="Permalink to this heading">#</a></h2>
<div class="exercise admonition" id="chapther2-convolution">

<p class="admonition-title"><span class="caption-number">Exercise 53 </span></p>
<p class="admonition-title"><span class="caption-number">Exercise 54 </span></p>
<section id="exercise-content">
<p>Dadas dos funciones de variable real <span class="math notranslate nohighlight">\(f\)</span> y <span class="math notranslate nohighlight">\(g\)</span>, definimos la <a class="reference external" href="https://en.wikipedia.org/wiki/Convolution"><strong>convolución</strong></a> de <span class="math notranslate nohighlight">\(f\)</span> y <span class="math notranslate nohighlight">\(g\)</span> como</p>
<div class="math notranslate nohighlight">
Expand All @@ -486,7 +486,7 @@ <h2>Convoluciones de arrays<a class="headerlink" href="#convoluciones-de-arrays"
</div>
<div class="solution dropdown admonition" id="notebooks/numpy/exercises-solution-1">

<p class="admonition-title">Solution to<a class="reference internal" href="#chapther2-convolution"> Exercise 53</a></p>
<p class="admonition-title">Solution to<a class="reference internal" href="#chapther2-convolution"> Exercise 54</a></p>
<section id="solution-content">
<p>Una primera solución iterando sobre todos las posibles combinaciones de <span class="math notranslate nohighlight">\(i\)</span> y <span class="math notranslate nohighlight">\(j\)</span> para cada <span class="math notranslate nohighlight">\(k\)</span></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">itertools</span> <span class="kn">import</span> <span class="n">product</span>
Expand Down Expand Up @@ -522,7 +522,7 @@ <h2>Convoluciones de arrays<a class="headerlink" href="#convoluciones-de-arrays"
<h2>Procesando imágenes con numpy<a class="headerlink" href="#procesando-imagenes-con-numpy" title="Permalink to this heading">#</a></h2>
<div class="exercise admonition" id="chapter2-images">

<p class="admonition-title"><span class="caption-number">Exercise 54 </span></p>
<p class="admonition-title"><span class="caption-number">Exercise 55 </span></p>
<section id="exercise-content">
<p>Una de las posibles técnicas que existen para comprimir una imagen es utilizar <a class="reference external" href="https://en.wikipedia.org/wiki/Singular_value_decomposition">la descomposición SVD (Singular Value Decomposition)</a> que nos permite expresar una matrix <span class="math notranslate nohighlight">\(A\)</span> de dimensiones <span class="math notranslate nohighlight">\(n\times m\)</span> como un producto</p>
<div class="math notranslate nohighlight">
Expand All @@ -541,7 +541,7 @@ <h2>Procesando imágenes con numpy<a class="headerlink" href="#procesando-imagen
</div>
<div class="solution dropdown admonition" id="notebooks/numpy/exercises-solution-3">

<p class="admonition-title">Solution to<a class="reference internal" href="#chapter2-images"> Exercise 54</a></p>
<p class="admonition-title">Solution to<a class="reference internal" href="#chapter2-images"> Exercise 55</a></p>
<section id="solution-content">
<p>Para visualizar la imagen</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">scipy.misc</span> <span class="kn">import</span> <span class="n">face</span>
Expand Down Expand Up @@ -582,7 +582,7 @@ <h2>Procesando imágenes con numpy<a class="headerlink" href="#procesando-imagen
</div>
<div class="exercise admonition" id="chapter2-images-convolution">

<p class="admonition-title"><span class="caption-number">Exercise 55 </span></p>
<p class="admonition-title"><span class="caption-number">Exercise 56 </span></p>
<section id="exercise-content">
<p>Importa una imagen de tu elección utilizando la función <code class="docutils literal notranslate"><span class="pre">imread</span></code> de la librería <code class="docutils literal notranslate"><span class="pre">cv2</span></code>. Crea un array <code class="docutils literal notranslate"><span class="pre">kernel</span></code> de dimensión <span class="math notranslate nohighlight">\((n, n)\)</span> y realiza la convolución de tu imagen con <code class="docutils literal notranslate"><span class="pre">kernel</span></code> mediante la función <a class="reference external" href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.convolve2d.html#scipy.signal.convolve2d"><code class="docutils literal notranslate"><span class="pre">scipy.signal.convolve2d</span></code></a> (parámetro <code class="docutils literal notranslate"><span class="pre">mode='same'</span></code>). Si tu imagen tiene varios canales para los colores, aplica el mismo kernel a cada canal.</p>
<p>Algunos ejemplos interesantes de kernel pueden ser los siguientes:</p>
Expand Down Expand Up @@ -624,7 +624,7 @@ <h2>Procesando imágenes con numpy<a class="headerlink" href="#procesando-imagen
</div>
<div class="solution dropdown admonition" id="notebooks/numpy/exercises-solution-5">

<p class="admonition-title">Solution to<a class="reference internal" href="#chapter2-images-convolution"> Exercise 55</a></p>
<p class="admonition-title">Solution to<a class="reference internal" href="#chapter2-images-convolution"> Exercise 56</a></p>
<section id="solution-content">
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">cv2</span>
<span class="kn">from</span> <span class="nn">scipy</span> <span class="kn">import</span> <span class="n">signal</span>
Expand Down Expand Up @@ -653,7 +653,7 @@ <h2>Procesando imágenes con numpy<a class="headerlink" href="#procesando-imagen
<h2>Regresión Lineal<a class="headerlink" href="#regresion-lineal" title="Permalink to this heading">#</a></h2>
<div class="exercise admonition" id="chapter2-linear-regression">

<p class="admonition-title"><span class="caption-number">Exercise 56 </span></p>
<p class="admonition-title"><span class="caption-number">Exercise 57 </span></p>
<section id="exercise-content">
<p>Considera un modelo de regresión lineal que consiste en estimar una variable <span class="math notranslate nohighlight">\(y\)</span> como una suma ponderada de un cojunto de variables regresoras</p>
<div class="math notranslate nohighlight">
Expand Down Expand Up @@ -726,7 +726,7 @@ <h2>Regresión Lineal<a class="headerlink" href="#regresion-lineal" title="Perma
</div>
<div class="solution dropdown admonition" id="notebooks/numpy/exercises-solution-7">

<p class="admonition-title">Solution to<a class="reference internal" href="#chapter2-linear-regression"> Exercise 56</a></p>
<p class="admonition-title">Solution to<a class="reference internal" href="#chapter2-linear-regression"> Exercise 57</a></p>
<section id="solution-content">
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">RegresionLineal</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
Expand Down
10 changes: 5 additions & 5 deletions notebooks/numpy/index-slicing.html
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ <h2>Indexado y <em>slicing</em><a class="headerlink" href="#indexado-y-slicing"
</div>
<div class="exercise admonition" id="introduction-numpy-indexing">

<p class="admonition-title"><span class="caption-number">Exercise 48 </span></p>
<p class="admonition-title"><span class="caption-number">Exercise 49 </span></p>
<section id="exercise-content">
<p>Devuelve el número 813 indexando el array <code class="docutils literal notranslate"><span class="pre">np.arange(2100).reshape((25,</span> <span class="pre">6,</span> <span class="pre">7,</span> <span class="pre">2))</span></code>.</p>
</section>
Expand Down Expand Up @@ -847,7 +847,7 @@ <h3>Indexado usando <em>slices</em><a class="headerlink" href="#indexado-usando-
</div>
<div class="exercise admonition" id="index-slicing-3x4x2">

<p class="admonition-title"><span class="caption-number">Exercise 49 </span></p>
<p class="admonition-title"><span class="caption-number">Exercise 50 </span></p>
<section id="exercise-content">
<p>Crea un array tridimensional de dimensiones <span class="math notranslate nohighlight">\((3, 4, 2)\)</span> y obtén el subarray indicada en la figura (<code class="docutils literal notranslate"><span class="pre">shape</span> <span class="pre">=</span> <span class="pre">(1,</span> <span class="pre">2)</span></code>). Obtén también un subarray a tu elección de dimensiones <span class="math notranslate nohighlight">\((2, 3, 1)\)</span>.</p>
<div style="display: flex; align-items: center;
Expand Down Expand Up @@ -1096,7 +1096,7 @@ <h3>Indexado con booleanos<a class="headerlink" href="#indexado-con-booleanos" t
</div>
<div class="exercise admonition" id="index-slicing-bool">

<p class="admonition-title"><span class="caption-number">Exercise 50 </span></p>
<p class="admonition-title"><span class="caption-number">Exercise 51 </span></p>
<section id="exercise-content">
<p>Devuelve las filas de <code class="docutils literal notranslate"><span class="pre">data</span></code> correspondientes a aquellos nombres que empiecen por «B» o «J». Puedes utilizar la función <code class="docutils literal notranslate"><span class="pre">np.char.startswith</span></code>.</p>
</section>
Expand Down Expand Up @@ -1130,7 +1130,7 @@ <h3>Indexado con booleanos<a class="headerlink" href="#indexado-con-booleanos" t
</div>
<div class="exercise admonition" id="index-slicing-flip">

<p class="admonition-title"><span class="caption-number">Exercise 51 </span></p>
<p class="admonition-title"><span class="caption-number">Exercise 52 </span></p>
<section id="exercise-content">
<p>Crea una función <code class="docutils literal notranslate"><span class="pre">flip</span></code> que tome como inputs un array <code class="docutils literal notranslate"><span class="pre">arr</span></code> y un número entero positivo <code class="docutils literal notranslate"><span class="pre">i</span></code> e <em>invierta</em> el eje i-ésimo, es decir, si la dimensión del eje <span class="math notranslate nohighlight">\(i\)</span> vale <span class="math notranslate nohighlight">\(d_i\)</span>, la transformación lleva el elemento con índice <span class="math notranslate nohighlight">\((x_1, \dots, x_i, \dots, x_n)\)</span> en <span class="math notranslate nohighlight">\((x_1, \dots, x_i^*, \dots, x_n)\)</span> donde <span class="math notranslate nohighlight">\(x_i + x_i^* = d_i + 1\)</span></p>
<p>Por ejemplo,</p>
Expand All @@ -1152,7 +1152,7 @@ <h3>Indexado con booleanos<a class="headerlink" href="#indexado-con-booleanos" t
</div>
<div class="solution dropdown admonition" id="notebooks/numpy/index-slicing-solution-4">

<p class="admonition-title">Solution to<a class="reference internal" href="#index-slicing-flip"> Exercise 51</a></p>
<p class="admonition-title">Solution to<a class="reference internal" href="#index-slicing-flip"> Exercise 52</a></p>
<section id="solution-content">
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">flip</span><span class="p">(</span><span class="n">arr</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">,</span> <span class="n">i</span><span class="p">:</span> <span class="nb">int</span><span class="p">):</span>
<span class="n">default_slice</span> <span class="o">=</span> <span class="nb">slice</span><span class="p">(</span><span class="kc">None</span><span class="p">)</span>
Expand Down
4 changes: 2 additions & 2 deletions notebooks/numpy/introduction-numpy.html
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ <h3>Homogeneidad<a class="headerlink" href="#homogeneidad" title="Permalink to t
<p><img alt="picture" src="https://drive.google.com/uc?id=1Py65cUUWZMph4JOZe0qZNh_PjsFkaZ6x" /></p>
<div class="exercise admonition" id="introduction-numpy-ndim">

<p class="admonition-title"><span class="caption-number">Exercise 46 </span></p>
<p class="admonition-title"><span class="caption-number">Exercise 47 </span></p>
<section id="exercise-content">
<p>Crea un array de numpy de dimensión (4, 1, 3) a partir de listas.</p>
</section>
Expand Down Expand Up @@ -916,7 +916,7 @@ <h2>Creación de arrays<a class="headerlink" href="#creacion-de-arrays" title="P
</div>
<div class="exercise admonition" id="introduction-numpy-diag">

<p class="admonition-title"><span class="caption-number">Exercise 47 </span></p>
<p class="admonition-title"><span class="caption-number">Exercise 48 </span></p>
<section id="exercise-content">
<p>Crea un array de enteros tridimensional en el que cada eje tenga <code class="docutils literal notranslate"><span class="pre">n</span></code> elementos, con -1 en la diagonal y 1 en el resto</p>
</section>
Expand Down
10 changes: 5 additions & 5 deletions notebooks/pandas/introduction-pandas.html
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ <h2>Series<a class="headerlink" href="#series" title="Permalink to this heading"
</div>
<div class="exercise admonition" id="pandas-series">

<p class="admonition-title"><span class="caption-number">Exercise 58 </span></p>
<p class="admonition-title"><span class="caption-number">Exercise 59 </span></p>
<section id="exercise-content">
<p>Carga las series <code class="docutils literal notranslate"><span class="pre">city_mpg</span></code> y <code class="docutils literal notranslate"><span class="pre">highway_mpg</span></code> con el siguiente código</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">url</span> <span class="o">=</span> <span class="s2">&quot;https://github.com/mattharrison/datasets/raw/master/data/vehicles.csv.zip&quot;</span>
Expand Down Expand Up @@ -3058,7 +3058,7 @@ <h3>Resumen de algunas maneras de crear un <em>DataFrame</em>:<a class="headerli
</ul>
<div class="exercise admonition" id="pandas-create-df">

<p class="admonition-title"><span class="caption-number">Exercise 59 </span></p>
<p class="admonition-title"><span class="caption-number">Exercise 60 </span></p>
<section id="exercise-content">
<p>Crea un DataFrame de 5 filas y columnas <code class="docutils literal notranslate"><span class="pre">Nombre</span></code>, <code class="docutils literal notranslate"><span class="pre">Edad</span></code>, <code class="docutils literal notranslate"><span class="pre">Peso</span></code> con alguno de los métodos mencionados arriba.</p>
</section>
Expand Down Expand Up @@ -4862,7 +4862,7 @@ <h3>Selección con loc e iloc<a class="headerlink" href="#seleccion-con-loc-e-il
</div>
<div class="exercise admonition" id="pandas-loc-iloc">

<p class="admonition-title"><span class="caption-number">Exercise 60 </span></p>
<p class="admonition-title"><span class="caption-number">Exercise 61 </span></p>
<section id="exercise-content">
<p>Carga el siguiente dataframe</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">url</span> <span class="o">=</span> <span class="s2">&quot;https://github.com/mattharrison/datasets/raw/master/data/vehicles.csv.zip&quot;</span>
Expand Down Expand Up @@ -5993,7 +5993,7 @@ <h3>Aplicación de funciones a las «vectorizadas»<a class="headerlink" href="#
</div>
<div class="exercise admonition" id="pandas-vfunctions">

<p class="admonition-title"><span class="caption-number">Exercise 61 </span></p>
<p class="admonition-title"><span class="caption-number">Exercise 62 </span></p>
<section id="exercise-content">
<p>Selecciona las columnas numéricas de <code class="docutils literal notranslate"><span class="pre">df</span></code> con el método <code class="docutils literal notranslate"><span class="pre">select_dtypes</span></code> y normaliza las columnas.</p>
</section>
Expand Down Expand Up @@ -7660,7 +7660,7 @@ <h2>Funciones estadísticas descriptivas<a class="headerlink" href="#funciones-e
</div>
<div class="exercise admonition" id="pandas-housing">

<p class="admonition-title"><span class="caption-number">Exercise 62 </span></p>
<p class="admonition-title"><span class="caption-number">Exercise 63 </span></p>
<section id="exercise-content">
<p>Descarga el dataframe <code class="docutils literal notranslate"><span class="pre">housing</span></code> utilizando el siguiente código</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">os</span>
Expand Down
Loading

0 comments on commit 72d803f

Please sign in to comment.