Return the content of a string buffer as integer value. For example: _sint('1234') -> 4321 _sint('123A') -> 17321
(s, start=0, end=None)
| 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"]: |
no test coverage detected