xcept ValueError:
        return int(expr.count())

_warning_msg = """
In version 0.11, Blaze's expresssion repr will return a standard 
representation and will no longer implicitly compute.  Use the `peek()`
method to see a preview of the expression's results.\
"""

use_new_repr = False
def _choose_repr(self):
    if use_new_repr:
        return new_repr(self)
    else:
        warnings.warn(_warning_msg, DeprecationWarning, stacklevel=2)
        return expr_repr(self)


def _warning_repr_html(self):
    if use_new_repr:
        return new_repr(self)
    else:
        warnings.warn(_warning_msg, DeprecationWarning, stacklevel=2)
        return to_html(self)


def new_repr(self):
    fmt =  "<`{}` expression; dshape='{}'>"
    return fmt.format(type(self).__name__,
                      sanitized_dshape(self.dshape))


Expr.__repr__ = _choose_repr
Expr.peek = _peek
Expr._repr_html_ = _warning_repr_html
Expr.__len__ = table_length


def intonumpy(data, dtype=None, **kwargs):
    # TODO: Don't ignore other kwargs like copy
    result = odo(data, np.ndarray)
    if dtype and result.dtype != dtype:
        result = result.astype(dtype)
    return result


def convert_base(typ, x):
    x = compute(x)
    try:
        return typ(x)
    except:
        return typ(odo(x, typ))


CORE_SCALAR_TYPES = (float, decimal.Decimal, int, bool, str, Timestamp,
                     datetime.date, datetime.timedelta)
CORE_SEQUENCE_TYPES = (list, dict, tuple, set, Series, DataFrame, np.ndarray)
CORE_TYPES = CORE_SCALAR_TYPES + CORE_SEQUENCE_TYPES


def iscorescalar(x):
    return isinstance(x, CORE_SCALAR_TYPES)


def iscoresequence(x):
    return isinstance(x, CORE_SEQUENCE_TYPES)


def iscoretype(x):
    return isinstance(x, CORE_TYPES)


Expr.__array__ = intonumpy
Expr.__int__ = lambda x: convert_base(int, x)
Expr.__float__ = lambda x: convert_base(float, x)
Expr.__complex__ = lambda x: convert_base(complex, x)
Expr.__bool__ = lambda x: convert_base(bool, x)
Expr.__nonzero__ = lambda x: convert_base(bool, x)
Expr.__iter__ = into(Iterator)
