def _parse_coord(sample, variables):
    """
    See if the variables in the sample are a valid encoding of a coordinate.

    The encoding is defined this way:
        For n-1 variables, the axis' range is {0, 1, ..., n}.
        A coordinate with value x is encoded as
            v_i = 0 for x <= i < n - 1
            v_i = 1 for 0 <= i < x
    """
    coord = 0
    for v, v_index in enumerate(variables):
        if sample[v_index] == 1:
            coord = v + 1
            if v != 0 and sample[v_index - 1] == 0:
                # Not a valid encoding
                return None
    return coord