# Path: tupa/model_util.py
# def load_json(filename):
#     """
#     Load dictionary from JSON file
#     :param filename: file to read from
#     """
#     print("Loading from '%s'." % filename)
#     with open(filename, "r") as h:
#         d = json.load(h)
#     return d
# 
# def save_json(filename, d):
#     """
#     Save dictionary to JSON file
#     :param filename: file to write to
#     :param d: dictionary to save
#     """
#     remove_existing(filename)
#     print("Saving to '%s'." % filename)
#     with open(filename, "w") as h:
#         json.dump(d, h, default=jsonify)


from collections import OrderedDict
from ..model_util import load_json, save_json
        """
        pass

    def finished_item(self, train=False, renew=True):
        """
        Called by the parser when a whole item is finished
        """
        pass

    def transition(self, action, axis):
        pass

    def save(self, filename, skip_labels=(), **kwargs):
        """
        Save all parameters to file
        """
        d = OrderedDict((
            ("type", self.model_type),
            ("axes", OrderedDict(
                (a, OrderedDict((("index", i), ("labels", l.save(skip=a in skip_labels)))))  # (all, size)
                for i, (a, l) in enumerate(self.labels.items())
            )),
            ("is_frozen", self.is_frozen),
            ("learning_rate", self.learning_rate),
            ("learning_rate_decay", self.learning_rate_decay),
            ("updates", self.updates),
            ("epoch", self.epoch),
            ("best_score", self.best_score),
        ) + tuple(kwargs.items()))
        self.save_model(filename, d)

# Path: tupa/model_util.py
# def load_json(filename):
#     """
#     Load dictionary from JSON file
#     :param filename: file to read from
#     """
#     print("Loading from '%s'." % filename)
#     with open(filename, "r") as h:
#         d = json.load(h)
#     return d
# 
# def save_json(filename, d):
#     """
#     Save dictionary to JSON file
#     :param filename: file to write to
#     :param d: dictionary to save
#     """
#     remove_existing(filename)
#     print("Saving to '%s'." % filename)
#     with open(filename, "w") as h:
#         json.dump(d, h, default=jsonify)


# Path: tupa/classifiers/classifier.py
from collections import OrderedDict
from ..model_util import load_json, save_json

        """
        pass

    def finished_item(self, train=False, renew=True):
        """
        Called by the parser when a whole item is finished
        """
        pass

    def transition(self, action, axis):
        pass

    def save(self, filename, skip_labels=(), **kwargs):
        """
        Save all parameters to file
        """
        d = OrderedDict((
            ("type", self.model_type),
            ("axes", OrderedDict(
                (a, OrderedDict((("index", i), ("labels", l.save(skip=a in skip_labels)))))  # (all, size)
                for i, (a, l) in enumerate(self.labels.items())
            )),
            ("is_frozen", self.is_frozen),
            ("learning_rate", self.learning_rate),
            ("learning_rate_decay", self.learning_rate_decay),
            ("updates", self.updates),
            ("epoch", self.epoch),
            ("best_score", self.best_score),
        ) + tuple(kwargs.items()))
        self.save_model(filename, d)

        save_json(filename + ".json", d)