Write a one-sentence description of the following Python function that conforms to the expectations of a docstring from pydocstyle:

def calculate_average(array: np.ndarray, weights: np.ndarray) -> float:
    if len(array) != len(weights):
        raise ValueError("Lengths of array and weights do not match.")

    weighted_sum = np.sum(array * weights)
    total_weight = np.sum(weights)
    return weighted_sum / total_weight