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

Method _sint

numpy/f2py/tests/test_string.py:43–60  ·  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

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