def hex_to_bin(hex_str: str, width: int = 32) -> str:
    """Converts hex string to binary string

    Parameters
    ----------
    hex_str : str
        hexadecimal string to convert

    width : int, optional
        width of binary output (used for zero padding), default=32

    Returns
    -------
    str
        binary array as string

    Raises
    ------
    ValueError
        raises ValueError if supplied width is not wide enough for binary string
    """
    if len(hex_str)*4 > width:
        raise ValueError(
            f"Hex string of length {len(hex_str)} too large for binary array of width {width}"
        )

    format_str = f"{{0:0{width}b}}"

    return format_str.format(int(hex_str, 16))