Skip to content

Commit 2b93231

Browse files
author
ZhiBing(陈治兵)
committed
Merge branch 'v1.17' of github.com:teadocs/numpy-cn into v1.17
2 parents d7eafea + 89140d1 commit 2b93231

File tree

11 files changed

+203
-272
lines changed

11 files changed

+203
-272
lines changed

docs/en/reference/routines/random.md

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,9 @@ from numpy import random
3333
random.standard_normal()
3434
```
3535

36-
[``Generator``](generator.html#numpy.random.Generator) can be used as a replacement for [``RandomState``](legacy.html#numpy.random.mtrand.RandomState). Both class
37-
instances now hold a internal *BitGenerator* instance to provide the bit
38-
stream, it is accessible as ``gen.bit_generator``. Some long-overdue API
39-
cleanup means that legacy and compatibility methods have been removed from
40-
[``Generator``](generator.html#numpy.random.Generator)
41-
42-
[RandomState](legacy.html#numpy.random.mtrand.RandomState) | [Generator](generator.html#numpy.random.Generator) | Notes
43-
---|---|---
44-
random_sample, | random | Compatible with [random.random](https://docs.python.org/dev/library/random.html#random.random)
45-
rand |   |  
46-
randint, | integers | Add an endpoint kwarg
47-
random_integers |   |  
48-
tomaxint | removed | Use integers(0, np.iinfo(np.int).max,endpoint=False)
49-
seed | removed | Use [spawn](bit_generators/generated/numpy.random.SeedSequence.spawn.html#numpy.random.SeedSequence.spawn)
50-
51-
See *new-or-different* for more information
36+
[`Generator`](https://numpy.org/doc/1.17/reference/random/generator.html#numpy.random.Generator) can be used as a direct replacement for RandomState, although the random values are generated by [`PCG64`](https://numpy.org/doc/1.17/reference/random/bit_generators/pcg64.html#numpy.random.pcg64.PCG64). The [`Generator`](https://numpy.org/doc/1.17/reference/random/generator.html#numpy.random.Generator) holds an instance of a BitGenerator. It is accessible as `gen.bit_generator`.
5237

53-
``` python
38+
```Python
5439
# As replacement for RandomState(); default_rng() instantiates Generator with
5540
# the default PCG64 BitGenerator.
5641
from numpy.random import default_rng
@@ -59,24 +44,9 @@ rg.standard_normal()
5944
rg.bit_generator
6045
```
6146

62-
Something like the following code can be used to support both ``RandomState``
63-
and ``Generator``, with the understanding that the interfaces are slightly
64-
different
65-
66-
``` python
67-
try:
68-
rg_integers = rg.integers
69-
except AttributeError:
70-
rg_integers = rg.randint
71-
a = rg_integers(1000)
72-
```
73-
74-
Seeds can be passed to any of the BitGenerators. The provided value is mixed
75-
via [``SeedSequence``](bit_generators/generated/numpy.random.SeedSequence.html#numpy.random.SeedSequence) to spread a possible sequence of seeds across a wider
76-
range of initialization states for the BitGenerator. Here [``PCG64``](bit_generators/pcg64.html#numpy.random.pcg64.PCG64) is used and
77-
is wrapped with a [``Generator``](generator.html#numpy.random.Generator).
47+
Seeds can be passed to any of the BitGenerators. The provided value is mixed via [`SeedSequence`](https://numpy.org/doc/1.17/reference/random/bit_generators/generated/numpy.random.SeedSequence.html#numpy.random.SeedSequence) to spread a possible sequence of seeds across a wider range of initialization states for the BitGenerator. Here [`PCG64`](https://numpy.org/doc/1.17/reference/random/bit_generators/pcg64.html#numpy.random.pcg64.PCG64) is used and is wrapped with a [`Generator`](https://numpy.org/doc/1.17/reference/random/generator.html#numpy.random.Generator).
7848

79-
``` python
49+
```python
8050
from numpy.random import Generator, PCG64
8151
rg = Generator(PCG64(12345))
8252
rg.standard_normal()
@@ -198,4 +168,4 @@ one of three ways:
198168
### Original Source
199169

200170
This package was developed independently of NumPy and was integrated in version
201-
1.17.0. The original repo is at [https://github.com/bashtage/randomgen](https://github.com/bashtage/randomgen).
171+
1.17.0. The original repo is at [https://github.com/bashtage/randomgen](https://github.com/bashtage/randomgen).

docs/reference/routines/math.md

Lines changed: 96 additions & 96 deletions
Large diffs are not rendered by default.

docs/reference/routines/matlib.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
# Matrix library (``numpy.matlib``)
1+
# 矩阵库 (``numpy.matlib``)
22

3-
This module contains all functions in the [``numpy``](index.html#module-numpy) namespace, with
4-
the following replacement functions that return [``matrices``](https://numpy.org/devdocs/reference/generated/numpy.matrix.html#numpy.matrix) instead of [``ndarrays``](https://numpy.org/devdocs/reference/generated/numpy.ndarray.html#numpy.ndarray).
3+
该模块包含 [``numpy``](index.html#module-numpy) 命名空间中的所有函数, 以下返回 [``矩阵``](https://numpy.org/devdocs/reference/generated/numpy.matrix.html#numpy.matrix) 而不是 [``ndarrays``](https://numpy.org/devdocs/reference/generated/numpy.ndarray.html#numpy.ndarray)的替换函数。
54

6-
Functions that are also in the numpy namespace and return matrices
5+
也在numpy命名空间中的函数并返回矩阵
76

87
method | description
98
---|---
10-
[mat](https://numpy.org/devdocs/reference/generated/numpy.mat.html#numpy.mat)(data[, dtype]) | Interpret the input as a [matrix](https://numpy.org/devdocs/reference/generated/numpy.matrix.html#numpy.matrix).
11-
[matrix](https://numpy.org/devdocs/reference/generated/numpy.matrix.html#numpy.matrix)(data[, dtype, copy]) | Note: It is no longer recommended to use this class, even for linear
12-
[asmatrix](https://numpy.org/devdocs/reference/generated/numpy.asmatrix.html#numpy.asmatrix)(data[, dtype]) | Interpret the input as a matrix.
13-
[bmat](https://numpy.org/devdocs/reference/generated/numpy.bmat.html#numpy.bmat)(obj[, ldict, gdict]) | Build a matrix object from a string, nested sequence, or array.
9+
[mat](https://numpy.org/devdocs/reference/generated/numpy.mat.html#numpy.mat)(data[, dtype]) | 将输入解释为 [矩阵](https://numpy.org/devdocs/reference/generated/numpy.matrix.html#numpy.matrix).
10+
[matrix](https://numpy.org/devdocs/reference/generated/numpy.matrix.html#numpy.matrix)(data[, dtype, copy]) | 注意:不再建议使用此类,即使对于线性
11+
[asmatrix](https://numpy.org/devdocs/reference/generated/numpy.asmatrix.html#numpy.asmatrix)(data[, dtype]) | 将输入解释为矩阵。
12+
[bmat](https://numpy.org/devdocs/reference/generated/numpy.bmat.html#numpy.bmat)(obj[, ldict, gdict]) | 从字符串,嵌套序列或数组构建矩阵对象。
1413

15-
Replacement functions in [``matlib``](#module-numpy.matlib)
14+
[``matlib``](#module-numpy.matlib)的替换函数
1615

1716
method | description
1817
---|---
19-
[empty](https://numpy.org/devdocs/reference/generated/numpy.matlib.empty.html#numpy.matlib.empty)(shape[, dtype, order]) | Return a new matrix of given shape and type, without initializing entries.
20-
[zeros](https://numpy.org/devdocs/reference/generated/numpy.matlib.zeros.html#numpy.matlib.zeros)(shape[, dtype, order]) | Return a matrix of given shape and type, filled with zeros.
21-
[ones](https://numpy.org/devdocs/reference/generated/numpy.matlib.ones.html#numpy.matlib.ones)(shape[, dtype, order]) | Matrix of ones.
22-
[eye](https://numpy.org/devdocs/reference/generated/numpy.matlib.eye.html#numpy.matlib.eye)(n[, M, k, dtype, order]) | Return a matrix with ones on the diagonal and zeros elsewhere.
23-
[identity](https://numpy.org/devdocs/reference/generated/numpy.matlib.identity.html#numpy.matlib.identity)(n[, dtype]) | Returns the square identity matrix of given size.
24-
[repmat](https://numpy.org/devdocs/reference/generated/numpy.matlib.repmat.html#numpy.matlib.repmat)(a, m, n) | Repeat a 0-D to 2-D array or matrix MxN times.
25-
[rand](https://numpy.org/devdocs/reference/generated/numpy.matlib.rand.html#numpy.matlib.rand)(\*args) | Return a matrix of random values with given shape.
26-
[randn](https://numpy.org/devdocs/reference/generated/numpy.matlib.randn.html#numpy.matlib.randn)(\*args) | Return a random matrix with data from the “standard normal” distribution.
18+
[empty](https://numpy.org/devdocs/reference/generated/numpy.matlib.empty.html#numpy.matlib.empty)(shape[, dtype, order]) | 返回给定形状和类型的新矩阵,而无需初始化条目。
19+
[zeros](https://numpy.org/devdocs/reference/generated/numpy.matlib.zeros.html#numpy.matlib.zeros)(shape[, dtype, order]) | 返回给定形状和类型的矩阵,并用零填充。
20+
[ones](https://numpy.org/devdocs/reference/generated/numpy.matlib.ones.html#numpy.matlib.ones)(shape[, dtype, order]) | 一个矩阵。
21+
[eye](https://numpy.org/devdocs/reference/generated/numpy.matlib.eye.html#numpy.matlib.eye)(n[, M, k, dtype, order]) | 返回一个矩阵,在对角线上有一个,在其他地方为零。
22+
[identity](https://numpy.org/devdocs/reference/generated/numpy.matlib.identity.html#numpy.matlib.identity)(n[, dtype]) | 返回给定大小的平方单位矩阵。
23+
[repmat](https://numpy.org/devdocs/reference/generated/numpy.matlib.repmat.html#numpy.matlib.repmat)(a, m, n) | 重复从0D到2D数组或矩阵MxN次。
24+
[rand](https://numpy.org/devdocs/reference/generated/numpy.matlib.rand.html#numpy.matlib.rand)(\*args) |返回具有给定形状的随机值矩阵。
25+
[randn](https://numpy.org/devdocs/reference/generated/numpy.matlib.randn.html#numpy.matlib.randn)(\*args) | 返回一个随机矩阵,其中包含来自“标准正态”分布的数据。

docs/reference/routines/other.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
# Miscellaneous routines
1+
# 杂项(`Miscellaneous routines`)
22

3-
## Performance tuning
3+
## 性能调优
44

55
method | description
66
---|---
7-
[setbufsize](https://numpy.org/devdocs/reference/generated/numpy.setbufsize.html#numpy.setbufsize)(size) | Set the size of the buffer used in ufuncs.
8-
[getbufsize](https://numpy.org/devdocs/reference/generated/numpy.getbufsize.html#numpy.getbufsize)() | Return the size of the buffer used in ufuncs.
7+
[setbufsize](https://numpy.org/devdocs/reference/generated/numpy.setbufsize.html#numpy.setbufsize)(size) | 设置用于ufuncs的缓冲区的大小。
8+
[getbufsize](https://numpy.org/devdocs/reference/generated/numpy.getbufsize.html#numpy.getbufsize)() | 返回用于ufuncs的缓冲区的大小。
99

10-
## Memory ranges
10+
## 内存区间
1111

1212
method | description
1313
---|---
14-
[shares_memory](https://numpy.org/devdocs/reference/generated/numpy.shares_memory.html#numpy.shares_memory)(a, b[, max_work]) | Determine if two arrays share memory
15-
[may_share_memory](https://numpy.org/devdocs/reference/generated/numpy.may_share_memory.html#numpy.may_share_memory)(a, b[, max_work]) | Determine if two arrays might share memory
16-
[byte_bounds](https://numpy.org/devdocs/reference/generated/numpy.byte_bounds.html#numpy.byte_bounds)(a) | Returns pointers to the end-points of an array.
14+
[shares_memory](https://numpy.org/devdocs/reference/generated/numpy.shares_memory.html#numpy.shares_memory)(a, b[, max_work]) | 确定两个阵列是否共享内存
15+
[may_share_memory](https://numpy.org/devdocs/reference/generated/numpy.may_share_memory.html#numpy.may_share_memory)(a, b[, max_work]) | 确定两个阵列是否可以共享内存
16+
[byte_bounds](https://numpy.org/devdocs/reference/generated/numpy.byte_bounds.html#numpy.byte_bounds)(a) | 返回指向数组端点的指针。
1717

18-
## Array mixins
18+
## 数组Mixin
1919

2020
method | description
2121
---|---
22-
[lib.mixins.NDArrayOperatorsMixin](https://numpy.org/devdocs/reference/generated/numpy.lib.mixins.NDArrayOperatorsMixin.html#numpy.lib.mixins.NDArrayOperatorsMixin) | Mixin defining all operator special methods using __array_ufunc__.
22+
[lib.mixins.NDArrayOperatorsMixin](https://numpy.org/devdocs/reference/generated/numpy.lib.mixins.NDArrayOperatorsMixin.html#numpy.lib.mixins.NDArrayOperatorsMixin) | Mixin使用__array_ufunc__定义所有运算符的特殊方法。
2323

24-
## NumPy version comparison
24+
## NumPy版本比较
2525

2626
method | description
2727
---|---
28-
[lib.NumpyVersion](https://numpy.org/devdocs/reference/generated/numpy.lib.NumpyVersion.html#numpy.lib.NumpyVersion)(vstring) | Parse and compare numpy version strings.
28+
[lib.NumpyVersion](https://numpy.org/devdocs/reference/generated/numpy.lib.NumpyVersion.html#numpy.lib.NumpyVersion)(vstring) | 解析并比较numpy版本字符串。
2929

30-
## Utility
30+
## 效用
3131

3232
method | description
3333
---|---
34-
[get_include](https://numpy.org/devdocs/reference/generated/numpy.get_include.html#numpy.get_include)() | Return the directory that contains the NumPy *.h header files.
35-
[deprecate](https://numpy.org/devdocs/reference/generated/numpy.deprecate.html#numpy.deprecate)(\*args, \*\*kwargs) | Issues a DeprecationWarning, adds warning to old_name’s docstring, rebinds old_name.__name__ and returns the new function object.
36-
[deprecate_with_doc](https://numpy.org/devdocs/reference/generated/numpy.deprecate_with_doc.html#numpy.deprecate_with_doc)(msg) |
34+
[get_include](https://numpy.org/devdocs/reference/generated/numpy.get_include.html#numpy.get_include)() | 返回包含NumPy * .h头文件的目录。
35+
[deprecate](https://numpy.org/devdocs/reference/generated/numpy.deprecate.html#numpy.deprecate)(\*args, \*\*kwargs) | 发出DeprecationWarning,向old_name的文档字符串添加警告,重新绑定old_name .__ name__并返回新的函数对象。
36+
[deprecate_with_doc](https://numpy.org/devdocs/reference/generated/numpy.deprecate_with_doc.html#numpy.deprecate_with_doc)(msg) |
3737

38-
## Matlab-like Functions
38+
## 类Matlab函数
3939

4040
method | description
4141
---|---
42-
[who](https://numpy.org/devdocs/reference/generated/numpy.who.html#numpy.who)([vardict]) | Print the NumPy arrays in the given dictionary.
43-
[disp](https://numpy.org/devdocs/reference/generated/numpy.disp.html#numpy.disp)(mesg[, device, linefeed]) | Display a message on a device.
42+
[who](https://numpy.org/devdocs/reference/generated/numpy.who.html#numpy.who)([vardict]) | 在给定的字典中打印NumPy数组。
43+
[disp](https://numpy.org/devdocs/reference/generated/numpy.disp.html#numpy.disp)(mesg[, device, linefeed]) | 在设备上显示消息。

docs/reference/routines/padding.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Padding Arrays
1+
# 填充数组(`Padding Arrays`)
22

33
method | description
44
---|---
5-
[pad](https://numpy.org/devdocs/reference/generated/numpy.pad.html#numpy.pad)(array, pad_width[, mode]) | Pad an array.
5+
[pad](https://numpy.org/devdocs/reference/generated/numpy.pad.html#numpy.pad)(array, pad_width[, mode]) | 填充一个数组。

docs/reference/routines/polynomials.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Polynomials
1+
# 多项式(`Polynomials`)
22

3-
Polynomials in NumPy can be created, manipulated, and even fitted using the [Using the Convenience Classes](https://www.numpy.org/devdocs/reference/routines.polynomials.classes.html) of the [numpy.polynomial](https://www.numpy.org/devdocs/reference/routines.polynomials.package.html#module-numpy.polynomial) package, introduced in NumPy 1.4.
3+
NumPy中的多项式可以使用NumPy 1.4中引入的[numpy.polynomial](https://www.numpy.org/devdocs/reference/routines.polynomials.package.html#module-numpy.polynomial)程序包的[Using the Convenience Classes](https://www.numpy.org/devdocs/reference/routines.polynomials.classes.html)创建,操纵甚至拟合。
44

5-
Prior to NumPy 1.4, [numpy.poly1d](https://www.numpy.org/devdocs/reference/generated/numpy.poly1d.html#numpy.poly1d) was the class of choice and it is still available in order to maintain backward compatibility. However, the newer Polynomial package is more complete than [numpy.poly1d](https://www.numpy.org/devdocs/reference/generated/numpy.poly1d.html#numpy.poly1d) and its convenience classes are better behaved in the numpy environment. Therefore Polynomial is recommended for new coding.
5+
在NumPy 1.4之前,[numpy.poly1d](https://www.numpy.org/devdocs/reference/generated/numpy.poly1d.html#numpy.poly1d)是选择的类,为了保持向后兼容性,仍可以使用。 但是,较新的Polynomial软件包比[numpy.poly1d](https://www.numpy.org/devdocs/reference/generated/numpy.poly1d.html#numpy.poly1d)更完整,并且其便利类在numpy环境中表现更好。 因此,建议多项式用于新编码。
66

7-
# Transition notice
7+
# 过渡通知
88

9-
The various routines in the Polynomial package all deal with series whose coefficients go from degree zero upward, which is the reverse order of the Poly1d convention. The easy way to remember this is that indexes correspond to degree, i.e., coef[i] is the coefficient of the term of degree i.
9+
多项式程序包中的各种例程均处理其系数从零度开始向上的级数,这与Poly1d约定的顺序相反。 记住这一点的简单方法是索引对应于度,即coef [i]是度i项的系数。
1010

1111
- [Polynomial Package](https://www.numpy.org/devdocs/reference/routines.polynomials.package.html)
1212
- [Using the Convenience Classes](https://www.numpy.org/devdocs/reference/routines.polynomials.classes.html)

0 commit comments

Comments
 (0)