Create a subclass of Coordinate, instances of which must have exactly the given keys.

    Parameters
    ----------
    name : str
        Name of the new class
    keys : sequence
        Keys which instances must exclusively have
    ordered : bool
        Whether to set the class' ``default_order`` based on the order of ``keys``

    Returns
    -------
    type

def spaced_coordinate(name, keys, ordered=True):
    """
    Create a subclass of Coordinate, instances of which must have exactly the given keys.

    Parameters
    ----------
    name : str
        Name of the new class
    keys : sequence
        Keys which instances must exclusively have
    ordered : bool
        Whether to set the class' ``default_order`` based on the order of ``keys``

    Returns
    -------
    type
    """
    def validate(self):
        """Raise a ValueError if the instance's keys are incorrect"""
        if set(keys) != set(self):
            raise ValueError('{} needs keys {} and got {}'.format(type(self).__name__, keys, tuple(self)))

    new_class = type(name, (Coordinate, ), {'default_order': keys if ordered else None, '_validate': validate})
    return new_class