# Path: hftools/dataset/dim.py
# class DimSweep(DiagAxis):
#     pass
# 
# class ComplexDiagAxis(_DiagAxis):
#     sortprio = 2000
#     _indep_axis = ComplexIndepAxis
#     _deriv_axis = ComplexDerivAxis
# 
# class ComplexIndepAxis(_IndepAxis):
#     sortprio = 2001
#     pass
# 
# class ComplexDerivAxis(_DerivAxis):
#     sortprio = 2002
#     pass
# 
# def dims_has_complex(dims):
#     for dim in reversed(dims):
#         dims = (ComplexDerivAxis, ComplexIndepAxis, ComplexDiagAxis)
#         if isinstance(dim, dims):
#             return True
#     return False
# 
# def info_has_complex(info):
#     deprecate("info_has_complex is deprecated")
#     return dims_has_complex(info)
# 
# Path: hftools/testing/common.py
# class TestCase(unittest.TestCase):
#     def assertAllclose(self, a, b, rtol=1e-05, atol=1e-08, msg=None):
#         a = np.asanyarray(a)
#         b = np.asanyarray(b)
#         if msg is None:
#             msg = "a (%s) not close to b (%s)" % (a, b)
#         self.assertTrue(np.allclose(a, b, rtol, atol), msg)
# 
#     def assertIsNotInstance(self, obj, cls):
#         self.assertFalse(isinstance(obj, cls))
# 
#     def assertIsInstance(self, obj, cls, msg=None):
#         """Same as self.assertTrue(isinstance(obj, cls)), with a nicer
#         default message."""
#         if not isinstance(obj, cls):
#             arg = (unittest.case.safe_repr(obj), cls)
#             standardMsg = '%s is not an instance of %r' % arg
#             self.fail(self._formatMessage(msg, standardMsg))
# 
#     def assertHFToolsWarning(self, funk, *k, **kw):
#         warnings.resetwarnings()
#         warnings.simplefilter("error", HFToolsWarning)
#         self.assertRaises(HFToolsWarning, funk, *k, **kw)
#         warnings.simplefilter("ignore", HFToolsWarning)
# 
#     def assertHFToolsDeprecationWarning(self, funk, *k, **kw):
#         warnings.resetwarnings()
#         warnings.simplefilter("error", HFToolsDeprecationWarning)
#         self.assertRaises(HFToolsDeprecationWarning, funk, *k, **kw)
#         warnings.simplefilter("ignore", HFToolsDeprecationWarning)
# 
# def make_load_tests(module):
#     """Add doctests to tests for module
# 
#     usage::
#         load_tests = make_load_tests(module)
#     """
#     warnings.simplefilter("error", HFToolsWarning)
#     warnings.simplefilter("error", HFToolsDeprecationWarning)
# #    warnings.simplefilter("error", DeprecationWarning)
# 
#     def load_tests(loader, standard_tests, pattern):
#         suite = unittest.TestSuite()
#         suite.addTests(standard_tests)
#         DocTests = doctest.DocTestSuite(module)
#         suite.addTests(DocTests)
#         return suite
#     return load_tests
# 
# Path: hftools/dataset/arrayobj.py
# class hfarray(_hfarray):
#     def __new__(subtype, data, dims=None, dtype=None, copy=True, order=None,
#                 subok=False, ndmin=0, unit=None, outputformat=None, info=None):
#         if hasattr(data, "__hfarray__"):
#             data, dims = data.__hfarray__()
#             if unit is None and len(dims) == 1:
#                 unit = dims[0].unit
#             if outputformat is None and len(dims) == 1:
#                 outputformat = dims[0].outputformat
#         return _hfarray.__new__(subtype, data, dims=dims, dtype=dtype,
#                                 copy=copy, order=order, subok=subok,
#                                 ndmin=ndmin, unit=unit,
#                                 outputformat=outputformat, info=info)
# 
# Path: hftools/utils.py
# def reset_hftools_warnings():
# def timestamp(highres=False):
# def warn(msg):
# def deprecate(msg):
#     def isnumber(x):
#     def isrealnumber(x):
#     def isnumber(x):
#     def isrealnumber(x):
# def is_numlike(a):
# def is_integer(a):
# def to_numeric(value, error=True):
# def stable_uniq(data):
# def uniq(data):
# def chop(x, rtol=1e-9, atol=1e-15):
# def make_dirs(*pathsegments):
# def split_num(string):
# def lex_order(lista):
# def glob(pat):
#     def beep(freq=None, duration=50):
#     def beep(freq=None, duration=50):
# def flatten(lista):


import os
import warnings
import numpy as np
import hftools.dataset.dim as ddim
from hftools.dataset.dim import DimSweep, ComplexDiagAxis, ComplexIndepAxis,\
    ComplexDerivAxis, dims_has_complex, info_has_complex
from hftools.testing import TestCase, make_load_tests
from hftools.dataset import hfarray
from hftools.utils import reset_hftools_warnings, HFToolsDeprecationWarning
class Object:
    pass


class TestDate(TestCase):
    def test_date_1(self):
        res = np.array(["2012-05-30 12:12:31", "2012-05-31 12:12:31"],
                       np.dtype("datetime64[us]"))
        d = DimSweep("a", res)
        self.assertEqual(d.data.dtype, np.dtype("datetime64[us]"))

    def test_obj(self):
        d = DimSweep("a", np.array([Object(), Object()]))
        self.assertEqual(d.data.dtype, np.object)

    def test_empty(self):
        d = DimSweep("a", [])
        self.assertEqual(d.data.dtype, np.float64)


class Testoutputformat(TestCase):
    def test_int(self):
        d = DimSweep("a", [1, 2, 3])
        self.assertEqual(d.outputformat, "%d")

    def test_num(self):
        d = DimSweep("a", [1., 2., 3])
        self.assertEqual(d.outputformat, "%.16e")

    def test_str(self):

# Path: hftools/dataset/dim.py
# class DimSweep(DiagAxis):
#     pass
# 
# class ComplexDiagAxis(_DiagAxis):
#     sortprio = 2000
#     _indep_axis = ComplexIndepAxis
#     _deriv_axis = ComplexDerivAxis
# 
# class ComplexIndepAxis(_IndepAxis):
#     sortprio = 2001
#     pass
# 
# class ComplexDerivAxis(_DerivAxis):
#     sortprio = 2002
#     pass
# 
# def dims_has_complex(dims):
#     for dim in reversed(dims):
#         dims = (ComplexDerivAxis, ComplexIndepAxis, ComplexDiagAxis)
#         if isinstance(dim, dims):
#             return True
#     return False
# 
# def info_has_complex(info):
#     deprecate("info_has_complex is deprecated")
#     return dims_has_complex(info)
# 
# Path: hftools/testing/common.py
# class TestCase(unittest.TestCase):
#     def assertAllclose(self, a, b, rtol=1e-05, atol=1e-08, msg=None):
#         a = np.asanyarray(a)
#         b = np.asanyarray(b)
#         if msg is None:
#             msg = "a (%s) not close to b (%s)" % (a, b)
#         self.assertTrue(np.allclose(a, b, rtol, atol), msg)
# 
#     def assertIsNotInstance(self, obj, cls):
#         self.assertFalse(isinstance(obj, cls))
# 
#     def assertIsInstance(self, obj, cls, msg=None):
#         """Same as self.assertTrue(isinstance(obj, cls)), with a nicer
#         default message."""
#         if not isinstance(obj, cls):
#             arg = (unittest.case.safe_repr(obj), cls)
#             standardMsg = '%s is not an instance of %r' % arg
#             self.fail(self._formatMessage(msg, standardMsg))
# 
#     def assertHFToolsWarning(self, funk, *k, **kw):
#         warnings.resetwarnings()
#         warnings.simplefilter("error", HFToolsWarning)
#         self.assertRaises(HFToolsWarning, funk, *k, **kw)
#         warnings.simplefilter("ignore", HFToolsWarning)
# 
#     def assertHFToolsDeprecationWarning(self, funk, *k, **kw):
#         warnings.resetwarnings()
#         warnings.simplefilter("error", HFToolsDeprecationWarning)
#         self.assertRaises(HFToolsDeprecationWarning, funk, *k, **kw)
#         warnings.simplefilter("ignore", HFToolsDeprecationWarning)
# 
# def make_load_tests(module):
#     """Add doctests to tests for module
# 
#     usage::
#         load_tests = make_load_tests(module)
#     """
#     warnings.simplefilter("error", HFToolsWarning)
#     warnings.simplefilter("error", HFToolsDeprecationWarning)
# #    warnings.simplefilter("error", DeprecationWarning)
# 
#     def load_tests(loader, standard_tests, pattern):
#         suite = unittest.TestSuite()
#         suite.addTests(standard_tests)
#         DocTests = doctest.DocTestSuite(module)
#         suite.addTests(DocTests)
#         return suite
#     return load_tests
# 
# Path: hftools/dataset/arrayobj.py
# class hfarray(_hfarray):
#     def __new__(subtype, data, dims=None, dtype=None, copy=True, order=None,
#                 subok=False, ndmin=0, unit=None, outputformat=None, info=None):
#         if hasattr(data, "__hfarray__"):
#             data, dims = data.__hfarray__()
#             if unit is None and len(dims) == 1:
#                 unit = dims[0].unit
#             if outputformat is None and len(dims) == 1:
#                 outputformat = dims[0].outputformat
#         return _hfarray.__new__(subtype, data, dims=dims, dtype=dtype,
#                                 copy=copy, order=order, subok=subok,
#                                 ndmin=ndmin, unit=unit,
#                                 outputformat=outputformat, info=info)
# 
# Path: hftools/utils.py
# def reset_hftools_warnings():
# def timestamp(highres=False):
# def warn(msg):
# def deprecate(msg):
#     def isnumber(x):
#     def isrealnumber(x):
#     def isnumber(x):
#     def isrealnumber(x):
# def is_numlike(a):
# def is_integer(a):
# def to_numeric(value, error=True):
# def stable_uniq(data):
# def uniq(data):
# def chop(x, rtol=1e-9, atol=1e-15):
# def make_dirs(*pathsegments):
# def split_num(string):
# def lex_order(lista):
# def glob(pat):
#     def beep(freq=None, duration=50):
#     def beep(freq=None, duration=50):
# def flatten(lista):


# Path: hftools/dataset/tests/test_dimensions.py
import os
import warnings
import numpy as np
import hftools.dataset.dim as ddim
from hftools.dataset.dim import DimSweep, ComplexDiagAxis, ComplexIndepAxis,\
    ComplexDerivAxis, dims_has_complex, info_has_complex
from hftools.testing import TestCase, make_load_tests
from hftools.dataset import hfarray
from hftools.utils import reset_hftools_warnings, HFToolsDeprecationWarning

class Object:
    pass


class TestDate(TestCase):
    def test_date_1(self):
        res = np.array(["2012-05-30 12:12:31", "2012-05-31 12:12:31"],
                       np.dtype("datetime64[us]"))
        d = DimSweep("a", res)
        self.assertEqual(d.data.dtype, np.dtype("datetime64[us]"))

    def test_obj(self):
        d = DimSweep("a", np.array([Object(), Object()]))
        self.assertEqual(d.data.dtype, np.object)

    def test_empty(self):
        d = DimSweep("a", [])
        self.assertEqual(d.data.dtype, np.float64)


class Testoutputformat(TestCase):
    def test_int(self):
        d = DimSweep("a", [1, 2, 3])
        self.assertEqual(d.outputformat, "%d")

    def test_num(self):
        d = DimSweep("a", [1., 2., 3])
        self.assertEqual(d.outputformat, "%.16e")

    def test_str(self):

        d = DimSweep("a", ["a"])