Skip to content

Commit

Permalink
Fix various typos. (aimacode#750)
Browse files Browse the repository at this point in the history
  • Loading branch information
roberthoenig authored and norvig committed Feb 23, 2018
1 parent eae217b commit 06af67e
Show file tree
Hide file tree
Showing 23 changed files with 64 additions and 64 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ In more detail:

## Port to Python 3; Pythonic Idioms; py.test

- Check for common problems in [porting to Python 3](http://python3porting.com/problems.html), such as: `print` is now a function; `range` and `map` and other functions no longer produce `list`s; objects of different types can no longer be compared with `<`; strings are now Unicode; it would be nice to move `%` string formating to `.format`; there is a new `next` function for generators; integer division now returns a float; we can now use set literals.
- Check for common problems in [porting to Python 3](http://python3porting.com/problems.html), such as: `print` is now a function; `range` and `map` and other functions no longer produce `list`s; objects of different types can no longer be compared with `<`; strings are now Unicode; it would be nice to move `%` string formatting to `.format`; there is a new `next` function for generators; integer division now returns a float; we can now use set literals.
- Replace old Lisp-based idioms with proper Python idioms. For example, we have many functions that were taken directly from Common Lisp, such as the `every` function: `every(callable, items)` returns true if every element of `items` is callable. This is good Lisp style, but good Python style would be to use `all` and a generator expression: `all(callable(f) for f in items)`. Eventually, fix all calls to these legacy Lisp functions and then remove the functions.
- Add more tests in `test_*.py` files. Strive for terseness; it is ok to group multiple asserts into one `def test_something():` function. Move most tests to `test_*.py`, but it is fine to have a single `doctest` example in the docstring of a function in the `.py` file, if the purpose of the doctest is to explain how to use the function, rather than test the implementation.

Expand Down Expand Up @@ -83,7 +83,7 @@ Reporting Issues

- Under which versions of Python does this happen?

- Provide an example of the issue occuring.
- Provide an example of the issue occurring.

- Is anybody working on this?

Expand Down
16 changes: 8 additions & 8 deletions agents.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@
" print('{} decided to move {}wards at location: {}'.format(str(agent)[1:-1], agent.direction.direction, agent.location))\n",
" agent.moveforward()\n",
" else:\n",
" print('{} decided to move {}wards at location: {}, but couldnt'.format(str(agent)[1:-1], agent.direction.direction, agent.location))\n",
" print('{} decided to move {}wards at location: {}, but couldn\\'t'.format(str(agent)[1:-1], agent.direction.direction, agent.location))\n",
" agent.moveforward(False)\n",
" elif action == \"eat\":\n",
" items = self.list_things_at(agent.location, tclass=Food)\n",
Expand Down Expand Up @@ -605,17 +605,17 @@
"EnergeticBlindDog decided to move downwards at location: [0, 1]\n",
"EnergeticBlindDog drank Water at location: [0, 2]\n",
"EnergeticBlindDog decided to turnright at location: [0, 2]\n",
"EnergeticBlindDog decided to move leftwards at location: [0, 2], but couldnt\n",
"EnergeticBlindDog decided to move leftwards at location: [0, 2], but couldn't\n",
"EnergeticBlindDog decided to turnright at location: [0, 2]\n",
"EnergeticBlindDog decided to turnright at location: [0, 2]\n",
"EnergeticBlindDog decided to turnleft at location: [0, 2]\n",
"EnergeticBlindDog decided to turnleft at location: [0, 2]\n",
"EnergeticBlindDog decided to move leftwards at location: [0, 2], but couldnt\n",
"EnergeticBlindDog decided to move leftwards at location: [0, 2], but couldn't\n",
"EnergeticBlindDog decided to turnleft at location: [0, 2]\n",
"EnergeticBlindDog decided to turnright at location: [0, 2]\n",
"EnergeticBlindDog decided to move leftwards at location: [0, 2], but couldnt\n",
"EnergeticBlindDog decided to move leftwards at location: [0, 2], but couldn't\n",
"EnergeticBlindDog decided to turnleft at location: [0, 2]\n",
"EnergeticBlindDog decided to move downwards at location: [0, 2], but couldnt\n",
"EnergeticBlindDog decided to move downwards at location: [0, 2], but couldn't\n",
"EnergeticBlindDog decided to turnright at location: [0, 2]\n",
"EnergeticBlindDog decided to turnleft at location: [0, 2]\n",
"EnergeticBlindDog decided to turnleft at location: [0, 2]\n",
Expand Down Expand Up @@ -684,7 +684,7 @@
" print('{} decided to move {}wards at location: {}'.format(str(agent)[1:-1], agent.direction.direction, agent.location))\n",
" agent.moveforward()\n",
" else:\n",
" print('{} decided to move {}wards at location: {}, but couldnt'.format(str(agent)[1:-1], agent.direction.direction, agent.location))\n",
" print('{} decided to move {}wards at location: {}, but couldn\\'t'.format(str(agent)[1:-1], agent.direction.direction, agent.location))\n",
" agent.moveforward(False)\n",
" elif action == \"eat\":\n",
" items = self.list_things_at(agent.location, tclass=Food)\n",
Expand Down Expand Up @@ -1012,7 +1012,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"EnergeticBlindDog decided to move leftwards at location: [0, 3], but couldnt\n"
"EnergeticBlindDog decided to move leftwards at location: [0, 3], but couldn't\n"
]
},
{
Expand Down Expand Up @@ -1069,7 +1069,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"EnergeticBlindDog decided to move leftwards at location: [0, 3], but couldnt\n"
"EnergeticBlindDog decided to move leftwards at location: [0, 3], but couldn't\n"
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions csp.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@
"source": [
"## TREE CSP SOLVER\n",
"\n",
"The `tree_csp_solver` function (**Figure 6.11** in the book) can be used to solve problems whose constraint graph is a tree. Given a CSP, with `neighbors` forming a tree, it returns an assignement that satisfies the given constraints. The algorithm works as follows:\n",
"The `tree_csp_solver` function (**Figure 6.11** in the book) can be used to solve problems whose constraint graph is a tree. Given a CSP, with `neighbors` forming a tree, it returns an assignment that satisfies the given constraints. The algorithm works as follows:\n",
"\n",
"First it finds the *topological sort* of the tree. This is an ordering of the tree where each variable/node comes after its parent in the tree. The function that accomplishes this is `topological_sort`, which builds the topological sort using the recursive function `build_topological`. That function is an augmented DFS, where each newly visited node of the tree is pushed on a stack. The stack in the end holds the variables topologically sorted.\n",
"\n",
Expand Down Expand Up @@ -896,7 +896,7 @@
"\n",
"visualize_callback = make_visualize(iteration_slider)\n",
"\n",
"visualize_button = widgets.ToggleButton(desctiption = \"Visualize\", value = False)\n",
"visualize_button = widgets.ToggleButton(description = \"Visualize\", value = False)\n",
"time_select = widgets.ToggleButtons(description='Extra Delay:',options=['0', '0.1', '0.2', '0.5', '0.7', '1.0'])\n",
"\n",
"a = widgets.interactive(visualize_callback, Visualize = visualize_button, time_step=time_select)\n",
Expand Down Expand Up @@ -1055,7 +1055,7 @@
"\n",
"visualize_callback = make_visualize(iteration_slider)\n",
"\n",
"visualize_button = widgets.ToggleButton(desctiption = \"Visualize\", value = False)\n",
"visualize_button = widgets.ToggleButton(description = \"Visualize\", value = False)\n",
"time_select = widgets.ToggleButtons(description='Extra Delay:',options=['0', '0.1', '0.2', '0.5', '0.7', '1.0'])\n",
"\n",
"a = widgets.interactive(visualize_callback, Visualize = visualize_button, time_step=time_select)\n",
Expand Down Expand Up @@ -1138,7 +1138,7 @@
"\n",
"visualize_callback = make_visualize(iteration_slider)\n",
"\n",
"visualize_button = widgets.ToggleButton(desctiption = \"Visualize\", value = False)\n",
"visualize_button = widgets.ToggleButton(description = \"Visualize\", value = False)\n",
"time_select = widgets.ToggleButtons(description='Extra Delay:',options=['0', '0.1', '0.2', '0.5', '0.7', '1.0'])\n",
"\n",
"a = widgets.interactive(visualize_callback, Visualize = visualize_button, time_step=time_select)\n",
Expand Down
2 changes: 1 addition & 1 deletion games.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
"\n",
"<img src=\"images/fig_5_2.png\" width=\"75%\">\n",
"\n",
"The states are represented wih capital letters inside the triangles (eg. \"A\") while moves are the labels on the edges between states (eg. \"a1\"). Terminal nodes carry utility values. Note that the terminal nodes are named in this example 'B1', 'B2' and 'B2' for the nodes below 'B', and so forth.\n",
"The states are represented with capital letters inside the triangles (eg. \"A\") while moves are the labels on the edges between states (eg. \"a1\"). Terminal nodes carry utility values. Note that the terminal nodes are named in this example 'B1', 'B2' and 'B2' for the nodes below 'B', and so forth.\n",
"\n",
"We will model the moves, utilities and initial state like this:"
]
Expand Down
2 changes: 1 addition & 1 deletion gui/xy_vacuum_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def update_env(self):
xf, yf = agt.location

def reset_env(self, agt):
"""Resets the GUI environment to the intial state."""
"""Resets the GUI environment to the initial state."""
self.read_env()
for i, btn_row in enumerate(self.buttons):
for j, btn in enumerate(btn_row):
Expand Down
6 changes: 3 additions & 3 deletions learning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@
"source": [
"The implementation of `DecisionTreeLearner` provided in [learning.py](https://github.com/aimacode/aima-python/blob/master/learning.py) uses information gain as the metric for selecting which attribute to test for splitting. The function builds the tree top-down in a recursive manner. Based on the input it makes one of the four choices:\n",
"<ol>\n",
"<li>If the input at the current step has no training data we return the mode of classes of input data recieved in the parent step (previous level of recursion).</li>\n",
"<li>If the input at the current step has no training data we return the mode of classes of input data received in the parent step (previous level of recursion).</li>\n",
"<li>If all values in training data belong to the same class it returns a `DecisionLeaf` whose class label is the class which all the data belongs to.</li>\n",
"<li>If the data has no attributes that can be tested we return the class with highest plurality value in the training data.</li>\n",
"<li>We choose the attribute which gives the highest amount of entropy gain and return a `DecisionFork` which splits based on this attribute. Each branch recursively calls `decision_tree_learning` to construct the sub-tree.</li>\n",
Expand Down Expand Up @@ -1155,7 +1155,7 @@
"\n",
"*a)* The probability of **Class** in the dataset.\n",
"\n",
"*b)* The conditional probability of each feature occuring in an item classified in **Class**.\n",
"*b)* The conditional probability of each feature occurring in an item classified in **Class**.\n",
"\n",
"*c)* The probabilities of each individual feature.\n",
"\n",
Expand Down Expand Up @@ -1339,7 +1339,7 @@
"source": [
"You can see the means of the features for the \"Setosa\" class and the deviations for \"Versicolor\".\n",
"\n",
"The prediction function will work similarly to the Discrete algorithm. It will multiply the probability of the class occuring with the conditional probabilities of the feature values for the class.\n",
"The prediction function will work similarly to the Discrete algorithm. It will multiply the probability of the class occurring with the conditional probabilities of the feature values for the class.\n",
"\n",
"Since we are using the Gaussian distribution, we will input the value for each feature into the Gaussian function, together with the mean and deviation of the feature. This will return the probability of the particular feature value for the given class. We will repeat for each class and pick the max value."
]
Expand Down
2 changes: 1 addition & 1 deletion logic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@
"metadata": {},
"source": [
"<em>\"Nono ... has some missiles\"</em><br/>\n",
"This states the existance of some missile which is owned by Nono. $\\exists x \\text{Owns}(\\text{Nono}, x) \\land \\text{Missile}(x)$. We invoke existential instantiation to introduce a new constant `M1` which is the missile owned by Nono.\n",
"This states the existence of some missile which is owned by Nono. $\\exists x \\text{Owns}(\\text{Nono}, x) \\land \\text{Missile}(x)$. We invoke existential instantiation to introduce a new constant `M1` which is the missile owned by Nono.\n",
"\n",
"$\\text{Owns}(\\text{Nono}, \\text{M1}), \\text{Missile}(\\text{M1})$"
]
Expand Down
4 changes: 2 additions & 2 deletions mdp.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"With this we have sucessfully represented our MDP. Later we will look at ways to solve this MDP."
"With this we have successfully represented our MDP. Later we will look at ways to solve this MDP."
]
},
{
Expand Down Expand Up @@ -919,7 +919,7 @@
"\n",
"visualize_callback = make_visualize(iteration_slider)\n",
"\n",
"visualize_button = widgets.ToggleButton(desctiption = \"Visualize\", value = False)\n",
"visualize_button = widgets.ToggleButton(description = \"Visualize\", value = False)\n",
"time_select = widgets.ToggleButtons(description='Extra Delay:',options=['0', '0.1', '0.2', '0.5', '0.7', '1.0'])\n",
"a = widgets.interactive(visualize_callback, Visualize = visualize_button, time_step=time_select)\n",
"display(a)"
Expand Down
Loading

0 comments on commit 06af67e

Please sign in to comment.