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

Function _get_format_function

numpy/core/arrayprint.py:452–490  ·  view source on GitHub ↗

find the right formatting function for the dtype_

(data, **options)

Source from the content-addressed store, hash-verified

450 return formatdict
451
452def _get_format_function(data, **options):
453 """
454 find the right formatting function for the dtype_
455 """
456 dtype_ = data.dtype
457 dtypeobj = dtype_.type
458 formatdict = _get_formatdict(data, **options)
459 if dtypeobj is None:
460 return formatdict["numpystr"]()
461 elif issubclass(dtypeobj, _nt.bool_):
462 return formatdict['bool']()
463 elif issubclass(dtypeobj, _nt.integer):
464 if issubclass(dtypeobj, _nt.timedelta64):
465 return formatdict['timedelta']()
466 else:
467 return formatdict['int']()
468 elif issubclass(dtypeobj, _nt.floating):
469 if issubclass(dtypeobj, _nt.longfloat):
470 return formatdict['longfloat']()
471 else:
472 return formatdict['float']()
473 elif issubclass(dtypeobj, _nt.complexfloating):
474 if issubclass(dtypeobj, _nt.clongfloat):
475 return formatdict['longcomplexfloat']()
476 else:
477 return formatdict['complexfloat']()
478 elif issubclass(dtypeobj, (_nt.str_, _nt.bytes_)):
479 return formatdict['numpystr']()
480 elif issubclass(dtypeobj, _nt.datetime64):
481 return formatdict['datetime']()
482 elif issubclass(dtypeobj, _nt.object_):
483 return formatdict['object']()
484 elif issubclass(dtypeobj, _nt.void):
485 if dtype_.names is not None:
486 return StructuredVoidFormat.from_data(data, **options)
487 else:
488 return formatdict['void']()
489 else:
490 return formatdict['numpystr']()
491
492
493def _recursive_guard(fillvalue='...'):

Callers 2

_array2stringFunction · 0.85
from_dataMethod · 0.85

Calls 2

_get_formatdictFunction · 0.85
from_dataMethod · 0.80

Tested by

no test coverage detected