# Path: mlpy/auxiliary/io.py
# def load_from_file(filename, import_modules=None):
#     """Load data from file.
# 
#     Different formats are supported.
# 
#     Parameters
#     ----------
#     filename : str
#         Name of the file to load data from.
#     import_modules : str or list
#         List of modules that may be required by the data
#         that need to be imported.
# 
#     Returns
#     -------
#     dict or list :
#         The loaded data. If any errors occur, ``None`` is returned.
# 
#     """
#     for m in listify(import_modules):
#         vars()[m] = importlib.import_module(m)
# 
#     try:
#         with open(filename, 'rb') as f:
#             try:
#                 data = eval(f.read())
#             except TypeError:
#                 f.seek(0, 0)
#                 data = pickle.load(f)
#             except SyntaxError:
#                 f.seek(0, 0)
#                 data = []
#                 for line in f:
#                     data.append(line.strip('\r\n'))
#             finally:
#                 f.seek(0, 0)
#         return data
#     except TypeError:
#         return None
# 
# def save_to_file(filename, data):
#     """Saves data to file.
# 
#     The data can be a dictionary or an object's
#     state and is saved in :mod:`pickle` format.
# 
#     Parameters
#     ----------
#     filename : str
#         Name of the file to which to save the data to.
#     data : dict or object
#         The data to be saved.
# 
#     """
#     path = os.path.dirname(filename)
#     if path and not os.path.exists(path):
#         os.makedirs(path)
# 
#     try:
#         with open(filename, 'wb') as f:
#             pickle.dump(data, f, pickle.HIGHEST_PROTOCOL)
#     except TypeError:
#         return


import numpy as np
from .io import load_from_file, save_to_file
            The name of the file

        Raises
        ------
        ValueError
            If no filename is passed to the function and the member variable
            filename is `None`.

        Notes
        -----
        If an error occurred during saving, the function fails silently.

        """
        if filename is None:
            filename = self._filename
        if filename is None:
            raise ValueError("No filename specified.")

        data = {}
        description = {}
        for name in self.get_field_names():
            data[name] = self._reduce(self._data[name], self._sequence_index + 1)
            data[name][self._sequence_index] = self._reduce(self._data[name][self._sequence_index],
                                                            self._endmarker[name], axis=1)
            if name in self._description:
                description[name + "_descr"] = self._description[name]

        if self._description:
            data.update(description)


# Path: mlpy/auxiliary/io.py
# def load_from_file(filename, import_modules=None):
#     """Load data from file.
# 
#     Different formats are supported.
# 
#     Parameters
#     ----------
#     filename : str
#         Name of the file to load data from.
#     import_modules : str or list
#         List of modules that may be required by the data
#         that need to be imported.
# 
#     Returns
#     -------
#     dict or list :
#         The loaded data. If any errors occur, ``None`` is returned.
# 
#     """
#     for m in listify(import_modules):
#         vars()[m] = importlib.import_module(m)
# 
#     try:
#         with open(filename, 'rb') as f:
#             try:
#                 data = eval(f.read())
#             except TypeError:
#                 f.seek(0, 0)
#                 data = pickle.load(f)
#             except SyntaxError:
#                 f.seek(0, 0)
#                 data = []
#                 for line in f:
#                     data.append(line.strip('\r\n'))
#             finally:
#                 f.seek(0, 0)
#         return data
#     except TypeError:
#         return None
# 
# def save_to_file(filename, data):
#     """Saves data to file.
# 
#     The data can be a dictionary or an object's
#     state and is saved in :mod:`pickle` format.
# 
#     Parameters
#     ----------
#     filename : str
#         Name of the file to which to save the data to.
#     data : dict or object
#         The data to be saved.
# 
#     """
#     path = os.path.dirname(filename)
#     if path and not os.path.exists(path):
#         os.makedirs(path)
# 
#     try:
#         with open(filename, 'wb') as f:
#             pickle.dump(data, f, pickle.HIGHEST_PROTOCOL)
#     except TypeError:
#         return


# Path: mlpy/auxiliary/datasets.py
import numpy as np
from .io import load_from_file, save_to_file

            The name of the file

        Raises
        ------
        ValueError
            If no filename is passed to the function and the member variable
            filename is `None`.

        Notes
        -----
        If an error occurred during saving, the function fails silently.

        """
        if filename is None:
            filename = self._filename
        if filename is None:
            raise ValueError("No filename specified.")

        data = {}
        description = {}
        for name in self.get_field_names():
            data[name] = self._reduce(self._data[name], self._sequence_index + 1)
            data[name][self._sequence_index] = self._reduce(self._data[name][self._sequence_index],
                                                            self._endmarker[name], axis=1)
            if name in self._description:
                description[name + "_descr"] = self._description[name]

        if self._description:
            data.update(description)


        save_to_file(filename, data)