Example #1
0
        then a view is not created and instead the columns are copied by
        reference. Frame `d3` will report the "full" size of its columns,
        even though they do not occupy any extra memory compared to `d`. This
        behavior may be changed in the future.

        This function is not intended for manual use. Instead, in order to get
        the size of a datatable `d`, call `sys.getsizeof(d)`.
        """
        return self._dt.alloc_size


#-------------------------------------------------------------------------------
# Global settings
#-------------------------------------------------------------------------------

core.register_function(4, TTypeError)
core.register_function(5, TValueError)
core.register_function(7, Frame)
core.register_function(9, make_datatable)
core.install_buffer_hooks(Frame())

options.register_option(
    "core_logger",
    xtype=callable,
    default=None,
    doc="If you set this option to a Logger object, then every call to any "
    "core function will be recorded via this object.")

options.register_option(
    "sort.insert_method_threshold",
    xtype=int,
Example #2
0
        even though they do not occupy any extra memory compared to `d`. This
        behavior may be changed in the future.

        This function is not intended for manual use. Instead, in order to get
        the size of a datatable `d`, call `sys.getsizeof(d)`.
        """
        return self._dt.alloc_size




#-------------------------------------------------------------------------------
# Global settings
#-------------------------------------------------------------------------------

core.register_function(4, TTypeError)
core.register_function(5, TValueError)
core.register_function(7, Frame)
core.install_buffer_hooks(Frame())


options.register_option(
    "core_logger", xtype=callable, default=None,
    doc="If you set this option to a Logger object, then every call to any "
        "core function will be recorded via this object.")

options.register_option(
    "sort.insert_method_threshold", xtype=int, default=64,
    doc="Largest n at which sorting will be performed using insert sort "
        "method. This setting also governs the recursive parts of the "
        "radix sort algorithm, when we need to sort smaller sub-parts of "
Example #3
0
    yield ("string", stype.str64)
    yield (object, stype.obj64)
    yield ("obj", stype.obj64)
    yield ("object", stype.obj64)
    yield ("object64", stype.obj64)

    # "old"-style stypes
    yield ("i1b", stype.bool8)
    yield ("i1i", stype.int8)
    yield ("i2i", stype.int16)
    yield ("i4i", stype.int32)
    yield ("i8i", stype.int64)
    yield ("f4r", stype.float32)
    yield ("f8r", stype.float64)
    yield ("i4s", stype.str32)
    yield ("i8s", stype.str64)
    yield ("p8p", stype.obj64)


def _init_value2members_from(iterator):
    for k, st in iterator:
        assert isinstance(st, stype)
        stype._value2member_map_[k] = st
        ltype._value2member_map_[k] = st.ltype


_init_value2members_from(_additional_stype_members())

core.register_function(2, stype)
core.register_function(3, ltype)
Example #4
0
        if message[0] != "[":
            message = "  " + message
        print(_log_color(message), flush=True)

    def warning(self, message):
        warnings.warn(message, category=FreadWarning)


# os.PathLike interface was added in Python 3.6
_pathlike = (str, bytes, os.PathLike) if hasattr(os, "PathLike") else \
            (str, bytes)

options.register_option(
    "fread.anonymize", xtype=bool, default=False)

core.register_function(8, fread)



#-------------------------------------------------------------------------------

# Corresponds to RT enum in "reader_parsers.h"
class rtype(enum.Enum):
    rdrop    = 0
    rauto    = 1
    rbool    = 2
    rint     = 3
    rint32   = 4
    rint64   = 5
    rfloat   = 6
    rfloat32 = 7
Example #5
0
            "columns": view.data,
            "rownumbers": ["%0*X" % (l, 16 * r) for r in range(row0, row1)],
        }

    print("Column %d" % colidx)
    print("Ltype: %s, Stype: %s, Mtype: %s" %
          (col.ltype.name, col.stype.name, col.mtype))
    datasize = col.data_size
    print("Bytes: %d" % datasize)
    print("Meta: %s" % col.meta)
    print("Refcnt: %d" % col.refcount)
    widget = DataFrameWidget((datasize + 15) // 16, 17, data_viewer)
    widget.render()


core.register_function(1, column_hexview)
core.register_function(4, TTypeError)
core.register_function(5, TValueError)
core.register_function(6, DatatableWarning)
core.install_buffer_hooks(Frame())

options.register_option(
    "nthreads",
    xtype=int,
    default=0,
    core=True,
    doc="The number of OMP threads to be used by datatable. The value of 0 "
    "(default) allows datatable to use the maximum number of threads. "
    "Values less than zero allow to use that fewer threads than the "
    "maximum. Finally, nthreads=1 indicates single-threaded mode.")
Example #6
0
        then a view is not created and instead the columns are copied by
        reference. Frame `d3` will report the "full" size of its columns,
        even though they do not occupy any extra memory compared to `d`. This
        behavior may be changed in the future.

        This function is not intended for manual use. Instead, in order to get
        the size of a datatable `d`, call `sys.getsizeof(d)`.
        """
        return self._dt.alloc_size


#-------------------------------------------------------------------------------
# Global settings
#-------------------------------------------------------------------------------

core.register_function(4, TTypeError)
core.register_function(5, TValueError)
core.register_function(6, DatatableWarning)
core.register_function(7, Frame)
core.install_buffer_hooks(Frame())

options.register_option(
    "nthreads",
    xtype=int,
    default=0,
    core=True,
    doc="The number of OMP threads to be used by datatable. The value of 0 "
    "(default) allows datatable to use the maximum number of threads. "
    "Values less than zero allow to use that fewer threads than the "
    "maximum. Finally, nthreads=1 indicates single-threaded mode.")
Example #7
0
            "columns": view.data,
            "indices": ["%0*X" % (l, 16 * r) for r in range(row0, row1)],
        }

    print("Column %d" % colidx)
    print("Ltype: %s, Stype: %s, Mtype: %s" %
          (col.ltype.name, col.stype.name, col.mtype))
    datasize = col.data_size
    print("Bytes: %d" % datasize)
    print("Meta: %s" % col.meta)
    print("Refcnt: %d" % col.refcount)
    widget = DataFrameWidget((datasize + 15) // 16, 17, data_viewer)
    widget.render()


core.register_function(1, column_hexview)
core.register_function(4, TTypeError)
core.register_function(5, TValueError)
core.install_buffer_hooks(Frame())

options.register_option(
    "nthreads",
    xtype=int,
    default=0,
    core=True,
    doc="The number of OMP threads to be used by datatable. The value of 0 "
    "(default) allows datatable to use the maximum number of threads. "
    "Values less than zero allow to use that fewer threads than the "
    "maximum. Finally, nthreads=1 indicates single-threaded mode.")

options.register_option(
Example #8
0
#-------------------------------------------------------------------------------

class DatatableWarning(UserWarning):
    def _handle_(self):
        name = self.__class__.__name__
        message = str(self)
        print(term.dim_yellow(name + ": ") + term.bright_black(message))


def dtwarn(message):
    warnings.warn(message, category=DatatableWarning)


def _showwarning(message, category, filename, lineno, file=None, line=None):
    custom_handler = getattr(category, "_handle_", None)
    if custom_handler:
        custom_handler(message)
    else:
        _default_warnings_hoook(message, category, filename, lineno, file, line)


# Replace the default warnings handler
_default_warnings_hoook = warnings.showwarning
warnings.showwarning = _showwarning

core.register_function(6, DatatableWarning)


__all__ = ("typed", "is_type", "U", "TTypeError", "TValueError", "TImportError",
           "Frame_t", "NumpyArray_t", "DatatableWarning", "dtwarn", "name_type")