Skip to content

Commit 1ab8806

Browse files
authored
Merge pull request numpy#25964 from mattip/doc-fixes2
CI: fix last docbuild warnings
2 parents 3b246c6 + 8df4cfb commit 1ab8806

File tree

6 files changed

+61
-20
lines changed

6 files changed

+61
-20
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ _defaults: &defaults
99
docker:
1010
# CircleCI maintains a library of pre-built images
1111
# documented at https://circleci.com/developer/images/image/cimg/python
12-
- image: cimg/python:3.11.4
12+
- image: cimg/python:3.11.8
1313
working_directory: ~/repo
1414

1515

@@ -74,7 +74,7 @@ jobs:
7474
. venv/bin/activate
7575
cd doc
7676
# Don't use -q, show warning summary"
77-
SPHINXOPTS="-j2 -n" make -e html || echo "ignoring errors for now, see gh-13114"
77+
SPHINXOPTS="-j2 -n" make -e html
7878
if [[ $(find build/html -type f | wc -l) -lt 1000 ]]; then
7979
echo "doc build failed: build/html is empty"
8080
exit -1
@@ -85,7 +85,7 @@ jobs:
8585
command: |
8686
. venv/bin/activate
8787
cd doc/neps
88-
SPHINXOPTS="-j2 -q" make -e html
88+
SPHINXOPTS="-j2 -n" make -e html || echo "ignoring errors for now"
8989
9090
- store_artifacts:
9191
path: doc/build/html/

doc/source/conf.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,3 +585,12 @@ class NumPyLexer(CLexer):
585585
breathe_projects = dict(numpy=os.path.join("..", "build", "doxygen", "xml"))
586586
breathe_default_project = "numpy"
587587
breathe_default_members = ("members", "undoc-members", "protected-members")
588+
589+
# See https://github.com/breathe-doc/breathe/issues/696
590+
nitpick_ignore = [
591+
('c:identifier', 'FILE'),
592+
('c:identifier', 'size_t'),
593+
('c:identifier', 'PyHeapTypeObject'),
594+
]
595+
596+

doc/source/user/how-to-io.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ created with NumPy 1.26.
327327
Convert from a pandas DataFrame to a NumPy array
328328
================================================
329329

330-
See :meth:`pandas.DataFrame.to_numpy`.
330+
See :meth:`pandas.Series.to_numpy`.
331331

332332
Save/restore using `~numpy.ndarray.tofile` and `~numpy.fromfile`
333333
================================================================

numpy/_core/records.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ def fromarrays(arrayList, dtype=None, shape=None, formats=None,
583583
``arrayList[0]``.
584584
formats, names, titles, aligned, byteorder :
585585
If `dtype` is ``None``, these arguments are passed to
586-
`numpy.format_parser` to construct a dtype. See that function for
586+
`numpy.rec.format_parser` to construct a dtype. See that function for
587587
detailed documentation.
588588
589589
Returns

numpy/lib/_npyio_impl.py

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,34 @@ def __repr__(self):
278278
array_names += "..."
279279
return f"NpzFile {filename!r} with keys: {array_names}"
280280

281+
# Work around problems with the docstrings in the Mapping methods
282+
# They contain a `->`, which confuses the type annotation interpretations
283+
# of sphinx-docs. See gh-25964
284+
285+
def get(self, key, default=None, /):
286+
"""
287+
D.get(k,[,d]) returns D[k] if k in D, else d. d defaults to None.
288+
"""
289+
return Mapping.get(self, key, default)
290+
291+
def items(self):
292+
"""
293+
D.items() returns a set-like object providing a view on the items
294+
"""
295+
return Mapping.items(self)
296+
297+
def keys(self):
298+
"""
299+
D.keys() returns a set-like object providing a view on the keys
300+
"""
301+
return Mapping.keys(self)
302+
303+
def values(self):
304+
"""
305+
D.values() returns a set-like object providing a view on the values
306+
"""
307+
return Mapping.values(self)
308+
281309

282310
@set_module('numpy')
283311
def load(file, mmap_mode=None, allow_pickle=False, fix_imports=True,
@@ -487,9 +515,9 @@ def save(file, arr, allow_pickle=True, fix_imports=True):
487515
arr : array_like
488516
Array data to be saved.
489517
allow_pickle : bool, optional
490-
Allow saving object arrays using Python pickles. Reasons for
518+
Allow saving object arrays using Python pickles. Reasons for
491519
disallowing pickles include security (loading pickled data can execute
492-
arbitrary code) and portability (pickled objects may not be loadable
520+
arbitrary code) and portability (pickled objects may not be loadable
493521
on different Python installations, for example if the stored objects
494522
require libraries that are not available, and not all pickled data is
495523
compatible between Python 2 and Python 3).
@@ -1814,10 +1842,10 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
18141842
.. versionadded:: 1.10.0
18151843
encoding : str, optional
18161844
Encoding used to decode the inputfile. Does not apply when `fname`
1817-
is a file object. The special value 'bytes' enables backward
1845+
is a file object. The special value 'bytes' enables backward
18181846
compatibility workarounds that ensure that you receive byte arrays
1819-
when possible and passes latin1 encoded strings to converters.
1820-
Override this value to receive unicode arrays and pass strings
1847+
when possible and passes latin1 encoded strings to converters.
1848+
Override this value to receive unicode arrays and pass strings
18211849
as input to converters. If set to None the system default is used.
18221850
The default value is 'bytes'.
18231851
@@ -1854,7 +1882,7 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
18541882
* Individual values are not stripped of spaces by default.
18551883
When using a custom converter, make sure the function does remove spaces.
18561884
* Custom converters may receive unexpected values due to dtype
1857-
discovery.
1885+
discovery.
18581886
18591887
References
18601888
----------
@@ -2127,7 +2155,7 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
21272155
except ValueError:
21282156
# We couldn't find it: the name must have been dropped
21292157
continue
2130-
# Redefine the key if it's a column number
2158+
# Redefine the key if it's a column number
21312159
# and usecols is defined
21322160
if usecols:
21332161
try:
@@ -2161,23 +2189,23 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
21612189
if len(dtype_flat) > 1:
21622190
# Flexible type : get a converter from each dtype
21632191
zipit = zip(dtype_flat, missing_values, filling_values)
2164-
converters = [StringConverter(dt,
2192+
converters = [StringConverter(dt,
21652193
locked=True,
2166-
missing_values=miss,
2194+
missing_values=miss,
21672195
default=fill)
21682196
for (dt, miss, fill) in zipit]
21692197
else:
21702198
# Set to a default converter (but w/ different missing values)
21712199
zipit = zip(missing_values, filling_values)
2172-
converters = [StringConverter(dtype,
2200+
converters = [StringConverter(dtype,
21732201
locked=True,
2174-
missing_values=miss,
2202+
missing_values=miss,
21752203
default=fill)
21762204
for (miss, fill) in zipit]
21772205
# Update the converters to use the user-defined ones
21782206
uc_update = []
21792207
for (j, conv) in user_converters.items():
2180-
# If the converter is specified by column names,
2208+
# If the converter is specified by column names,
21812209
# use the index instead
21822210
if _is_string_like(j):
21832211
try:
@@ -2201,8 +2229,8 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
22012229
if conv is bytes:
22022230
user_conv = asbytes
22032231
elif byte_converters:
2204-
# Converters may use decode to workaround numpy's old
2205-
# behavior, so encode the string again before passing
2232+
# Converters may use decode to workaround numpy's old
2233+
# behavior, so encode the string again before passing
22062234
# to the user converter.
22072235
def tobytes_first(x, conv):
22082236
if type(x) is bytes:
@@ -2338,7 +2366,7 @@ def tobytes_first(x, conv):
23382366
"argument is deprecated. Set the encoding, use None for the "
23392367
"system default.",
23402368
np.exceptions.VisibleDeprecationWarning, stacklevel=2)
2341-
2369+
23422370
def encode_unicode_cols(row_tup):
23432371
row = list(row_tup)
23442372
for i in strcolidx:

numpy/lib/tests/test_io.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2760,12 +2760,16 @@ def test_npzfile_dict():
27602760
assert_(f in ['x', 'y'])
27612761
assert_equal(a.shape, (3, 3))
27622762

2763+
for a in z.values():
2764+
assert_equal(a.shape, (3, 3))
2765+
27632766
assert_(len(z.items()) == 2)
27642767

27652768
for f in z:
27662769
assert_(f in ['x', 'y'])
27672770

27682771
assert_('x' in z.keys())
2772+
assert (z.get('x') == z['x']).all()
27692773

27702774

27712775
@pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts")

0 commit comments

Comments
 (0)