'''
Copyright (C) 2016 Turi
All rights reserved.

This software may be modified and distributed under the terms
of the BSD license. See the LICENSE file for details.
'''
import unittest
import numpy as np
from numpy import nan
import array
import datetime as dt
from ..data_structures import image
from .. import SArray
import os
from ..cython.cy_flexible_type import _translate_through_flexible_type as _flexible_type
from ..cython.cy_flexible_type import _translate_through_flex_list as _tr_flex_list
from ..cython.cy_flexible_type import infer_type_of_list
from ..cython.cy_flexible_type import _get_inferred_column_type, _all_convertable
from ..cython.cy_flexible_type import _check_ft_pyobject_hint_path
from ..cython.cy_flexible_type import pytype_from_type_name
from ..util.timezone import GMT
import datetime
from itertools import product
from copy import copy

import sys
if sys.version_info.major > 2:
    long = int
    unicode = str

NoneType = type(None)

current_file_dir = os.path.dirname(os.path.realpath(__file__))

def from_lambda(v):
    from ..connect import main as glconnect
    u = glconnect.get_unity()
    return u.eval_lambda(lambda x: x, v)

special_types = set()

IntegerValue = (
    [int(0), long(1)]
     + [_dt(0) for _dt in (np.sctypes['int'] + np.sctypes['uint']
                         + [np.bool, bool, np.bool_])])
special_types.add(id(IntegerValue))

# 2**63 and -2**63-1 are not representable by a C int64_t, so it's
# treated as a float.
FloatValue = [float(0)] + [_dt(0) for _dt in np.sctypes['float']] + [2**63, -2**63 - 1]
special_types.add(id(FloatValue))

StringValue = ([str('bork'), unicode('bork'), b'bork', b'']
               + [_dt('bork') for _dt in
                  [np.unicode, np.unicode_, str, unicode, np.str,