def METHOD_NAME(weights, natoms, ncsets=None, dtype=float):
    """Returns *weights* if it has correct shape ([ncsets, ]natoms, 1).
    after its shape and data type is corrected. otherwise raise an exception.
    All items of *weights* must be greater than zero."""
    try:
        ndim, shape, wtype = weights.ndim, weights.shape, weights.dtype
    except AttributeError:
        raise TypeError('weights must be a numpy.ndarray instance')
    if ncsets:
        if ndim not in NDIM123:
            raise ValueError('weights.dim must be 1, 2, or 3')
        if ndim == 3:
            if shape[0] != ncsets:
                raise ValueError('weights.shape must be '
                                '(ncsets, natoms[, 1])')
        if ndim < 3:
            weights = tile(weights.reshape((1, natoms, 1)), (ncsets, 1, 1))
    else:
        if ndim not in NDIM12:
            raise ValueError('weights.dim must be 1 or 2')
        if shape[0] != natoms:
            raise ValueError('weights.shape must be (natoms[, 1])')
        if ndim == 1:
            weights = weights.reshape((natoms, 1))
    if dtype:
        if wtype != dtype:
            try:
                weights = weights.astype(dtype)
            except ValueError:
                raise ValueError('weights.astype({0}) failed, {0} type '
                                   'could not be assigned'.format(str(dtype)))
    if any(weights < 0):
        raise ValueError('all weights must be greater or equal to 0')
    return weights