Skip to content

Commit

Permalink
Fix small issues (#55)
Browse files Browse the repository at this point in the history
Fix lots of small things noted during a very close look by @apitarch29 --many thanks for reporting!
  • Loading branch information
hmgaudecker authored Nov 28, 2024
1 parent 460f1f9 commit 16e803f
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 97 deletions.
106 changes: 49 additions & 57 deletions src/epp_topics/git/collaboration/objectives_materials.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -177,57 +177,6 @@
" },\n",
" ],\n",
" },\n",
"]\n",
"\n",
"display_quiz(content)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Cards"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"remove-input"
]
},
"outputs": [],
"source": [
"content = [\n",
" {\n",
" \"name\": \"Intro\",\n",
" \"front\": \"What are the typical steps for \\\n",
" creating a new feature branch?\",\n",
" \"back\": \"Let's go through them step by step \\\n",
" (click on next in the bottom right).\",\n",
" },\n",
" {\n",
" \"name\": \"git checkout main\",\n",
" \"front\": \"git checkout main\",\n",
" \"back\": \"This command switches to the main branch. \\\n",
" We need to switch to the main branch and update it \\\n",
" before creating a new branch, to make sure that \\\n",
" we start working from the latest version \\\n",
" of the code.\",\n",
" },\n",
" {\n",
" \"name\": \"git pull\",\n",
" \"front\": \"git pull\",\n",
" \"back\": \"This command pulls the latest changes \\\n",
" from the remote repository.\",\n",
" },\n",
" {\n",
" \"name\": \"git checkout -b feature_branch\",\n",
" \"front\": \"git checkout -b feature_branch\",\n",
" \"back\": \"This command creates a new branch called \\\n",
" feature_branch and switches to it.\",\n",
" },\n",
" {\n",
" \"question\": \"`git push` ...\",\n",
" \"type\": \"multiple_choice\",\n",
Expand Down Expand Up @@ -306,18 +255,61 @@
" },\n",
"]\n",
"\n",
"\n",
"from jupytercards import display_flashcards\n",
"\n",
"display_flashcards(content)"
"display_quiz(content)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Cards"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": [
"remove-input"
]
},
"outputs": [],
"source": []
"source": [
"content = [\n",
" {\n",
" \"name\": \"Intro\",\n",
" \"front\": \"What are the typical steps for \\\n",
" creating a new feature branch?\",\n",
" \"back\": \"Let's go through them step by step \\\n",
" (click on next in the bottom right).\",\n",
" },\n",
" {\n",
" \"name\": \"git checkout main\",\n",
" \"front\": \"git checkout main\",\n",
" \"back\": \"This command switches to the main branch. \\\n",
" We need to switch to the main branch and update it \\\n",
" before creating a new branch, to make sure that \\\n",
" we start working from the latest version \\\n",
" of the code.\",\n",
" },\n",
" {\n",
" \"name\": \"git pull\",\n",
" \"front\": \"git pull\",\n",
" \"back\": \"This command pulls the latest changes \\\n",
" from the remote repository.\",\n",
" },\n",
" {\n",
" \"name\": \"git checkout -b feature_branch\",\n",
" \"front\": \"git checkout -b feature_branch\",\n",
" \"back\": \"This command creates a new branch called \\\n",
" feature_branch and switches to it.\",\n",
" },\n",
"]\n",
"\n",
"from jupytercards import display_flashcards\n",
"\n",
"display_flashcards(content)"
]
}
],
"metadata": {
Expand Down
4 changes: 2 additions & 2 deletions src/epp_topics/git/introduction/objectives_materials.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"\n",
"Download the [slides](git-introduction.pdf).\n",
"\n",
"[Paper](https://www.zbw.eu/econis-archiv/bitstream/11159/268088/1/EBP07471872X_0.pdf)\n",
"documenting trends in number of authors per econ paper\n",
"[Paper](https://www.aeaweb.org/articles?id=10.1257/jep.10.3.153)\n",
"documenting trends in number of authors per econ paper.\n",
" \n",
"\n",
"## Quiz\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,7 @@
"\n",
"Download the [slides](pandas-creating_variables.pdf).\n",
"\n",
"\n",
"\n",
"## Further Reading\n",
"\n",
"\n",
"\n",
"## Quiz"
"## Quiz\n"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lineplot.svg
scatterplot.svg

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,15 @@ year
>>> pd.options.plotting.backend = "plotly"
>>> df.groupby("year")["life_exp"].mean().plot()
```
<img src="/lineplot.png" class="rounded" width="400"/>
<img src="/lineplot.svg" class="rounded" width="400"/>

</div>
<div>

- Any Series has a `.plot` method

- Any Series has a `.hist` method

- Summary statistics based on groupby return Series which can again be plotted

</div>
Expand All @@ -356,13 +358,15 @@ year
>>> df.plot.scatter(x="year", y="life_exp",
color="country")
```
<img src="/scatterplot.png" class="rounded" width="400"/>
<img src="/scatterplot.svg" class="rounded" width="400"/>

</div>
<div>

- Any DataFrame has a `.plot` method

- Defaults to line plot, can access `.scatter` and many more

- Notebook gives you interactive plots

</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
from pathlib import Path

import pandas as pd
import plotly.express as px

from epp_topics.config import SITE_SOURCE_DIR
import pytask

pd.options.plotting.backend = "plotly"


LINEPLOT = SITE_SOURCE_DIR / "pandas" / "inspecting_and_summarizing" / "lineplot.png"

SCATTERPLOT = (
SITE_SOURCE_DIR / "pandas" / "inspecting_and_summarizing" / "scatterplot.png"
)


def task_create_lineplot(produces=LINEPLOT):
@pytask.mark.try_first
def task_create_lineplot(produces=Path() / "public" / "lineplot.svg"):
df = px.data.gapminder()
df = df.rename(
columns={
"lifeExp": "life_exp",
},
)
fig = df.groupby("year")["life_exp"].mean().plot(template="plotly_dark")
fig = (
df.groupby("year")["life_exp"]
.mean()
.plot(
template="presentation" # "+plotly_dark"
)
)
fig.write_image(produces)


def task_create_scatterplot(produces=SCATTERPLOT):
@pytask.mark.try_first
def task_create_scatterplot(produces=Path() / "public" / "scatterplot.svg"):
df = px.data.gapminder()
df = df.rename(
columns={
Expand All @@ -35,6 +37,6 @@ def task_create_scatterplot(produces=SCATTERPLOT):
x="year",
y="life_exp",
color="country",
template="plotly_dark",
template="presentation", # "+plotly_dark"
)
fig.write_image(produces)
10 changes: 5 additions & 5 deletions src/epp_topics/plotting/what_to_plot/objectives_materials.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@
"\n",
"Some additional resources:\n",
"\n",
"- [Better Data\n",
" Visualizations](https://policyviz.com/pv_books/better-data-visualizations-a-guide-for-scholars-researchers-and-wonks/)\n",
" (Jonathan Schwabish): Very extensive, with direct focus on science/economics. Some\n",
" material in the screencast based on that.\n",
"- Chapter 7 of [Calling Bullshit](https://www.callingbullshit.org/) (Carl Bergstrom &\n",
" Jevin West). Light read, important insights in particular how popular visualisations\n",
" often try to mislead in more or less subtle ways. Also has some general insights into\n",
" how to think about graphics. Some of the examples are [available\n",
" online](https://www.callingbullshit.org/tools.html)\n",
"- [How Charts Lie](http://www.thefunctionalart.com/p/reviews.html) (Alberto Cairo).\n",
"- [How Charts Lie](https://www.amazon.com/gp/product/0393358429) (Alberto Cairo).\n",
" Similar to Chapter 7 of Calling Bullshit, but the entire book is devoted to\n",
" visualisations.\n",
"- [Better Data\n",
" Visualizations](https://policyviz.com/pv_books/better-data-visualizations-a-guide-for-scholars-researchers-and-wonks/)\n",
" (Jonathan Schwabish): Very extensive, with direct focus on science/economics. Some\n",
" material in the screencast based on that.\n",
"- [The Functional Art](http://www.thefunctionalart.com/p/about-book.html) (Alberto\n",
" Cairo) and [Show Me the Numbers](http://www.perceptualedge.com/library.php) (Stephen\n",
" Few). Authoritative References if you want to become a data viz pro. Alberto Cairo has\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,10 @@
"\n",
"Download the [slides](scientific_computing-randomness.pdf).\n",
"\n",
"- This [Blogpost](https://albertcthomas.github.io/good-practices-random-number-generators/) explains some of the reasons behind our best practices.\n",
"- If you find the \"legacy\" version of the NumPy random number generator somewhere (i.e., calling `np.random.seed`. E.g., LLMs are trained on lots of data using that...), a clear exposition of why you want to use the suggested version can be found [here](https://builtin.com/data-science/numpy-random-seed).\n",
"\n",
"\n",
"\n",
"\n",
"- This [Blogpost](https://albertcthomas.github.io/good-practices-random-number-generators/) explains some of the reasons behind our best practices. \n",
"\n",
"\n",
"## Quiz"
"## Quiz\n"
]
},
{
Expand All @@ -51,7 +47,7 @@
"from epp_topics.quiz_utilities import display_quiz\n",
"\n",
"content = {\n",
" \"To set a good seed which of the following lines of code would zou use?\": {\n",
" \"To set a good seed which of the following lines of code would you use?\": {\n",
" \"np.random.seed\": False,\n",
" \"np.random.default_rng\": False,\n",
" \"np.random.default_rng(6943)\": True,\n",
Expand All @@ -60,7 +56,7 @@
" \"A seed is nice to have, but not essential\": False,\n",
" \"For the purpose of reproducible research\": True,\n",
" \"To help obtain nicer results\": False,\n",
" \"To make sure that two random extraction will \\\n",
" \"To make sure that two random extractions will \\\n",
" not yield the same outcome\": False,\n",
" },\n",
" \"Which of the following applies to seeds?\": {\n",
Expand Down

0 comments on commit 16e803f

Please sign in to comment.