Shortcuts

Source code for ts.metrics.metric_encoder



"""
Metric Encoder class for json dumps
"""

import json
from json import JSONEncoder

from ts.metrics.dimension import Dimension
from ts.metrics.metric import Metric


[docs]class MetricEncoder(JSONEncoder): """ Encoder class for json encoding Metric Object """
[docs] def default(self, obj): # pylint: disable=arguments-differ, method-hidden """ Override only when object is of type Metric """ if isinstance(obj, (Metric, Dimension)): return obj.to_dict() return json.JSONEncoder.default(self, obj)

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources