MCPcopy Create free account
hub / github.com/numpy/numpy / _decode_line

Function _decode_line

numpy/lib/_iotools.py:11–34  ·  view source on GitHub ↗

Decode bytes from binary input streams. Defaults to decoding from 'latin1'. That differs from the behavior of np.compat.asunicode that decodes from 'ascii'. Parameters ---------- line : str or bytes Line to be decoded. encoding : str Encoding used to decod

(line, encoding=None)

Source from the content-addressed store, hash-verified

9
10
11def _decode_line(line, encoding=None):
12 """Decode bytes from binary input streams.
13
14 Defaults to decoding from 'latin1'. That differs from the behavior of
15 np.compat.asunicode that decodes from 'ascii'.
16
17 Parameters
18 ----------
19 line : str or bytes
20 Line to be decoded.
21 encoding : str
22 Encoding used to decode `line`.
23
24 Returns
25 -------
26 decoded_line : str
27
28 """
29 if type(line) is bytes:
30 if encoding is None:
31 encoding = "latin1"
32 line = line.decode(encoding)
33
34 return line
35
36
37def _is_string_like(obj):

Callers 3

genfromtxtFunction · 0.85
__init__Method · 0.85
__call__Method · 0.85

Calls 1

decodeMethod · 0.80

Tested by

no test coverage detected