8000 Merge pull request #28023 from mattip/doctest-1.6.0 · numpy/numpy@cb34472 · GitHub
[go: up one dir, main page]

Skip to content

Commit cb34472

Browse files
authored
Merge pull request #28023 from mattip/doctest-1.6.0
DOC: update to scipy-doctest 1.6.0 and fix tests
2 parents 965fdf5 + 84fa489 commit cb34472

File tree

4 files changed

+40
-48
lines changed

4 files changed

+40
-48
lines changed

‎.github/workflows/linux.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,13 @@ jobs:
194194
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
195195
run: |
196196
spin bench --quick
197-
- name: Check docstests
198-
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
199-
run: |
200-
pip install scipy-doctest==1.5.1 hypothesis==6.104.1 matplotlib scipy pytz pandas
201-
spin check-docs -v
202-
spin check-tutorials -v
197+
# These are run on CircleCI
198+
# - name: Check docstests
199+
# shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
200+
# run: |
201+
# pip install scipy-doctest==1.6.0 hypothesis==6.104.1 matplotlib scipy pytz pandas
202+
# spin check-docs -v
203+
# spin check-tutorials -v
203204

204205
sdist:
205206
needs: [smoke_test]

‎numpy/_core/_add_newdocs.py

Lines changed: 31 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2771,7 +2771,7 @@
27712771
>>> y.shape = (3, 6)
27722772
Traceback (most recent call last):
27732773
File "<stdin>", line 1, in <module>
2774-
ValueError: total size of new array must be unchanged
2774+
ValueError: cannot reshape array of size 24 into shape (3,6)
27752775
>>> np.zeros((4,2))[::2].shape = (-1,)
27762776
Traceback (most recent call last):
27772777
File "<stdin>", line 1, in <module>
@@ -2854,31 +2854,32 @@
28542854
Examples
28552855
--------
28562856
>>> import numpy as np
2857-
>>> y = np.reshape(np.arange(2*3*4), (2,3,4))
2857+
>>> y = np.reshape(np.arange(2 * 3 * 4, dtype=np.int32), (2, 3, 4))
28582858
>>> y
28592859
array([[[ 0, 1, 2, 3],
28602860
[ 4, 5, 6, 7],
28612861
[ 8, 9, 10, 11]],
28622862
[[12, 13, 14, 15],
28632863
[16, 17, 18, 19],
2864-
[20, 21, 22, 23]]])
2864+
[20, 21, 22, 23]]], dtype=np.int32)
28652865
>>> y.strides
28662866
(48, 16, 4)
2867-
>>> y[1,1,1]
2868-
17
2869-
>>> offset=sum(y.strides * np.array((1,1,1)))
2870-
>>> offset/y.itemsize
2871-
17
2872-
2873-
>>> x = np.reshape(np.arange(5*6*7*8), (5,6,7,8)).transpose(2,3,1,0)
2867+
>>> y[1, 1, 1]
2868+
np.int32(17)
2869+
>>> offset = sum(y.strides * np.array((1, 1, 1)))
2870+
>>> offset // y.itemsize
2871+
np.int64(17)
2872+
2873+
>>> x = np.reshape(np.arange(5*6*7*8, dtype=np.int32), (5, 6, 7, 8))
2874+
>>> x = x.transpose(2, 3, 1, 0)
28742875
>>> x.strides
28752876
(32, 4, 224, 1344)
2876-
>>> i = np.array([3,5,2,2])
2877+
>>> i = np.array([3, 5, 2, 2], dtype=np.int32)
28772878
>>> offset = sum(i * x.strides)
2878-
>>> x[3,5,2,2]
2879-
813
2880-
>>> offset / x.itemsize
2881-
813
2879+
>>> x[3, 5, 2, 2]
2880+
np.int32(813)
2881+
>>> offset // x.itemsize
2882+
np.int64(813)
28822883
28832884
"""))
28842885

@@ -4964,8 +4965,8 @@
49644965
0
49654966
>>> np.multiply.identity
49664967
1
4967-
>>> np.power.identity
4968-
1
4968+
>>> print(np.power.identity)
4969+
None
49694970
>>> print(np.exp.identity)
49704971
None
49714972
"""))
@@ -5053,15 +5054,15 @@
50535054
--------
50545055
>>> import numpy as np
50555056
>>> np.add.ntypes
5056-
18
5057+
22
50575058
>>> np.multiply.ntypes
5058-
18
5059+
23
50595060
>>> np.power.ntypes
5060-
17
5061+
21
50615062
>>> np.exp.ntypes
5062-
7
5063+
10
50635064
>>> np.remainder.ntypes
5064-
14
5065+
16
50655066
50665067
"""))
50675068

@@ -5080,26 +5081,16 @@
50805081
--------
50815082
>>> import numpy as np
50825083
>>> np.add.types
5083-
['??->?', 'bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',
5084-
'LL->L', 'qq->q', 'QQ->Q', 'ff->f', 'dd->d', 'gg->g', 'FF->F', 'DD->D',
5085-
'GG->G', 'OO->O']
5086-
5087-
>>> np.multiply.types
5088-
['??->?', 'bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',
5089-
'LL->L', 'qq->q', 'QQ->Q', 'ff->f', 'dd->d', 'gg->g', 'FF->F', 'DD->D',
5090-
'GG->G', 'OO->O']
5084+
['??->?', 'bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', ...
50915085
50925086
>>> np.power.types
5093-
['bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
5094-
'qq->q', 'QQ->Q', 'ff->f', 'dd->d', 'gg->g', 'FF->F', 'DD->D', 'GG->G',
5095-
'OO->O']
5087+
['bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', ...
50965088
50975089
>>> np.exp.types
5098-
['f->f', 'd->d', 'g->g', 'F->F', 'D->D', 'G->G', 'O->O']
5090+
['e->e', 'f->f', 'd->d', 'f->f', 'd->d', 'g->g', 'F->F', 'D->D', 'G->G', 'O->O']
50995091
51005092
>>> np.remainder.types
5101-
['bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
5102-
'qq->q', 'QQ->Q', 'ff->f', 'dd->d', 'gg->g', 'OO->O']
5093+
['bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', ...
51035094
51045095
"""))
51055096

@@ -5953,7 +5944,7 @@
59535944
>>> import numpy as np
59545945
>>> dt = np.dtype([('name', np.str_, 16), ('grades', np.float64, (2,))])
59555946
>>> print(dt.fields)
5956-
{'grades': (dtype(('float64',(2,))), 16), 'name': (dtype('|S16'), 0)}
5947+
{'name': (dtype('|S16'), 0), 'grades': (dtype(('float64',(2,))), 16)}
59575948
59585949
"""))
59595950

@@ -6131,13 +6122,12 @@
61316122
>>> (arr + arr).dtype.metadata
61326123
mappingproxy({'key': 'value'})
61336124
6134-
But if the arrays have different dtype metadata, the metadata may be
6135-
dropped:
6125+
If the arrays have different dtype metadata, the first one wins:
61366126
61376127
>>> dt2 = np.dtype(float, metadata={"key2": "value2"})
61386128
>>> arr2 = np.array([3, 2, 1], dtype=dt2)
6139-
>>> (arr + arr2).dtype.metadata is None
6140-
True # The metadata field is cleared so None is returned
6129+
>>> print((arr + arr2).dtype.metadata)
6130+
{'key': 'value'}
61416131
"""))
61426132

61436133
add_newdoc('numpy._core.multiarray', 'dtype', ('name',

‎numpy/polynomial/_polybase.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ def degree(self):
685685
686686
Create a polynomial object for ``1 + 7*x + 4*x**2``:
687687
688+
>>> np.polynomial.set_default_printstyle("unicode")
688689
>>> poly = np.polynomial.Polynomial([1, 7, 4])
689690
>>> print(poly)
690691
1.0 + 7.0·x + 4.0 6EC3 ·x²

‎requirements/doc_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ towncrier
1818
toml
1919

2020
# for doctests, also needs pytz which is in test_requirements
21-
scipy-doctest==1.5.1
21+
scipy-doctest==1.6.0

0 commit comments

Comments
 (0)
0