# Path: gridsim/decorators.py
# def accepts(*atypes):
#     """
#     accepts()
# 
#     Type Enforcement. Verifies types of parameters given to the function.
#     
#     *Example:*
#     ::
# 
#         @accepts((0,int), (1,(int,float)))
#         def func(arg1, arg2):
#             return arg1 * arg2
# 
#     .. warning::
#         In a class function, the current class cannot be used (e.g.: ``self``
#         type cannot be defined with ``accepts``)
#     """
# 
#     if __debug__:
#         def check_accepts(func):
# 
#             @wraps(func)
#             def new_func(*args, **keywords):
# 
#                 if len(atypes) != 0 and type(atypes[0]) is not tuple:
#                     raise AttributeError("Missing brackets in accepts of function "
#                                          + func.__name__)
# 
#                 for atype in atypes:
# 
#                     if type(atype[0]) is tuple:
#                         for apos in atype[0]:
# 
#                             default_param = False
#                             try:
#                                 args[apos]
#                             except IndexError:
#                                 default_param = True
# 
#                             if not default_param \
#                                     and not isinstance(args[apos], atype[1]):
#                                 raise TypeError(
#                                     "In '"+func.__name__+"', "
#                                     "params value %r does not "
#                                     "match %s" % (args[apos], atype[1]))
#                     else:
# 
#                         default_param = False
#                         try:
#                             args[atype[0]]
#                         except IndexError:
#                             default_param = True
# 
#                         if not default_param \
#                                 and not isinstance(args[atype[0]], atype[1]):
#                             raise TypeError(
#                                 "In"+func.__name__+", "
#                                 "params value %r does not "
#                                 "match %s" % (args[atype[0]], atype[1]))
# 
#                 return func(*args, **keywords)
# 
#             return new_func
#     else:
#         def check_accepts(func):
#             return func
# 
#     return check_accepts
# 
# Path: gridsim/unit.py
# class _Unit(object):
#     def __init__(self):
#     def Quantity(self):
#     def Unit(self):
#     def __call__(self, *args, **kwargs):
#     def __getattr__(self, item):
#     def to_si(self, measurement_or_unit):
#     def value(self, measurement, unit=None):
#     def unit(self, measurement):
#     def dimension(self, measurement):
#     def convert(self, m, u):
# 
# Path: gridsim/iodata/input.py
# class Reader(object):
# 
#     def __init__(self):
#         """
#         __init__(self)
# 
#         This class is the based class of all readers/loaders.
#         """
#         super(Reader, self).__init__()
# 
#     def clear(self):
#         """
#         clear(self)
# 
#         Empties the data of the Reader.
#         """
#         raise NotImplementedError('Pure abstract method.')
# 
#     @accepts((1, str), (2, int, float))
#     @returns(dict)
#     def load(self, data_type=None, nb_data=float("inf")):
#         """
#         load(self, data_type=None, nb_data=float("inf"))
# 
#         This method MUST returns formatted data following this format
#         ``[(label1, data1], (label2, data2), ...]``
# 
#         with:
# 
#         * ``labelX``: a str
#         * ``dataX``: a list of ``data_type``
# 
#         :param data_type: the type of stored data if ``None`` no conversion
#             are done.
#         :type data_type: type (default None)
#         :param nb_data: the number of data to load
#         :type nb_data: int
# 
#         :return: a dict of values
#         :rtype: dict
#         """
#         raise NotImplementedError('Pure abstract method.')


import types
import warnings
from io import BufferedReader
from types import FunctionType
from .decorators import accepts
from .unit import units
from .iodata.input import Reader
The data are translated into attributes of the :class:`TimeSeries` by calling
the :func:`TimeSeries.load` method on a TimeSeriesObject or any subclass of it::

    obj = TimeSeries()
    obj.load('../../data/examples/example.csv')

This will call the :func:`gridsim.iodata.input.Reader.load` function and process
the data to simplify the access from the simulator.

It is important to have a ``time`` data or to identify the data representing the
time.

If the data contain a ``temperature`` data, it can be access with:

.. literalinclude:: ../../demo/timeseries.py
    :linenos:

This would give an output like this::

    20.0
    18.5

"""




class TimeSeries(object):

    @accepts((1, Reader))

# Path: gridsim/decorators.py
# def accepts(*atypes):
#     """
#     accepts()
# 
#     Type Enforcement. Verifies types of parameters given to the function.
#     
#     *Example:*
#     ::
# 
#         @accepts((0,int), (1,(int,float)))
#         def func(arg1, arg2):
#             return arg1 * arg2
# 
#     .. warning::
#         In a class function, the current class cannot be used (e.g.: ``self``
#         type cannot be defined with ``accepts``)
#     """
# 
#     if __debug__:
#         def check_accepts(func):
# 
#             @wraps(func)
#             def new_func(*args, **keywords):
# 
#                 if len(atypes) != 0 and type(atypes[0]) is not tuple:
#                     raise AttributeError("Missing brackets in accepts of function "
#                                          + func.__name__)
# 
#                 for atype in atypes:
# 
#                     if type(atype[0]) is tuple:
#                         for apos in atype[0]:
# 
#                             default_param = False
#                             try:
#                                 args[apos]
#                             except IndexError:
#                                 default_param = True
# 
#                             if not default_param \
#                                     and not isinstance(args[apos], atype[1]):
#                                 raise TypeError(
#                                     "In '"+func.__name__+"', "
#                                     "params value %r does not "
#                                     "match %s" % (args[apos], atype[1]))
#                     else:
# 
#                         default_param = False
#                         try:
#                             args[atype[0]]
#                         except IndexError:
#                             default_param = True
# 
#                         if not default_param \
#                                 and not isinstance(args[atype[0]], atype[1]):
#                             raise TypeError(
#                                 "In"+func.__name__+", "
#                                 "params value %r does not "
#                                 "match %s" % (args[atype[0]], atype[1]))
# 
#                 return func(*args, **keywords)
# 
#             return new_func
#     else:
#         def check_accepts(func):
#             return func
# 
#     return check_accepts
# 
# Path: gridsim/unit.py
# class _Unit(object):
#     def __init__(self):
#     def Quantity(self):
#     def Unit(self):
#     def __call__(self, *args, **kwargs):
#     def __getattr__(self, item):
#     def to_si(self, measurement_or_unit):
#     def value(self, measurement, unit=None):
#     def unit(self, measurement):
#     def dimension(self, measurement):
#     def convert(self, m, u):
# 
# Path: gridsim/iodata/input.py
# class Reader(object):
# 
#     def __init__(self):
#         """
#         __init__(self)
# 
#         This class is the based class of all readers/loaders.
#         """
#         super(Reader, self).__init__()
# 
#     def clear(self):
#         """
#         clear(self)
# 
#         Empties the data of the Reader.
#         """
#         raise NotImplementedError('Pure abstract method.')
# 
#     @accepts((1, str), (2, int, float))
#     @returns(dict)
#     def load(self, data_type=None, nb_data=float("inf")):
#         """
#         load(self, data_type=None, nb_data=float("inf"))
# 
#         This method MUST returns formatted data following this format
#         ``[(label1, data1], (label2, data2), ...]``
# 
#         with:
# 
#         * ``labelX``: a str
#         * ``dataX``: a list of ``data_type``
# 
#         :param data_type: the type of stored data if ``None`` no conversion
#             are done.
#         :type data_type: type (default None)
#         :param nb_data: the number of data to load
#         :type nb_data: int
# 
#         :return: a dict of values
#         :rtype: dict
#         """
#         raise NotImplementedError('Pure abstract method.')


# Path: gridsim/timeseries.py
import types
import warnings
from io import BufferedReader
from types import FunctionType
from .decorators import accepts
from .unit import units
from .iodata.input import Reader

The data are translated into attributes of the :class:`TimeSeries` by calling
the :func:`TimeSeries.load` method on a TimeSeriesObject or any subclass of it::

    obj = TimeSeries()
    obj.load('../../data/examples/example.csv')

This will call the :func:`gridsim.iodata.input.Reader.load` function and process
the data to simplify the access from the simulator.

It is important to have a ``time`` data or to identify the data representing the
time.

If the data contain a ``temperature`` data, it can be access with:

.. literalinclude:: ../../demo/timeseries.py
    :linenos:

This would give an output like this::

    20.0
    18.5

"""




class TimeSeries(object):

    @accepts((1, Reader))

    @units.wraps(None, (None, None, units.second), strict=False)