@staticmethod
def write(automaton_in, filename, format='json'):
    """ write input automaton into a file with the given format.

        - Input:

        :param Automaton automaton_in: automaton to write into the file
        :param str filename: the name of the file. If it does not exist,
         the file is created.
        :param str format: 'json' or yaml'
        """
    from splearn.serializer import Serializer
    if format == 'json':
        data_str = Serializer.data_to_json(automaton_in)
    elif format == 'yaml':
        data_str = Serializer.data_to_yaml(automaton_in)
    else:
        raise ValueError('Invalid input format. Should be "json" or "yaml"')
    with open(filename, 'w') as outfile:
        outfile.write(data_str)
