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

Function PyArray_DebugPrint

numpy/core/src/multiarray/arrayobject.c:495–551  ·  view source on GitHub ↗

NUMPY_API * Prints the raw data of the ndarray in a form useful for debugging * low-level C issues. */

Source from the content-addressed store, hash-verified

493 * low-level C issues.
494 */
495NPY_NO_EXPORT void
496PyArray_DebugPrint(PyArrayObject *obj)
497{
498 int i;
499 PyArrayObject_fields *fobj = (PyArrayObject_fields *)obj;
500
501 printf("-------------------------------------------------------\n");
502 printf(" Dump of NumPy ndarray at address %p\n", obj);
503 if (obj == NULL) {
504 printf(" It's NULL!\n");
505 printf("-------------------------------------------------------\n");
506 fflush(stdout);
507 return;
508 }
509 printf(" ndim : %d\n", fobj->nd);
510 printf(" shape :");
511 for (i = 0; i < fobj->nd; ++i) {
512 printf(" %" NPY_INTP_FMT, fobj->dimensions[i]);
513 }
514 printf("\n");
515
516 printf(" dtype : ");
517 PyObject_Print((PyObject *)fobj->descr, stdout, 0);
518 printf("\n");
519 printf(" data : %p\n", fobj->data);
520 printf(" strides:");
521 for (i = 0; i < fobj->nd; ++i) {
522 printf(" %" NPY_INTP_FMT, fobj->strides[i]);
523 }
524 printf("\n");
525
526 printf(" base : %p\n", fobj->base);
527
528 printf(" flags :");
529 if (fobj->flags & NPY_ARRAY_C_CONTIGUOUS)
530 printf(" NPY_C_CONTIGUOUS");
531 if (fobj->flags & NPY_ARRAY_F_CONTIGUOUS)
532 printf(" NPY_F_CONTIGUOUS");
533 if (fobj->flags & NPY_ARRAY_OWNDATA)
534 printf(" NPY_OWNDATA");
535 if (fobj->flags & NPY_ARRAY_ALIGNED)
536 printf(" NPY_ALIGNED");
537 if (fobj->flags & NPY_ARRAY_WRITEABLE)
538 printf(" NPY_WRITEABLE");
539 if (fobj->flags & NPY_ARRAY_WRITEBACKIFCOPY)
540 printf(" NPY_WRITEBACKIFCOPY");
541 printf("\n");
542
543 if (fobj->base != NULL && PyArray_Check(fobj->base)) {
544 printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
545 printf("Dump of array's BASE:\n");
546 PyArray_DebugPrint((PyArrayObject *)fobj->base);
547 printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
548 }
549 printf("-------------------------------------------------------\n");
550 fflush(stdout);
551}
552

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected