diff --git a/firanka/series/__init__.py b/firanka/series/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..7ff006835df18021b5ea9ad72420624c8775f85a --- /dev/null +++ b/firanka/series/__init__.py @@ -0,0 +1,27 @@ +# coding=UTF-8 +from __future__ import print_function, absolute_import, division +import six +import logging + +logger = logging.getLogger(__name__) + + +class DataSeries(object): + """ + Finite mapping from x: REAL => object + """ + + def __init__(self, data=None): + self.data = data or [] + + def length(self): + """ + Return timespan + :return: float + """ + try: + return self.data[-1] - self.data[0] + except IndexError: + return 0.0 + + diff --git a/firanka/series/exceptions.py b/firanka/series/exceptions.py new file mode 100644 index 0000000000000000000000000000000000000000..e0e7c5302dcf8c34f69534e7dfd2bc6f1f37b0f7 --- /dev/null +++ b/firanka/series/exceptions.py @@ -0,0 +1,15 @@ +# coding=UTF-8 +from __future__ import print_function, absolute_import, division +import six +import logging + +logger = logging.getLogger(__name__) + + +class FirankaException(Exception): + pass + +class Empty(FirankaException): + """ + Series was empty + """ \ No newline at end of file diff --git a/tests/series/__init__.py b/tests/series/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..1c762b12fd99adc2f7d4e5137c5b872079457510 --- /dev/null +++ b/tests/series/__init__.py @@ -0,0 +1,8 @@ +# coding=UTF-8 +from __future__ import print_function, absolute_import, division +import six +import logging + +logger = logging.getLogger(__name__) + + diff --git a/tests/series/series.py b/tests/series/series.py new file mode 100644 index 0000000000000000000000000000000000000000..01f3fdf1fbe56b7c7431aff5e29124c8afb64057 --- /dev/null +++ b/tests/series/series.py @@ -0,0 +1,11 @@ +# coding=UTF-8 +from __future__ import print_function, absolute_import, division +import six +import unittest +from firanka.series import DataSeries + +class TestSeries(unittest.TestCase): + def test_ds(self): + + ds = DataSeries() + self.assertAlmostEqual(ds.length(), 0.0)