def loads(cls, raw: str, *, name: Timegroup) -> 'PredictionInfo': data = json.loads(raw) range_ = data["range"] return cls( name=name, # explicitly passed. (not in `data` before 2.1) time=int(data["time"]), range=(Timestamp(range_[0]), Timestamp(range_[1])), cf=ConsolidationFunctionName(data["cf"]), dsname=MetricName(data["dsname"]), slice=int(data["slice"]), params=dict(data["params"]), )
def loads(cls, raw: str) -> 'PredictionData': data = json.loads(raw) return cls( columns=[str(e) for e in data["columns"]], points=[[None if e is None else float(e) for e in elist] for elist in data["points"]], num_points=int(data["num_points"]), data_twindow=[Timestamp(e) for e in data["data_twindow"]], step=Seconds(data["step"]), )