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

Function scan_rational

numpy/core/src/umath/_rational_tests.c:338–359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

336}
337
338static int
339scan_rational(const char** s, rational* x) {
340 long n,d;
341 int offset;
342 const char* ss;
343 if (sscanf(*s,"%ld%n",&n,&offset)<=0) {
344 return 0;
345 }
346 ss = *s+offset;
347 if (*ss!='/') {
348 *s = ss;
349 *x = make_rational_int(n);
350 return 1;
351 }
352 ss++;
353 if (sscanf(ss,"%ld%n",&d,&offset)<=0 || d<=0) {
354 return 0;
355 }
356 *s = ss+offset;
357 *x = make_rational_slow(n,d);
358 return 1;
359}
360
361/* Expose rational to Python as a numpy scalar */
362

Callers 1

pyrational_newFunction · 0.85

Calls 2

make_rational_intFunction · 0.85
make_rational_slowFunction · 0.85

Tested by

no test coverage detected