MCPcopy
hub / github.com/numpy/numpy / _sint

Method _sint

numpy/f2py/tests/test_string.py:45–62  ·  view source on GitHub ↗

Return the content of a string buffer as integer value. For example: _sint('1234') -> 4321 _sint('123A') -> 17321

(s, start=0, end=None)

Source from the content-addressed store, hash-verified

43
44 @staticmethod
45 def _sint(s, start=0, end=None):
46 """Return the content of a string buffer as integer value.
47
48 For example:
49 _sint('1234') -> 4321
50 _sint('123A') -> 17321
51 """
52 if isinstance(s, np.ndarray):
53 s = s.tobytes()
54 elif isinstance(s, str):
55 s = s.encode()
56 assert isinstance(s, bytes)
57 if end is None:
58 end = len(s)
59 i = 0
60 for j in range(start, min(end, len(s))):
61 i += s[j] * 10**j
62 return i
63
64 def _get_input(self, intent="in"):
65 if intent in ["in"]:

Callers 2

test_intent_inMethod · 0.95
test_intent_inoutMethod · 0.95

Calls 3

encodeMethod · 0.80
minFunction · 0.50
tobytesMethod · 0.45

Tested by

no test coverage detected