def fill_hist(hist, array, weights=None, return_indices=False):
import ROOT<EOL>array = np.asarray(array, dtype=np.double)<EOL>if weights is not None:<EOL><INDENT>weights = np.asarray(weights, dtype=np.double)<EOL>if weights.shape[<NUM_LIT:0>] != array.shape[<NUM_LIT:0>]:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if weights.ndim != <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>if isinstance(hist, ROOT.TH3):<EOL><INDENT>if array.ndim != <NUM_LIT:2>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if array.shape[<NUM_LIT:1>] != <NUM_LIT:3>:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>return _librootnumpy.fill_h3(<EOL>ROOT.AsCObject(hist), array, weights, return_indices)<EOL><DEDENT>elif isinstance(hist, ROOT.TH2):<EOL><INDENT>if array.ndim != <NUM_LIT:2>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if array.shape[<NUM_LIT:1>] != <NUM_LIT:2>:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>return _librootnumpy.fill_h2(<EOL>ROOT.AsCObject(hist), array, weights, return_indices)<EOL><DEDENT>elif isinstance(hist, ROOT.TH1):<EOL><INDENT>if array.ndim != <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>return _librootnumpy.fill_h1(<EOL>ROOT.AsCObject(hist), array, weights, return_indices)<EOL><DEDENT>raise TypeError(<EOL>"<STR_LIT>")<EOL>
Fill a ROOT histogram with a NumPy array.

    Parameters
    ----------
    hist : ROOT TH1, TH2, or TH3
        The ROOT histogram to fill.
    array : numpy array of shape [n_samples, n_dimensions]
        The values to fill the histogram with. The number of columns must match
        the dimensionality of the histogram. Supply a flat numpy array when
        filling a 1D histogram.
    weights : numpy array
        A flat numpy array of weights for each sample in ``array``.
    return_indices : bool, optional (default=False)
        If True then return an array of the bin indices filled for each element
        in ``array``.

    Returns
    -------
    indices : numpy array or None
        If ``return_indices`` is True, then return an array of the bin indices
        filled for each element in ``array`` otherwise return None.