  against
    msg_prefix : str
        A prefix to put before the message, typically the name of the argument

    Returns
    -------
    normalized_axis : int
        The normalized axis index, such that `0 <= normalized_axis < ndim`

    Raises
    ------
    AxisError
        If the axis index is invalid, when `-ndim <= axis < ndim` is false.

    Examples
    --------
    >>> normalize_axis_index(0, ndim=3)
    0
    >>> normalize_axis_index(1, ndim=3)
    1
    >>> normalize_axis_index(-1, ndim=3)
    2

    >>> normalize_axis_index(3, ndim=3)
    Traceback (most recent call last):
    ...
    AxisError: axis 3 is out of bounds for array of dimension 3
    >>> normalize_axis_index(-4, ndim=3, msg_prefix='axes_arg')
    Traceback (most recent call last):
    ...
    AxisError: axes_arg: axis -4 is out of bounds for array of dimension 3
    """)

add_newdoc('numpy.core.multiarray', 'datetime_data',
    """
    datetime_data(dtype, /)

    Get information about the step size of a date or time type.

    The returned tuple can be passed as the second argument of `numpy.datetime64` and
    `numpy.timedelta64`.

    Parameters
    ----------
    dtype : dtype
        The dtype object, which must be a `datetime64` or `timedelta64` type.

    Returns
    -------
    unit : str
        The :ref:`datetime unit <arrays.dtypes.dateunits>` on which this dtype
        is based.
    count : int
        The number of base units in a step.

    Examples
    --------
    >>> dt_25s = np.dtype('timedelta64[25s]')
    >>> np.datetime_data(dt_25s)
    ('s', 25)
    >>> np.array(10, dt_25s).astype('timedelta64[s]')
    array(250, dtype='timedelta64[s]')

    The result can be used to construct a datetime that uses the same units
    as a timedelta

    >>> np.datetime64('2010', np.datetime_data(dt_25s))
    numpy.datetime64('2010-01-01T00:00:00','25s')
    """)


##############################################################################
#
# Documentation for `generic` attributes and methods
#
##############################################################################

add_newdoc('numpy.core.numerictypes', 'generic',
    """
    Base class for numpy scalar types.

    Class from which most (all?) numpy scalar types are derived.  For
    consistency, exposes the same API as `ndarray`, despite many
    consequent attributes being either "get-only," or completely irrelevant.
    This is the class from which it is strongly suggested users should derive
    custom scalar types.

    """)

# Attributes

def refer_to_array_attribute(attr, method=True):
    docstring = """
    Scalar {} identical to the corresponding array attribute.

    Please see `ndarray.{}`.
    """

    return attr, docstring.format("method" if method else "attribute", attr)


add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('T', method=False))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('base', method=False))

add_newdoc('numpy.core.numerictypes', 'generic', ('data',
    """Pointer to start of data."""))

add_newdoc('numpy.core.numerictypes', 'generic', ('dtype',
    """Get array data-descriptor."""))

add_newdoc('numpy.core.numerictypes', 'generic', ('flags',
    """The integer value of flags."""))

add_newdoc('numpy.core.numerictypes', 'generic', ('flat',
    """A 1-D view of the scalar."""))

add_newdoc('numpy.core.numerictypes', 'generic', ('imag',
    """The imaginary part of the scalar."""))

add_newdoc('numpy.core.numerictypes', 'generic', ('itemsize',
    """The length of one element in bytes."""))

add_newdoc('numpy.core.numerictypes', 'generic', ('nbytes',
    """The length of the scalar in bytes."""))

add_newdoc('numpy.core.numerictypes', 'generic', ('ndim',
    """The number of array dimensions."""))

add_newdoc('numpy.core.numerictypes', 'generic', ('real',
    """The real part of the scalar."""))

add_newdoc('numpy.core.numerictypes', 'generic', ('shape',
    """Tuple of array dimensions."""))

add_newdoc('numpy.core.numerictypes', 'generic', ('size',
    """The number of elements in the gentype."""))

add_newdoc('numpy.core.numerictypes', 'generic', ('strides',
    """Tuple of bytes steps in each dimension."""))

# Methods

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('all'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('any'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('argmax'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('argmin'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('argsort'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('astype'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('byteswap'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('choose'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('clip'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('compress'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('conjugate'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('copy'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('cumprod'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('cumsum'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('diagonal'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('dump'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('dumps'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('fill'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('flatten'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('getfield'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('item'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('itemset'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('max'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('mean'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('min'))

add_newdoc('numpy.core.numerictypes', 'generic', ('newbyteorder',
    """
    newbyteorder(new_order='S', /)

    Return a new `dtype` with a different byte order.

    Changes are also made in all fields and sub-arrays of the data type.

    The `new_order` code can be any from the following:

    * 'S' - swap dtype from current to opposite endian
    * {'<', 'little'} - little endian
    * {'>', 'big'} - big endian
    * {'=', 'native'} - native order
    * {'|', 'I'} - ignore (no change to byte order)

    Parameters
    ----------
    new_order : str, optional
        Byte order to force; a value from the byte order specifications
        above.  The default value ('S') results in swapping the current
        byte order.


    Returns
    -------
    new_dtype : dtype
        New `dtype` object with the given change to the byte order.

    """))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('nonzero'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('prod'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('ptp'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('put'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('ravel'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('repeat'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('reshape'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('resize'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('round'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('searchsorted'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('setfield'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('setflags'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('sort'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('squeeze'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('std'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('sum'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('swapaxes'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('take'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('tofile'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('tolist'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('tostring'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('trace'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('transpose'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('var'))

add_newdoc('numpy.core.numerictypes', 'generic',
           refer_to_array_attribute('view'))

add_newdoc('numpy.core.numerictypes', 'number', ('__class_getitem__',
    """
    __class_getitem__(item, /)

    Return a parametrized wrapper around the `~numpy.number` type.

    .. versionadded:: 1.22

    Returns
    -------
    alias : types.GenericAlias
        A parametrized `~numpy.number` type.

    Examples
    --------
    >>> from typing import Any
    >>> import numpy as np

    >>> np.signedinteger[Any]
    numpy.signedinteger[typing.Any]

    Notes
    -----
    This method is only available for python 3.9 and later.

    See Also
    --------
    :pep:`585` : Type hinting generics in standard collections.

    """))

##############################################################################
#
# Documentation for scalar type abstract base classes in type hierarchy
#
##############################################################################


add_newdoc('numpy.core.numerictypes', 'number',
    """
    Abstract base class of all numeric scalar types.

    """)

add_newdoc('numpy.core.numerictypes', 'integer',
    """
    Abstract base class of all integer scalar types.

    """)

add_newdoc('numpy.core.numerictypes', 'signedinteger',
    """
    Abstract base class of all signed integer scalar types.

    """)

add_newdoc('numpy.core.numerictypes', 'unsignedinteger',
    """
    Abstract base class of all unsigned integer scalar types.

    """)

add_newdoc('numpy.core.numerictypes', 'inexact',
    """
    Abstract base class of all numeric scalar types with a (potentially)
    inexact representation of the values in its range, such as
    floating-point numbers.

    """)

add_newdoc('numpy.core.numerictypes', 'floating',
    """
    Abstract base class of all floating-point scalar types.

    """)

add_newdoc('numpy.core.numerictypes', 'complexfloating',
    """
    Abstract base class of all complex number scalar types that are made up of
    floating-point numbers.

    """)

add_newdoc('numpy.core.numerictypes', 'flexible',
    """
    Abstract base class of all scalar types without predefined length.
    The actual size of these types depends on the specific `np.dtype`
    instantiation.

    """)

add_newdoc('numpy.core.numerictypes', 'character',
    """
    Abstract base class of all character string scalar types.

    """)
