# Path: hydra_base/config.py
# PYTHONVERSION = sys.version_info
# CONFIG = None
#     CONFIG = config
# def load_config():
# def read_values_from_environment(config, section_key, options_key):
# def set_windows_env_variables(config):
# def get(section, option, default=None):
# def getint(section, option, default=None):
# 
# Path: hydra_base/lib/HydraTypes/Encodings.py
# class ScalarJSON(object):
#     def __get__(self, instance, owner):
#         return json.dumps({owner.tag : { arg : getattr(instance, arg) for arg in owner.ctor_fmt }})
# 
#     def __set__(self, instance, encstr):
#         jo = json.loads(encstr)[instance.tag]
#         for arg in instance.ctor_fmt:
#             setattr(instance, arg, jo[arg])
# 
# class ArrayJSON(object):
#     def __get__(self, instance, owner):
#         return json.dumps({owner.tag : instance.data.to_dict()})
# 
#     def __set__(self, instance, encstr):
#         data = json.loads(encstr)[instance.tag]
#         instance.data = pd.DataFrame.from_dict(data)
# 
# class DescriptorJSON(object):
#     def __get__(self, instance, owner):
#         return ""
# 
#     def __set__(self, instance, encstr):
#         pass
# 
# class DataframeJSON(object):
#     def __get__(self, instance, owner):
#         return "{}"
# 
#     def __set__(self, instance, encstr):
#         pass
# 
# class TimeseriesJSON(object):
#     def __get__(self, instance, owner):
#         return "{}"
# 
#     def __set__(self, instance, encstr):
#         pass
# 
# Path: hydra_base/exceptions.py
# class HydraError(Exception):
#     __error_code__ = None
# 
#     def __init__(self, message="A hydra error has occurred"):
#         # Call the base class constructor with the parameters it needs
#         self.code = error_codes.get(self.__error_code__, '0000')
#         self.message = message # Added for Py3
#         super(HydraError, self).__init__({"message": message, "code": self.code})


import json
import math
import six
import numpy as np
import pandas as pd
import collections
import logging
from abc import abstractmethod, abstractproperty
from datetime import datetime
from hydra_base import config
from .Encodings import ScalarJSON, ArrayJSON, DescriptorJSON, DataframeJSON, TimeseriesJSON
from hydra_base.exceptions import HydraError
        from .Registry import typemap
                self._value = df
                self.validate()
            except Exception as e:
                """ ...and fail if neither """
                raise HydraError(str(e))

    value = property(get_value, set_value)

class Timeseries(DataType):
    tag      = "TIMESERIES"
    name     = "Time Series"
    skeleton = "[%s, ...]"
    json     = TimeseriesJSON()

    def __init__(self, ts):
        super(Timeseries, self).__init__()
        self.value = ts
        self.validate()

    @classmethod
    def fromDataset(cls, value, metadata=None):
        ordered_jo = json.loads(six.text_type(value), object_pairs_hook=collections.OrderedDict)
        ts = pd.DataFrame.from_dict(ordered_jo)
        return cls(ts)


    def validate(self):
        base_ts = pd.Timestamp("01-01-1970")
        #TODO: We need a more permanent solution to seasonal/repeating timeseries
        seasonal_year = config.get('DEFAULT','seasonal_year', '1678')

# Path: hydra_base/config.py
# PYTHONVERSION = sys.version_info
# CONFIG = None
#     CONFIG = config
# def load_config():
# def read_values_from_environment(config, section_key, options_key):
# def set_windows_env_variables(config):
# def get(section, option, default=None):
# def getint(section, option, default=None):
# 
# Path: hydra_base/lib/HydraTypes/Encodings.py
# class ScalarJSON(object):
#     def __get__(self, instance, owner):
#         return json.dumps({owner.tag : { arg : getattr(instance, arg) for arg in owner.ctor_fmt }})
# 
#     def __set__(self, instance, encstr):
#         jo = json.loads(encstr)[instance.tag]
#         for arg in instance.ctor_fmt:
#             setattr(instance, arg, jo[arg])
# 
# class ArrayJSON(object):
#     def __get__(self, instance, owner):
#         return json.dumps({owner.tag : instance.data.to_dict()})
# 
#     def __set__(self, instance, encstr):
#         data = json.loads(encstr)[instance.tag]
#         instance.data = pd.DataFrame.from_dict(data)
# 
# class DescriptorJSON(object):
#     def __get__(self, instance, owner):
#         return ""
# 
#     def __set__(self, instance, encstr):
#         pass
# 
# class DataframeJSON(object):
#     def __get__(self, instance, owner):
#         return "{}"
# 
#     def __set__(self, instance, encstr):
#         pass
# 
# class TimeseriesJSON(object):
#     def __get__(self, instance, owner):
#         return "{}"
# 
#     def __set__(self, instance, encstr):
#         pass
# 
# Path: hydra_base/exceptions.py
# class HydraError(Exception):
#     __error_code__ = None
# 
#     def __init__(self, message="A hydra error has occurred"):
#         # Call the base class constructor with the parameters it needs
#         self.code = error_codes.get(self.__error_code__, '0000')
#         self.message = message # Added for Py3
#         super(HydraError, self).__init__({"message": message, "code": self.code})


# Path: hydra_base/lib/HydraTypes/Types.py
import json
import math
import six
import numpy as np
import pandas as pd
import collections
import logging
from abc import abstractmethod, abstractproperty
from datetime import datetime
from hydra_base import config
from .Encodings import ScalarJSON, ArrayJSON, DescriptorJSON, DataframeJSON, TimeseriesJSON
from hydra_base.exceptions import HydraError
        from .Registry import typemap

                self._value = df
                self.validate()
            except Exception as e:
                """ ...and fail if neither """
                raise HydraError(str(e))

    value = property(get_value, set_value)

class Timeseries(DataType):
    tag      = "TIMESERIES"
    name     = "Time Series"
    skeleton = "[%s, ...]"
    json     = TimeseriesJSON()

    def __init__(self, ts):
        super(Timeseries, self).__init__()
        self.value = ts
        self.validate()

    @classmethod
    def fromDataset(cls, value, metadata=None):
        ordered_jo = json.loads(six.text_type(value), object_pairs_hook=collections.OrderedDict)
        ts = pd.DataFrame.from_dict(ordered_jo)
        return cls(ts)


    def validate(self):
        base_ts = pd.Timestamp("01-01-1970")
        #TODO: We need a more permanent solution to seasonal/repeating timeseries
        seasonal_year = config.get('DEFAULT','seasonal_year', '1678')

        seasonal_key = config.get('DEFAULT', 'seasonal_key', '9999')