Browse Source

add english version for tutorial

pull/2/MERGE
Geoff 4 years ago
parent
commit
70f532fbc7
5 changed files with 362 additions and 371 deletions
  1. +17
    -17
      1_numpy_matplotlib_scipy_sympy/1-numpy_tutorial.ipynb
  2. +31
    -31
      1_numpy_matplotlib_scipy_sympy/2-matplotlib_simple_tutorial.ipynb
  3. +2
    -2
      1_numpy_matplotlib_scipy_sympy/3-ipython_notebook.ipynb
  4. +158
    -161
      1_numpy_matplotlib_scipy_sympy/4-scipy_tutorial.ipynb
  5. +154
    -160
      1_numpy_matplotlib_scipy_sympy/5-sympy_tutorial.ipynb

+ 17
- 17
1_numpy_matplotlib_scipy_sympy/1-numpy_tutorial.ipynb View File

@@ -4378,7 +4378,7 @@
" for col_idx, element in enumerate(row):\n",
" print(\"col_idx\", col_idx, \"element\", element)\n",
" \n",
" # update the matrix M: square each element\n",
" # 更新矩阵:对每个元素求平方\n",
" M[row_idx, col_idx] = element ** 2"
]
},
@@ -4400,7 +4400,7 @@
}
],
"source": [
"# each element in M is now squared\n",
"# 现在矩阵里的每一个元素都已经求得平方\n",
"M"
]
},
@@ -4408,14 +4408,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Vectorizing functions"
"## 向量化功能"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As mentioned several times by now, to get good performance we should try to avoid looping over elements in our vectors and matrices, and instead use vectorized algorithms. The first step in converting a scalar algorithm to a vectorized algorithm is to make sure that the functions we write work with vector inputs."
"正如前面多次提到的,为了获得良好的性能,我们应该尽量避免对向量和矩阵中的元素进行循环,而应该使用向量化算法。将标量算法转换为向量化算法的第一步是确保我们编写的函数使用向量输入。"
]
},
{
@@ -4426,7 +4426,7 @@
"source": [
"def Theta(x):\n",
" \"\"\"\n",
" Scalar implemenation of the Heaviside step function.\n",
" Heaviside阶跃函数的标量实现\n",
" \"\"\"\n",
" if x >= 0:\n",
" return 1\n",
@@ -4460,9 +4460,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"OK, that didn't work because we didn't write the `Theta` function so that it can handle a vector input... \n",
"这个操作并不可行因为我们没有写`Theta`函数去解决一个向量输入\n",
"\n",
"To get a vectorized version of Theta we can use the Numpy function `vectorize`. In many cases it can automatically vectorize a function:"
"为了得到向量化的版本,我们可以使用Numpy函数`vectorize`。在许多情况下,它可以自动向量化一个函数:"
]
},
{
@@ -4498,7 +4498,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We can also implement the function to accept a vector input from the beginning (requires more effort but might give better performance):"
"我们也可以实现从一开始就接受矢量输入的函数(需要更多的计算,但可能会有更好的性能):"
]
},
{
@@ -4509,7 +4509,7 @@
"source": [
"def Theta(x):\n",
" \"\"\"\n",
" Vector-aware implemenation of the Heaviside step function.\n",
" Heaviside阶跃函数的矢量感知实现。\n",
" \"\"\"\n",
" return 1 * (x >= 0)"
]
@@ -4581,7 +4581,7 @@
}
],
"source": [
"# still works for scalars as well\n",
"# 同样适用于标量\n",
"Theta(-1.2), Theta(2.6)"
]
},
@@ -4589,14 +4589,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Using arrays in conditions"
"## 在条件中使用数组"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"When using arrays in conditions,for example `if` statements and other boolean expressions, one needs to use `any` or `all`, which requires that any or all elements in the array evalutes to `True`:"
"当在条件中使用数组时,例如`if`语句和其他布尔表达,一个需要用`any`或者`all`,这让数组任何或者所有元素都等于`True`。"
]
},
{
@@ -4685,14 +4685,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Type casting"
"## 类型转换"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Since Numpy arrays are *statically typed*, the type of an array does not change once created. But we can explicitly cast an array of some type to another using the `astype` functions (see also the similar `asarray` function). This always create a new array of new type:"
"因为Numpy数组是*静态类型*,数组的类型一旦创建就不会改变。但是我们可以用`astype`函数(参见类似的“asarray”函数)显式地转换一个数组的类型到其他的类型,这总是创建一个新类型的新数组。"
]
},
{
@@ -4785,7 +4785,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Further reading"
"## 进一步的阅读"
]
},
{
@@ -4794,14 +4794,14 @@
"source": [
"* http://numpy.scipy.org\n",
"* http://scipy.org/Tentative_NumPy_Tutorial\n",
"* http://scipy.org/NumPy_for_Matlab_Users - A Numpy guide for MATLAB users."
"* http://scipy.org/NumPy_for_Matlab_Users - 一个针对MATLAB使用者的Numpy教程."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Versions"
"## 版本"
]
},
{


+ 31
- 31
1_numpy_matplotlib_scipy_sympy/2-matplotlib_simple_tutorial.ipynb
File diff suppressed because it is too large
View File


+ 2
- 2
1_numpy_matplotlib_scipy_sympy/3-ipython_notebook.ipynb View File

@@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# 1.1. Introducing IPython and the Jupyter Notebook"
"# 1.1. 介绍IPython和Jupyter笔记本"
]
},
{
@@ -330,7 +330,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.6.8"
}
},
"nbformat": 4,


+ 158
- 161
1_numpy_matplotlib_scipy_sympy/4-scipy_tutorial.ipynb
File diff suppressed because it is too large
View File


+ 154
- 160
1_numpy_matplotlib_scipy_sympy/5-sympy_tutorial.ipynb
File diff suppressed because it is too large
View File


Loading…
Cancel
Save