{ } Raw JSON

bundles / numpy 2.4.4 / numpy / lib / _iotools / easy_dtype

function

numpy.lib._iotools:easy_dtype

source: /numpy/lib/_iotools.py :824

Signature

def   easy_dtype ( ndtype names = None defaultfmt = f%i ** validationargs )

Summary

Convenience function to create a np.dtype object.

Extended Summary

The function processes the input dtype and matches it with the given names.

Parameters

ndtype : var

Definition of the dtype. Can be any string or dictionary recognized by the np.dtype function, or a sequence of types.

names : str or sequence, optional

Sequence of strings to use as field names for a structured dtype. For convenience, names can be a string of a comma-separated list of names.

defaultfmt : str, optional

Format string used to define missing names, such as "f%i" (default) or "fields_%02i".

validationargs : optional

A series of optional arguments used to initialize a NameValidator.

Examples

import numpy as np
np.lib._iotools.easy_dtype(float)
np.lib._iotools.easy_dtype("i4, f8")
np.lib._iotools.easy_dtype("i4, f8", defaultfmt="field_%03i")
np.lib._iotools.easy_dtype((int, float, float), names="a,b,c")
np.lib._iotools.easy_dtype(float, names="a,b,c")

Aliases

  • numpy.lib._iotools.easy_dtype