import logging


def calc_bpm(num_beats, dur):
    """
    Determines the beats per minute of an ECG signal

    Args:
        num_beats: number of total beats
        dur: duration of ECG signal
    Returns:
        bpm: average beats per minute
    """
    bpm = num_beats/(dur/60)

    if bpm > 180:
        logging.warning("Average heart rate detected to be more than 180 bpm.")
    if bpm < 40:
        logging.warning("Average heart rate detected to be less than 40 bpm.")
    return bpm