# Path: liam2/compat.py
# PY2 = sys.version_info[0] == 2
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
# def csv_open(filename, mode='r'):
#     class metaclass(meta):
# 
# Path: liam2/config.py



import ast
import itertools
import math
import re
import sys
import time
import warnings
import numpy as np
import numexpr as ne
import larray as la
from collections import defaultdict, deque, namedtuple
from textwrap import wrap
from liam2.compat import zip, basestring
from liam2 import config
    from liam2.data import ColumnArray
    from cutils import fromiter
    '1.95 Kb'
    >>> size2str(10000000)
    '9.54 Mb'
    >>> size2str(1.27 * 1024 ** 3)
    '1.27 Gb'
    """
    units = ["bytes", "Kb", "Mb", "Gb", "Tb", "Pb"]
    scale = int(math.log(value, 1024)) if value else 0
    fmt = "%.2f %s" if scale else "%d %s"
    return fmt % (value / 1024.0 ** scale, units[scale])


# def mem_usage():
#    pid = os.getpid()
#    proc = psutil.Process(pid)
#    return proc.get_memory_info()[0]


# def mem_usage_str():
#    return size2str(mem_usage())


def gettime(func, *args, **kwargs):
    start = time.time()
    res = func(*args, **kwargs)
    return time.time() - start, res


def timed(func, *args, **kwargs):
    elapsed, res = gettime(func, *args, **kwargs)

# Path: liam2/compat.py
# PY2 = sys.version_info[0] == 2
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
# def csv_open(filename, mode='r'):
#     class metaclass(meta):
# 
# Path: liam2/config.py



# Path: liam2/utils.py
import ast
import itertools
import math
import re
import sys
import time
import warnings
import numpy as np
import numexpr as ne
import larray as la
from collections import defaultdict, deque, namedtuple
from textwrap import wrap
from liam2.compat import zip, basestring
from liam2 import config
    from liam2.data import ColumnArray
    from cutils import fromiter

    '1.95 Kb'
    >>> size2str(10000000)
    '9.54 Mb'
    >>> size2str(1.27 * 1024 ** 3)
    '1.27 Gb'
    """
    units = ["bytes", "Kb", "Mb", "Gb", "Tb", "Pb"]
    scale = int(math.log(value, 1024)) if value else 0
    fmt = "%.2f %s" if scale else "%d %s"
    return fmt % (value / 1024.0 ** scale, units[scale])


# def mem_usage():
#    pid = os.getpid()
#    proc = psutil.Process(pid)
#    return proc.get_memory_info()[0]


# def mem_usage_str():
#    return size2str(mem_usage())


def gettime(func, *args, **kwargs):
    start = time.time()
    res = func(*args, **kwargs)
    return time.time() - start, res


def timed(func, *args, **kwargs):
    elapsed, res = gettime(func, *args, **kwargs)

    if config.show_timings: