Skip to content

Commit

Permalink
Fix units and harmonize documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhuppmann committed Jan 14, 2025
1 parent 08dec91 commit 0fa8580
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
26 changes: 17 additions & 9 deletions tutorial/transport/0_transport-tutorial_platform-setup.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@
"id": "b6209e20-9979-4f3b-b6b7-fe37a1c09366",
"metadata": {},
"source": [
"## Defining `Unit`s in the database backend\n",
"## Defining units in the platform and database\n",
"\n",
"The **ixmp4** package requires that `Unit`s are defined explicitly before adding data using them.\n",
"The **ixmp4** package requires that units are defined explicitly before adding data using them.\n",
"\n",
"The transport tutorial uses the units \"cases\", \"km\" and \"USD/km\"."
"The transport tutorial uses the units \"cases\", \"1000 miles\" and \"dollars per case per 1000 miles\"."
]
},
{
Expand All @@ -97,7 +97,7 @@
"metadata": {},
"outputs": [],
"source": [
"for unit in [\"cases\", \"km\", \"USD/km\"]:\n",
"for unit in [\"cases\", \"1000 miles\", \"dollars per case per 1000 miles\"]:\n",
" platform.units.create(unit)"
]
},
Expand Down Expand Up @@ -126,7 +126,7 @@
"source": [
"<div class=\"alert alert-warning\">\n",
"\n",
"Defining a `Unit` again (i.e., creating one that is already defined in the database) will raise an error!\n",
"Defining an **ixmp4.Unit** again (i.e., creating one that is already defined in the database) will raise an error!\n",
"\n",
"</div>"
]
Expand All @@ -136,9 +136,9 @@
"id": "1e7f631c-67d5-4170-858d-c96636c5e765",
"metadata": {},
"source": [
"One reason for defining `Unit`s explicitly is so that we can assign doc-strings to them.\n",
"One reason for defining units explicitly is so that we can assign docstrings to them.\n",
"\n",
"First, we get a specific `ixmp4.Unit` from the platform. Then, we add a docstring. Third, we illustrate how to retrieve the docstring. "
"First, we get a specific **ixmp4.Unit** from the platform. Then, we add a docstring. Third, we illustrate how to retrieve the docstring. "
]
},
{
Expand All @@ -159,7 +159,7 @@
"metadata": {},
"outputs": [],
"source": [
"cases.docs = \"Unit of a good produced at plants and consumed at markets\""
"cases.docs = \"Unit of a good produced at canning plants and consumed at markets\""
]
},
{
Expand Down Expand Up @@ -189,12 +189,20 @@
"\n",
"Run the following in the command-line:\n",
"```\n",
"ixmp4 platforms delete transport-tutorial\n",
"ixmp4 platforms remove transport-tutorial\n",
"```\n",
"\n",
"The prompt will ask whether you also want to delete the SQLite database file from your computer, \n",
"answer `y` for a complete deletion."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9395354e-2a0a-45f1-b819-34af7d925805",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
16 changes: 8 additions & 8 deletions tutorial/transport/1_transport-tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
"metadata": {},
"outputs": [],
"source": [
"i.docs = \"Canning Plants\""
"i.docs = \"Canning plants\""
]
},
{
Expand Down Expand Up @@ -236,7 +236,7 @@
"outputs": [],
"source": [
"a = run.optimization.parameters.create(name=\"a\", constrained_to_indexsets=[\"i\"])\n",
"a.docs = \"Capacity of plant i\"\n",
"a.docs = \"Capacity of canning plant i\"\n",
"\n",
"a_data = {\n",
" \"i\": [\"seattle\", \"san-diego\"],\n",
Expand Down Expand Up @@ -333,7 +333,7 @@
" \"i\": [\"seattle\", \"seattle\", \"seattle\", \"san-diego\"],\n",
" \"j\": [\"new-york\", \"chicago\", \"topeka\", \"new-york\"],\n",
" \"values\": [2.5, 1.7, 1.8, 2.5],\n",
" \"units\": [\"km\", \"km\", \"km\", \"km\"],\n",
" \"units\": [\"1000 miles\", \"1000 miles\", \"1000 miles\", \"1000 miles\"],\n",
"}\n",
"d.add(d_data)"
]
Expand All @@ -351,8 +351,8 @@
"metadata": {},
"outputs": [],
"source": [
"d.add({\"i\": [\"san-diego\"], \"j\": [\"chicago\"], \"values\": [1.8], \"units\": [\"km\"]})\n",
"d.add({\"i\": [\"san-diego\"], \"j\": [\"topeka\"], \"values\": [1.4], \"units\": [\"km\"]})"
"d.add({\"i\": [\"san-diego\"], \"j\": [\"chicago\"], \"values\": [1.8], \"units\": [\"1000 miles\"]})\n",
"d.add({\"i\": [\"san-diego\"], \"j\": [\"topeka\"], \"values\": [1.4], \"units\": [\"1000 miles\"]})"
]
},
{
Expand Down Expand Up @@ -388,7 +388,7 @@
"metadata": {},
"outputs": [],
"source": [
"f = run.optimization.scalars.create(name=\"f\", value=90, unit=\"USD/km\")\n",
"f = run.optimization.scalars.create(name=\"f\", value=90, unit=\"dollars per case per 1000 miles\")\n",
"f.docs = \"Freight\""
]
},
Expand Down Expand Up @@ -421,9 +421,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Here, *supply* can only come from the factories in `IndexSet` *i*, while *demand* needs to be met at the markets in `IndexSet` *j*.\n",
"Here, *supply* can only come from the canning plant in **IndexSet** *i*, while *demand* needs to be met at the markets in **IndexSet** *j*.\n",
"\n",
"Shipment happens from a factory to a market, so *x* needs to be assigned to both *i* and *j*."
"Shipment is defined from a canning plant to a market, so *x* needs to be assigned to both *i* and *j*."
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions tutorial/transport/2_transport-tutorial_variant.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
"For instances of a **Variable** or a **Parameter** that have multiple dimensions,\n",
"you can use **pandas** for filtering and inspecting the data.\n",
"\n",
"The following cell shows the data for a using the distance parameter *d* and cast the `data` to a **pandas.DataFrame**."
"The following cell shows the data for a using the distance parameter *d* and cast the `Parameter.data` to a **pandas.DataFrame**."
]
},
{
Expand Down Expand Up @@ -471,7 +471,7 @@
"\n",
"Run the following in the command-line:\n",
"```\n",
"ixmp4 platforms delete transport-tutorial\n",
"ixmp4 platforms remove transport-tutorial\n",
"```\n",
"\n",
"The prompt will ask whether you also want to delete the SQLite database file from your computer."
Expand Down

0 comments on commit 0fa8580

Please sign in to comment.