Skip to content

Commit

Permalink
deploy: d8eb423
Browse files Browse the repository at this point in the history
  • Loading branch information
baniasbaabe committed Feb 11, 2024
1 parent e10541d commit 8115573
Show file tree
Hide file tree
Showing 7 changed files with 232 additions and 1 deletion.
50 changes: 50 additions & 0 deletions _sources/book/codequality/automation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,56 @@
"source": [
"!nox"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Update Your Dependencies Automatically with `pyup`"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Do you need an easy way to update your project's dependencies?\n",
"\n",
"Try `pyup`.\n",
"\n",
"`pyup` goes through your dependency files and searches for new package versions.\n",
"\n",
"It will then create a new branch in your repository, a new commit for every update and a pull request containing all commits.\n",
"\n",
"You only need to provide an access token (from GitHub or GitLab) and the repository name."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pip install pyupio"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pyup --repo=username/repo --user-token=<YOUR_TOKEN> --initial # After running the first time, you can remove the --initial flag"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# gitlab.com:\n",
"!pyup --provider gitlab --repo=username/repo --user-token=<YOUR_TOKEN>"
]
}
],
"metadata": {
Expand Down
43 changes: 43 additions & 0 deletions _sources/book/jupyternotebook/Chapter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,49 @@
"%%ai chatgpt\n",
"Provide a hello world function in Python"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Modern Alternative to Jupyter Notebook"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Forget Jupyter Notebooks.\n",
"\n",
"`Marimo` Notebook is the future.\n",
"\n",
"`Marimo` Notebooks are a git-friendly, reactive and interactive alternative to Jupyter Notebooks by providing the following features:\n",
"\n",
"- Automatically re-running affected cells when changing something\n",
"- Notebooks are executed in a deterministic order, with no hidden state\n",
"- Easily deployable\n",
"- Interactive elements\n",
"\n",
"Just give it a try, it's open-source too!"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pip install marimo"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!marimo edit"
]
}
],
"metadata": {
Expand Down
45 changes: 45 additions & 0 deletions _sources/book/pythontricks/Chapter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,51 @@
" def push(self, item: T) -> None:\n",
" self.items.append(item)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Enumerations in Python"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To make your Python Code cleaner, use `Enums`.\n",
"\n",
"`Enums` (or enumerations) are a way to represent a set of named values as symbolic names.\n",
"\n",
"It provides a way to work with meaningful names instead of raw integers or weird string constants.\n",
"\n",
"Python supports enums with its standard library."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Option 1\n",
"from enum import Enum, auto\n",
"\n",
"class Color(Enum):\n",
" RED = 1\n",
" GREEN = 2\n",
" BLUE = 3\n",
" \n",
"print(Color.RED.value) # Output: 1\n",
"\n",
"# Option 2: auto() assigns unique values starting by 1\n",
"class Status(Enum):\n",
" PENDING = auto()\n",
" APPROVED = auto()\n",
" REJECTED = auto()\n",
" \n",
"print(Status.PENDING.value) # Output: 1"
]
}
],
"metadata": {
Expand Down
32 changes: 32 additions & 0 deletions book/codequality/automation.html
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ <h2> Contents </h2>
<ul class="visible nav section-nav flex-column">
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#automate-bash-commands-with-makefile">1.1.1. Automate Bash Commands with <code class="docutils literal notranslate"><span class="pre">Makefile</span></code></a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#automate-testing-with-nox">1.1.2. Automate Testing with Nox</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#update-your-dependencies-automatically-with-pyup">1.1.3. Update Your Dependencies Automatically with <code class="docutils literal notranslate"><span class="pre">pyup</span></code></a></li>
</ul>
</nav>
</div>
Expand Down Expand Up @@ -502,6 +503,36 @@ <h2><span class="section-number">1.1.2. </span>Automate Testing with Nox<a class
</div>
</div>
</section>
<section id="update-your-dependencies-automatically-with-pyup">
<h2><span class="section-number">1.1.3. </span>Update Your Dependencies Automatically with <code class="docutils literal notranslate"><span class="pre">pyup</span></code><a class="headerlink" href="#update-your-dependencies-automatically-with-pyup" title="Permalink to this heading">#</a></h2>
<p>Do you need an easy way to update your project’s dependencies?</p>
<p>Try <code class="docutils literal notranslate"><span class="pre">pyup</span></code>.</p>
<p><code class="docutils literal notranslate"><span class="pre">pyup</span></code> goes through your dependency files and searches for new package versions.</p>
<p>It will then create a new branch in your repository, a new commit for every update and a pull request containing all commits.</p>
<p>You only need to provide an access token (from GitHub or GitLab) and the repository name.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span>!pip install pyupio
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span>!pyup --repo=username/repo --user-token=&lt;YOUR_TOKEN&gt; --initial # After running the first time, you can remove the --initial flag
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span># gitlab.com:
!pyup --provider gitlab --repo=username/repo --user-token=&lt;YOUR_TOKEN&gt;
</pre></div>
</div>
</div>
</div>
</section>
</section>

<script type="text/x-thebe-config">
Expand Down Expand Up @@ -573,6 +604,7 @@ <h2><span class="section-number">1.1.2. </span>Automate Testing with Nox<a class
<ul class="visible nav section-nav flex-column">
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#automate-bash-commands-with-makefile">1.1.1. Automate Bash Commands with <code class="docutils literal notranslate"><span class="pre">Makefile</span></code></a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#automate-testing-with-nox">1.1.2. Automate Testing with Nox</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#update-your-dependencies-automatically-with-pyup">1.1.3. Update Your Dependencies Automatically with <code class="docutils literal notranslate"><span class="pre">pyup</span></code></a></li>
</ul>
</nav></div>

Expand Down
29 changes: 29 additions & 0 deletions book/jupyternotebook/Chapter.html
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ <h2> Contents </h2>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#create-and-reuse-juptyer-notebook-templates">3.1.7. Create and Reuse Juptyer Notebook Templates</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#remove-output-cells-automatically-with-nbstripout">3.1.8. Remove Output Cells Automatically with <code class="docutils literal notranslate"><span class="pre">nbstripout</span></code></a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#bring-llms-into-your-notebook-with-jupyter-ai">3.1.9. Bring LLMs Into Your Notebook with <code class="docutils literal notranslate"><span class="pre">jupyter-ai</span></code></a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#modern-alternative-to-jupyter-notebook">3.1.10. Modern Alternative to Jupyter Notebook</a></li>
</ul>
</nav>
</div>
Expand Down Expand Up @@ -777,6 +778,33 @@ <h2><span class="section-number">3.1.9. </span>Bring LLMs Into Your Notebook wit
</div>
</div>
</section>
<section id="modern-alternative-to-jupyter-notebook">
<h2><span class="section-number">3.1.10. </span>Modern Alternative to Jupyter Notebook<a class="headerlink" href="#modern-alternative-to-jupyter-notebook" title="Permalink to this heading">#</a></h2>
<p>Forget Jupyter Notebooks.</p>
<p><code class="docutils literal notranslate"><span class="pre">Marimo</span></code> Notebook is the future.</p>
<p><code class="docutils literal notranslate"><span class="pre">Marimo</span></code> Notebooks are a git-friendly, reactive and interactive alternative to Jupyter Notebooks by providing the following features:</p>
<ul class="simple">
<li><p>Automatically re-running affected cells when changing something</p></li>
<li><p>Notebooks are executed in a deterministic order, with no hidden state</p></li>
<li><p>Easily deployable</p></li>
<li><p>Interactive elements</p></li>
</ul>
<p>Just give it a try, it’s open-source too!</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span>!pip install marimo
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span>!marimo edit
</pre></div>
</div>
</div>
</div>
</section>
</section>

<script type="text/x-thebe-config">
Expand Down Expand Up @@ -855,6 +883,7 @@ <h2><span class="section-number">3.1.9. </span>Bring LLMs Into Your Notebook wit
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#create-and-reuse-juptyer-notebook-templates">3.1.7. Create and Reuse Juptyer Notebook Templates</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#remove-output-cells-automatically-with-nbstripout">3.1.8. Remove Output Cells Automatically with <code class="docutils literal notranslate"><span class="pre">nbstripout</span></code></a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#bring-llms-into-your-notebook-with-jupyter-ai">3.1.9. Bring LLMs Into Your Notebook with <code class="docutils literal notranslate"><span class="pre">jupyter-ai</span></code></a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#modern-alternative-to-jupyter-notebook">3.1.10. Modern Alternative to Jupyter Notebook</a></li>
</ul>
</nav></div>

Expand Down
32 changes: 32 additions & 0 deletions book/pythontricks/Chapter.html
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ <h2> Contents </h2>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#optimize-your-python-objects-with-slots">10.1.22. Optimize Your Python Objects with <code class="docutils literal notranslate"><span class="pre">__slots__</span></code></a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#modify-print-statements">10.1.23. Modify Print Statements</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#type-variables-in-python-3-12">10.1.24. Type Variables in Python 3.12</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#enumerations-in-python">10.1.25. Enumerations in Python</a></li>
</ul>
</nav>
</div>
Expand Down Expand Up @@ -1031,6 +1032,36 @@ <h2><span class="section-number">10.1.24. </span>Type Variables in Python 3.12<a
</div>
</div>
</section>
<section id="enumerations-in-python">
<h2><span class="section-number">10.1.25. </span>Enumerations in Python<a class="headerlink" href="#enumerations-in-python" title="Permalink to this heading">#</a></h2>
<p>To make your Python Code cleaner, use <code class="docutils literal notranslate"><span class="pre">Enums</span></code>.</p>
<p><code class="docutils literal notranslate"><span class="pre">Enums</span></code> (or enumerations) are a way to represent a set of named values as symbolic names.</p>
<p>It provides a way to work with meaningful names instead of raw integers or weird string constants.</p>
<p>Python supports enums with its standard library.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># Option 1</span>
<span class="kn">from</span> <span class="nn">enum</span> <span class="kn">import</span> <span class="n">Enum</span><span class="p">,</span> <span class="n">auto</span>

<span class="k">class</span> <span class="nc">Color</span><span class="p">(</span><span class="n">Enum</span><span class="p">):</span>
<span class="n">RED</span> <span class="o">=</span> <span class="mi">1</span>
<span class="n">GREEN</span> <span class="o">=</span> <span class="mi">2</span>
<span class="n">BLUE</span> <span class="o">=</span> <span class="mi">3</span>

<span class="nb">print</span><span class="p">(</span><span class="n">Color</span><span class="o">.</span><span class="n">RED</span><span class="o">.</span><span class="n">value</span><span class="p">)</span> <span class="c1"># Output: 1</span>

<span class="c1"># Option 2: auto() assigns unique values starting by 1</span>
<span class="k">class</span> <span class="nc">Status</span><span class="p">(</span><span class="n">Enum</span><span class="p">):</span>
<span class="n">PENDING</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span>
<span class="n">APPROVED</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span>
<span class="n">REJECTED</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span>

<span class="nb">print</span><span class="p">(</span><span class="n">Status</span><span class="o">.</span><span class="n">PENDING</span><span class="o">.</span><span class="n">value</span><span class="p">)</span> <span class="c1"># Output: 1</span>
</pre></div>
</div>
</div>
</div>
</section>
</section>

<script type="text/x-thebe-config">
Expand Down Expand Up @@ -1124,6 +1155,7 @@ <h2><span class="section-number">10.1.24. </span>Type Variables in Python 3.12<a
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#optimize-your-python-objects-with-slots">10.1.22. Optimize Your Python Objects with <code class="docutils literal notranslate"><span class="pre">__slots__</span></code></a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#modify-print-statements">10.1.23. Modify Print Statements</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#type-variables-in-python-3-12">10.1.24. Type Variables in Python 3.12</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#enumerations-in-python">10.1.25. Enumerations in Python</a></li>
</ul>
</nav></div>

Expand Down
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

0 comments on commit 8115573

Please sign in to comment.