Init frame from binary data.
497426
def from_payload(self, payload):
        """"""
        number_of_objects = payload[0]
        self.remaining_scenes = payload[-1]
        predicted_len = number_of_objects * 65 + 2
        if len(payload) != predicted_len:
            raise PyVLXException('scene_list_notification_wrong_length')
        self.scenes = []
        for i in range(number_of_objects):
            scene = payload[(i*65+1):(i*65+66)]
            number = scene[0]
            name = bytes_to_string(scene[1:])
            self.scenes.append((number, name))
1090159
def _init_data_line(self, fnc, lnum, line):
        """"""
        fld = re.split(self.sep, line)
        # Lines may contain different numbers of items.
        # The line should have all columns requested by the user.
        if self.usr_max_idx < len(fld):
            self.convert_ints_floats(fld)
            fnc(fld)
        else:
            for fld in enumerate(zip(self.hdr2idx.keys(), fld)):
                print(fld)
            for hdr in self.hdrs_usr:
                print(hdr)
            print('# ITEMS ON A LINE:', len(fld))
            print('MAX USR IDX:', self.usr_max_idx)
            raise Exception("ERROR ON LINE {} IN {}".format(lnum+1, self.fin))
1238530
def __init_from_csc(self, csc, params_str, ref_dataset):
        """"""
        if len(csc.indices) != len(csc.data):
            raise ValueError('Length mismatch: {} vs {}'.format(len(csc.indices), len(csc.data)))
        self.handle = ctypes.c_void_p()

        ptr_indptr, type_ptr_indptr, __ = c_int_array(csc.indptr)
        ptr_data, type_ptr_data, _ = c_float_array(csc.data)

        assert csc.shape[0] <= MAX_INT32
        csc.indices = csc.indices.astype(np.int32, copy=False)

        _safe_call(_LIB.LGBM_DatasetCreateFromCSC(
            ptr_indptr,
            ctypes.c_int(type_ptr_indptr),
            csc.indices.ctypes.data_as(ctypes.POINTER(ctypes.c_int32)),
            ptr_data,
            ctypes.c_int(type_ptr_data),
            ctypes.c_int64(len(csc.indptr)),
            ctypes.c_int64(len(csc.data)),
            ctypes.c_int64(csc.shape[0]),
            c_str(params_str),
            ref_dataset,
            ctypes.byref(self.handle)))
        return self
340042
def fromints(cls, ints):
        """"""
        return cls.frombitsets(map(cls.BitSet.fromint, ints))
1119300
def add_the_init(root_dir, data):
  """"""
  init_file = os.path.join(root_dir, '{dataset_type}', '__init__.py')
  context = (
      'from tensorflow_datasets.{dataset_type}.{dataset_name} import '
      '{dataset_cls}  # {TODO} Sort alphabetically\n'
  )
  with gfile.GFile(init_file.format(**data), 'a') as f:
    f.write(context.format(**data))
1219146
def _init_lsr(n_items, alpha, initial_params):
    """"""
    if initial_params is None:
        weights = np.ones(n_items)
    else:
        weights = exp_transform(initial_params)
    chain = alpha * np.ones((n_items, n_items), dtype=float)
    return weights, chain
951775
def __init_from_list_np2d(self, mats, params_str, ref_dataset):
        """"""
        ncol = mats[0].shape[1]
        nrow = np.zeros((len(mats),), np.int32)
        if mats[0].dtype == np.float64:
            ptr_data = (ctypes.POINTER(ctypes.c_double) * len(mats))()
        else:
            ptr_data = (ctypes.POINTER(ctypes.c_float) * len(mats))()

        holders = []
        type_ptr_data = None

        for i, mat in enumerate(mats):
            if len(mat.shape) != 2:
                raise ValueError('Input numpy.ndarray must be 2 dimensional')

            if mat.shape[1] != ncol:
                raise ValueError('Input arrays must have same number of columns')

            nrow[i] = mat.shape[0]

            if mat.dtype == np.float32 or mat.dtype == np.float64:
                mats[i] = np.array(mat.reshape(mat.size), dtype=mat.dtype, copy=False)
            else:
                # change non-float data to float data, need to copy
                mats[i] = np.array(mat.reshape(mat.size), dtype=np.float32)

            chunk_ptr_data, chunk_type_ptr_data, holder = c_float_array(mats[i])
            if type_ptr_data is not None and chunk_type_ptr_data != type_ptr_data:
                raise ValueError('Input chunks must have same type')
            ptr_data[i] = chunk_ptr_data
            type_ptr_data = chunk_type_ptr_data
            holders.append(holder)

        self.handle = ctypes.c_void_p()
        _safe_call(_LIB.LGBM_DatasetCreateFromMats(
            ctypes.c_int(len(mats)),
            ctypes.cast(ptr_data, ctypes.POINTER(ctypes.POINTER(ctypes.c_double))),
            ctypes.c_int(type_ptr_data),
            nrow.ctypes.data_as(ctypes.POINTER(ctypes.c_int32)),
            ctypes.c_int(ncol),
            ctypes.c_int(C_API_IS_ROW_MAJOR),
            c_str(params_str),
            ref_dataset,
            ctypes.byref(self.handle)))
        return self
1018120
def to_binary_string(self, code, identifier):
        """"""
        return struct.pack(self.FORMAT, self.COMMAND, code, identifier)
1142777
def _init(self):
        """"""
        read_values = []
        read = self._file.read
        last = read(1)
        current = read(1)
        while last != b'' and current != b'' and not \
                (last == b'\r' and current == b'\n'):
            read_values.append(last)
            last = current
            current = read(1)
        if current == b'' and last != b'\r':
            read_values.append(last)
        self._bytes = b''.join(read_values)
346395
def insert_data_frame(col, df, int_col=None, binary_col=None, minimal_size=5):
    
    data = transform.to_dict_list_generic_type(df,
                                               int_col=int_col,
                                               binary_col=binary_col)
    smart_insert(col, data, minimal_size)
440769
def init_contents(self, size=0, **kwargs):
        """"""
        self.set_uri(
            *self.storage(**kwargs).initialize(size=size),
            readable=False, writable=True)
1145265
def _initialize_with_array(self, data, rowBased=True):
        """"""
        if rowBased:
            self.matrix = []
            if len(data) != self._rows:
                raise ValueError("Size of Matrix does not match")
            for col in xrange(self._columns):
                self.matrix.append([])
                for row in xrange(self._rows):
                    if len(data[row]) != self._columns:
                        raise ValueError("Size of Matrix does not match")
                    self.matrix[col].append(data[row][col])
        else:
            if len(data) != self._columns:
                raise ValueError("Size of Matrix does not match")
            for col in data:
                if len(col) != self._rows:
                    raise ValueError("Size of Matrix does not match")
            self.matrix = copy.deepcopy(data)
69513
def init(arguments_type, frame_type)
      raise "Wrong argument type, expect Type not #{arguments_type.class}" unless arguments_type.is_a? Type
      raise "Wrong frame type, expect Type not #{frame_type.class}" unless frame_type.is_a? Type
      self.arguments_type = arguments_type
      self.frame_type = frame_type
      self.binary = BinaryCode.new(0)
    end
644903
def initialize():
        """"""
        _WindowsCSBI._define_csbi()
        _WindowsCSBI.HANDLE_STDERR = _WindowsCSBI.HANDLE_STDERR or _WindowsCSBI.WINDLL.kernel32.GetStdHandle(-12)
        _WindowsCSBI.HANDLE_STDOUT = _WindowsCSBI.HANDLE_STDOUT or _WindowsCSBI.WINDLL.kernel32.GetStdHandle(-11)
        if _WindowsCSBI.WINDLL.kernel32.GetConsoleScreenBufferInfo.argtypes:
            return

        _WindowsCSBI.WINDLL.kernel32.GetStdHandle.argtypes = [ctypes.wintypes.DWORD]
        _WindowsCSBI.WINDLL.kernel32.GetStdHandle.restype = ctypes.wintypes.HANDLE
        _WindowsCSBI.WINDLL.kernel32.GetConsoleScreenBufferInfo.restype = ctypes.wintypes.BOOL
        _WindowsCSBI.WINDLL.kernel32.GetConsoleScreenBufferInfo.argtypes = [
            ctypes.wintypes.HANDLE, ctypes.POINTER(_WindowsCSBI.CSBI)
        ]
840889
def __init_from_np2d(self, mat, params_str, ref_dataset):
        """"""
        if len(mat.shape) != 2:
            raise ValueError('Input numpy.ndarray must be 2 dimensional')

        self.handle = ctypes.c_void_p()
        if mat.dtype == np.float32 or mat.dtype == np.float64:
            data = np.array(mat.reshape(mat.size), dtype=mat.dtype, copy=False)
        else:
            # change non-float data to float data, need to copy
            data = np.array(mat.reshape(mat.size), dtype=np.float32)

        ptr_data, type_ptr_data, _ = c_float_array(data)
        _safe_call(_LIB.LGBM_DatasetCreateFromMat(
            ptr_data,
            ctypes.c_int(type_ptr_data),
            ctypes.c_int(mat.shape[0]),
            ctypes.c_int(mat.shape[1]),
            ctypes.c_int(C_API_IS_ROW_MAJOR),
            c_str(params_str),
            ref_dataset,
            ctypes.byref(self.handle)))
        return self
285212
def frombinary(self, s):
        """"""
        entrylen = struct.calcsize(self.ENTRYSTRUCT)
        p = 0
        while p<len(s):
            (slen, dpos, dlen, ulen, flag, typcd) = struct.unpack(self.ENTRYSTRUCT,
                                                        s[p:p+entrylen])
            nmlen = slen - entrylen
            p = p + entrylen
            (nm,) = struct.unpack(`nmlen`+'s', s[p:p+nmlen])
            p = p + nmlen
            # version 4
            # self.data.append((dpos, dlen, ulen, flag, typcd, nm[:-1]))
            # version 5
            # nm may have up to 15 bytes of padding
            pos = nm.find('\0')
            if pos < 0:
                self.data.append((dpos, dlen, ulen, flag, typcd, nm))
            else:
                self.data.append((dpos, dlen, ulen, flag, typcd, nm[:pos]))
5931
def _init(self):
        """"""
        group_stack = [self]
        clip_stack = []
        last_layer = None

        for record, channels in self._record._iter_layers():
            current_group = group_stack[-1]

            blocks = record.tagged_blocks
            end_of_group = False
            divider = blocks.get_data('SECTION_DIVIDER_SETTING', None)
            divider = blocks.get_data('NESTED_SECTION_DIVIDER_SETTING',
                                      divider)
            if divider is not None:
                if divider.kind == SectionDivider.BOUNDING_SECTION_DIVIDER:
                    layer = Group(self, None, None, current_group)
                    group_stack.append(layer)
                elif divider.kind in (SectionDivider.OPEN_FOLDER,
                                      SectionDivider.CLOSED_FOLDER):
                    layer = group_stack.pop()
                    assert layer is not self

                    layer._record = record
                    layer._channels = channels
                    for key in (
                        'ARTBOARD_DATA1', 'ARTBOARD_DATA2', 'ARTBOARD_DATA3'
                    ):
                        if key in blocks:
                            layer = Artboard._move(layer)
                    end_of_group = True
            elif (
                'TYPE_TOOL_OBJECT_SETTING' in blocks or
                'TYPE_TOOL_INFO' in blocks
            ):
                layer = TypeLayer(self, record, channels, current_group)
            elif (
                record.flags.pixel_data_irrelevant and (
                    'VECTOR_ORIGINATION_DATA' in blocks or
                    'VECTOR_MASK_SETTING1' in blocks or
                    'VECTOR_MASK_SETTING2' in blocks or
                    'VECTOR_STROKE_DATA' in blocks or
                    'VECTOR_STROKE_CONTENT_DATA' in blocks
                )
            ):
                layer = ShapeLayer(self, record, channels, current_group)
            elif (
                'SMART_OBJECT_LAYER_DATA1' in blocks or
                'SMART_OBJECT_LAYER_DATA2' in blocks or
                'PLACED_LAYER1' in blocks or
                'PLACED_LAYER2' in blocks
            ):
                layer = SmartObjectLayer(self, record, channels,
                                         current_group)
            else:
                layer = None
                for key in adjustments.TYPES.keys():
                    if key in blocks:
                        layer = adjustments.TYPES[key](
                            self, record, channels, current_group
                        )
                        break
                # If nothing applies, this is a pixel layer.
                if layer is None:
                    layer = PixelLayer(
                        self, record, channels, current_group
                    )

            if record.clipping == Clipping.NON_BASE:
                clip_stack.append(layer)
            else:
                if clip_stack:
                    last_layer._clip_layers = clip_stack
                clip_stack = []
                if not end_of_group:
                    current_group._layers.append(layer)
                last_layer = layer

        if clip_stack and last_layer:
            last_layer._clip_layers = clip_stack