@@ -278,6 +278,34 @@ def __repr__(self):
278
278
array_names += "..."
279
279
return f"NpzFile { filename !r} with keys: { array_names } "
280
280
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
+
281
309
282
310
@set_module ('numpy' )
283
311
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):
487
515
arr : array_like
488
516
Array data to be saved.
489
517
allow_pickle : bool, optional
490
- Allow saving object arrays using Python pickles. Reasons for
518
+ Allow saving object arrays using Python pickles. Reasons for
491
519
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
493
521
on different Python installations, for example if the stored objects
494
522
require libraries that are not available, and not all pickled data is
495
523
compatible between Python 2 and Python 3).
@@ -1814,10 +1842,10 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
1814
1842
.. versionadded:: 1.10.0
1815
1843
encoding : str, optional
1816
1844
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
1818
1846
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
1821
1849
as input to converters. If set to None the system default is used.
1822
1850
The default value is 'bytes'.
1823
1851
@@ -1854,7 +1882,7 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
1854
1882
* Individual values are not stripped of spaces by default.
1855
1883
When using a custom converter, make sure the function does remove spaces.
1856
1884
* Custom converters may receive unexpected values due to dtype
1857
- discovery.
1885
+ discovery.
1858
1886
1859
1887
References
1860
1888
----------
@@ -2127,7 +2155,7 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
2127
2155
except ValueError :
2128
2156
# We couldn't find it: the name must have been dropped
2129
2157
continue
2130
- # Redefine the key if it's a column number
2158
+ # Redefine the key if it's a column number
2131
2159
# and usecols is defined
2132
2160
if usecols :
2133
2161
try :
@@ -2161,23 +2189,23 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
2161
2189
if len (dtype_flat ) > 1 :
2162
2190
# Flexible type : get a converter from each dtype
2163
2191
zipit = zip (dtype_flat , missing_values , filling_values )
2164
- converters = [StringConverter (dt ,
2192
+ converters = [StringConverter (dt ,
2165
2193
locked = True ,
2166
- missing_values = miss ,
2194
+ missing_values = miss ,
2167
2195
default = fill )
2168
2196
for (dt , miss , fill ) in zipit ]
2169
2197
else :
2170
2198
# Set to a default converter (but w/ different missing values)
2171
2199
zipit = zip (missing_values , filling_values )
2172
- converters = [StringConverter (dtype ,
2200
+ converters = [StringConverter (dtype ,
2173
2201
locked = True ,
2174
- missing_values = miss ,
2202
+ missing_values = miss ,
2175
2203
default = fill )
2176
2204
for (miss , fill ) in zipit ]
2177
2205
# Update the converters to use the user-defined ones
2178
2206
uc_update = []
2179
2207
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,
2181
2209
# use the index instead
2182
2210
if _is_string_like (j ):
2183
2211
try :
@@ -2201,8 +2229,8 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
2201
2229
if conv is bytes :
2202
2230
user_conv = asbytes
2203
2231
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
2206
2234
# to the user converter.
2207
2235
def tobytes_first (x , conv ):
2208
2236
if type (x ) is bytes :
@@ -2338,7 +2366,7 @@ def tobytes_first(x, conv):
2338
2366
"argument is deprecated. Set the encoding, use None for the "
2339
2367
"system default." ,
2340
2368
np .exceptions .VisibleDeprecationWarning , stacklevel = 2 )
2341
-
2369
+
2342
2370
def encode_unicode_cols (row_tup ):
2343
2371
row = list (row_tup )
2344
2372
for i in strcolidx :
0 commit comments