Skip to content

Commit

Permalink
Merge pull request #18 from ibah/master
Browse files Browse the repository at this point in the history
Alternative solution to 'Consider two random array A anb B, check if they are equal' plus an explanation
  • Loading branch information
rougier committed Aug 25, 2016
2 parents 9ee1a2c + 9b248dd commit 4fa32cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions 100 Numpy exercises.ipynb
Expand Up @@ -855,8 +855,13 @@
"source": [
"A = np.random.randint(0,2,5)\n",
"B = np.random.randint(0,2,5)\n",
"# Assuming identical shape of the arrays and a tolerance for the comparison of values"
"equal = np.allclose(A,B)\n",
"print(equal)"
"\n"
"# Checking both the shape and the element values, no tolerance (values have to be exactly equal)"
"equal = np.array_equal(A,B)"
"print(equal)"
]
},
{
Expand Down
5 changes: 5 additions & 0 deletions 100 Numpy exercises.md
Expand Up @@ -387,8 +387,13 @@ np.add.reduce(Z)
```python
A = np.random.randint(0,2,5)
B = np.random.randint(0,2,5)
# Assuming identical shape of the arrays and a tolerance for the comparison of values
equal = np.allclose(A,B)
print(equal)

# Checking both the shape and the element values, no tolerance (values have to be exactly equal)
equal = np.array_equal(A,B)
print(equal)
```

#### 43. Make an array immutable (read-only) (★★☆)
Expand Down

0 comments on commit 4fa32cb

Please sign in to comment.