def validate_voicing(ref_voicing, est_voicing):
    """Checks that voicing inputs to a metric are in the correct format.

    Parameters
    ----------
    ref_voicing : np.ndarray
        Reference boolean voicing array
    est_voicing : np.ndarray
        Estimated boolean voicing array

    """
    if ref_voicing.size == 0:
        warnings.warn("Reference voicing array is empty.")
    if est_voicing.size == 0:
        warnings.warn("Estimated voicing array is empty.")
    if ref_voicing.sum() == 0:
        warnings.warn("Reference melody has no voiced frames.")
    if est_voicing.sum() == 0:
        warnings.warn("Estimated melody has no voiced frames.")
    # Make sure they're the same length
    if ref_voicing.shape[0] != est_voicing.shape[0]:
        raise ValueError('Reference and estimated voicing arrays should '
                         'be the same length.')
    for voicing in [ref_voicing, est_voicing]:
        # Make sure they're (effectively) boolean
        if np.logical_and(voicing != 0, voicing != 1).any():
            raise ValueError('Voicing arrays must be boolean.')
def validate_voicing ( ref_voicing , est_voicing ) : if ref_voicing . size == 0 : warnings . warn ( "Reference voicing array is empty." ) if est_voicing . size == 0 : warnings . warn ( "Estimated voicing array is empty." ) if ref_voicing . sum ( ) == 0 : warnings . warn ( "Reference melody has no voiced frames." ) if est_voicing . sum ( ) == 0 : warnings . warn ( "Estimated melody has no voiced frames." ) if ref_voicing . shape [ 0 ] != est_voicing . shape [ 0 ] : raise ValueError ( 'Reference and estimated voicing arrays should ' 'be the same length.' ) for voicing in [ ref_voicing , est_voicing ] : if np . logical_and ( voicing != 0 , voicing != 1 ) . any ( ) : raise ValueError ( 'Voicing arrays must be boolean.' )
Checks that voicing inputs to a metric are in the correct format.

    Parameters
    ----------
    ref_voicing : np.ndarray
        Reference boolean voicing array
    est_voicing : np.ndarray
        Estimated boolean voicing array