# Path: tests/data.py
# class DummyData(object):
#     def __init__(self):
#         self.attrs = {
#                 'datetime': datetime(2016,6,4),
#                 'LATITUDE': 15, 'LONGITUDE': -38}
#         self.data = {
#                 'PRES': ma.fix_invalid(
#                     [2, 6, 10, 21, 44, 79, 100, 150,
#                         200, 400, 410, 650, 1000, 2000, 5000]),
#                 'TEMP': ma.fix_invalid(
#                     [25.32, 25.34, 25.34, 25.31, 24.99, 23.46, 21.85, 17.95,
#                         15.39, 11.08, 6.93, 7.93, 5.71, 3.58, np.nan]),
#                 'PSAL': ma.fix_invalid(
#                     [36.49, 36.51, 36.52, 36.53, 36.59, 36.76, 36.81, 36.39,
#                         35.98, 35.30, 35.28, 34.93, 34.86, np.nan, np.nan])}
# 
#     def __getitem__(self, key):
#         return self.data[key]
# 
#     def keys(self):
#         return self.data.keys()
# 
#     @property
#     def attributes(self):
#         print('attributes will be removed. Use attrs instead!')
#         return self.attrs


from hypothesis import given
from numpy import ma
from ..data import DummyData
import hypothesis.strategies as st
import numpy as np
    import pandas as pd
    import xarray as xr
    """Validate the results using a tuple
    """
    profile = DummyData()
    tp = {}
    for v in profile.keys():
        if isinstance(profile[v], ma.MaskedArray) and profile[v].mask.any():
            profile[v][profile[v].mask] = np.nan
            profile.data[v] = profile[v].data
        tp[v] = tuple(profile.data[v])

    y = Procedure(profile, "TEMP", cfg)
    y2 = Procedure(tp, "TEMP", cfg, attrs=profile.attrs)

    assert isinstance(y2["TEMP"], tuple), "It didn't preserve the tuple type"

    for f in y.features:
        assert np.allclose(y.features[f], y2.features[f], equal_nan=True)
        assert y.features[f].dtype == y2.features[f].dtype
    for f in y.flags:
        assert type(y.flags[f]) == type(y2.flags[f])
        assert y.flags[f].dtype == y2.flags[f].dtype
        assert np.allclose(y.flags[f], y2.flags[f], equal_nan=True)


def compare_pandas(Procedure, cfg):
    """Validate the results using pandas.DataFrame
    """
    if not PANDAS_AVAILABLE:
        return


# Path: tests/data.py
# class DummyData(object):
#     def __init__(self):
#         self.attrs = {
#                 'datetime': datetime(2016,6,4),
#                 'LATITUDE': 15, 'LONGITUDE': -38}
#         self.data = {
#                 'PRES': ma.fix_invalid(
#                     [2, 6, 10, 21, 44, 79, 100, 150,
#                         200, 400, 410, 650, 1000, 2000, 5000]),
#                 'TEMP': ma.fix_invalid(
#                     [25.32, 25.34, 25.34, 25.31, 24.99, 23.46, 21.85, 17.95,
#                         15.39, 11.08, 6.93, 7.93, 5.71, 3.58, np.nan]),
#                 'PSAL': ma.fix_invalid(
#                     [36.49, 36.51, 36.52, 36.53, 36.59, 36.76, 36.81, 36.39,
#                         35.98, 35.30, 35.28, 34.93, 34.86, np.nan, np.nan])}
# 
#     def __getitem__(self, key):
#         return self.data[key]
# 
#     def keys(self):
#         return self.data.keys()
# 
#     @property
#     def attributes(self):
#         print('attributes will be removed. Use attrs instead!')
#         return self.attrs


# Path: tests/qctests/compare.py
from hypothesis import given
from numpy import ma
from ..data import DummyData
import hypothesis.strategies as st
import numpy as np
    import pandas as pd
    import xarray as xr

    """Validate the results using a tuple
    """
    profile = DummyData()
    tp = {}
    for v in profile.keys():
        if isinstance(profile[v], ma.MaskedArray) and profile[v].mask.any():
            profile[v][profile[v].mask] = np.nan
            profile.data[v] = profile[v].data
        tp[v] = tuple(profile.data[v])

    y = Procedure(profile, "TEMP", cfg)
    y2 = Procedure(tp, "TEMP", cfg, attrs=profile.attrs)

    assert isinstance(y2["TEMP"], tuple), "It didn't preserve the tuple type"

    for f in y.features:
        assert np.allclose(y.features[f], y2.features[f], equal_nan=True)
        assert y.features[f].dtype == y2.features[f].dtype
    for f in y.flags:
        assert type(y.flags[f]) == type(y2.flags[f])
        assert y.flags[f].dtype == y2.flags[f].dtype
        assert np.allclose(y.flags[f], y2.flags[f], equal_nan=True)


def compare_pandas(Procedure, cfg):
    """Validate the results using pandas.DataFrame
    """
    if not PANDAS_AVAILABLE:
        return


    profile = DummyData()