Load values from a Python file.
8258
def from_pyfile(self, filename: str) -> None:
        """"""
        globals_ = {}  # type: Dict[str, Any]
        locals_ = {}  # type: Dict[str, Any]
        with open(filename, "rb") as f:
            exec(compile(f.read(), filename, 'exec'), globals_, locals_)

        for key, value in locals_.items():
            if (key.isupper() and not isinstance(value, types.ModuleType)):
                self._setattr(key, value)

        logger.info("Config is loaded from file: %s", filename)
1310295
def _read_values(self, file, number_values):
        """"""

        if self.data_type.nptype is not None:
            dtype = (np.dtype(self.data_type.nptype).newbyteorder(
                self.endianness))
            return fromfile(file, dtype=dtype, count=number_values)
        elif self.data_type == types.String:
            return read_string_data(file, number_values, self.endianness)
        data = self._new_segment_data()
        for i in range(number_values):
            data[i] = self.data_type.read(file, self.endianness)
        return data
53083
def loads(s):
    """"""
    _decoder = json.JSONDecoder()

    while s:
        s = s.strip()
        obj, pos = _decoder.raw_decode(s)
        if not pos:
            raise ValueError('no JSON object found at %i' % pos)
        yield obj
        s = s[pos:]
859944
def load(self, filename):
        """"""
        f = io.open(filename,'r',encoding='utf-8')
        for line in f:
            data = line.strip().split("\t")
            type, count = data[:2]
            self.count(type,count)
        f.close()
820519
def __load(self, path):
        """"""
        try:
            path = os.path.abspath(path)
            with open(path, 'rb') as df:
                # loaded_dataset = pickle.load(df)
                self.__data, self.__classes, self.__labels, \
                self.__dtype, self.__description, \
                self.__num_features, self.__feature_names = pickle.load(df)

            # ensure the loaded dataset is valid
            self.__validate(self.__data, self.__classes, self.__labels)

        except IOError as ioe:
            raise IOError('Unable to read the dataset from file: {}', format(ioe))
        except:
            raise
1048097
def load(self):
        """"""
        try:
            self._read()
            self._parse()
        except Exception as exc:
            self.failed = True

            params = {'path': self._path, 'exception': exc}
            if self.fail_silently:
                LOG.warning("Error processing message json file '%(path)s': "
                            "%(exception)s", params)
            else:
                raise exceptions.MessageFailure(
                    _("Error processing message json file '%(path)s': "
                      "%(exception)s") % params)
1289260
def _load( self, fn ):
        """"""

        # if file is empty, create an empty notebook
        if os.path.getsize(fn) == 0:
            self._description = None
            self._results = dict()
            self._pending = dict()
        else:
            # load the JSON object
            with open(fn, "r") as f:
                s = f.read()

                # parse back into appropriate variables
                j = json.loads(s)
                self._description = j['description']
                self._pending = dict(j['pending'])
                self._results = j['results']

                # perform any post-load patching
                self.patch()
200128
def load(self, filepath):
        """"""
        with open(filepath, 'rb') as fd:
            num_keys = struct.unpack(">i", fd.read(4))[0]
            for i in range(num_keys):
                row, value, kind = struct.unpack('>ifb', fd.read(9))
                self.keys.append(TrackKey(row, value, kind))
1211367
def from_file(self, fname):
        """"""
        f = open(fname, "rb")
        data = f.read()
        self.update(data)
        f.close()
789789
def load_data(self, filename, *args, **kwargs):
        
        # header keys
        header_param = self.parameters.get('header')  # default is None
        # data keys
        data_param = self.parameters['data']  # raises KeyError if no 'data'
        dtype = data_param.get('dtype')  # default is None
        # if not None convert to tuple and normal ASCII
        _utf8_list_to_ascii_tuple(dtype) if dtype else None  # -> tuple of str
        delimiter = data_param.get('delimiter')  # default is None
        skip_header = data_param.get('skip_header')  # default is None
        usecols = data_param.get('usecols')  # default is None
        names = data_param.get('names')  # default is None
        names = [str(_) for _ in names] if names else None  # -> str
        excludelist = data_param.get('excludelist')  # default is None
        deletechars = data_param.get('deletechars')  # default is None
        data_units = data_param.get('units', {})  # default is an empty dict
        # either dtype or names must be specified
        if not (dtype or names):
            raise UnnamedDataError(filename)
        data = {}  # a dictionary for data
        # open file for reading
        with open(filename, 'r') as fid:
            # read header
            if header_param:
                data.update(_read_header(fid, header_param))
                fid.seek(0)  # move cursor back to beginning
            # data
            data_data = np.genfromtxt(fid, dtype, delimiter=delimiter,
                                      skip_header=skip_header, usecols=usecols,
                                      names=names, excludelist=excludelist,
                                      deletechars=deletechars)
        # apply units
        data.update(_apply_units(data_data, data_units, fid.name))
        return data
243691
def load_data(self, filename, ext):
        """"""
        from spyder_kernels.utils.iofuncs import iofunctions
        from spyder_kernels.utils.misc import fix_reference_name

        glbs = self._mglobals()

        load_func = iofunctions.load_funcs[ext]
        data, error_message = load_func(filename)

        if error_message:
            return error_message

        for key in list(data.keys()):
            new_key = fix_reference_name(key, blacklist=list(glbs.keys()))
            if new_key != key:
                data[new_key] = data.pop(key)

        try:
            glbs.update(data)
        except Exception as error:
            return str(error)

        return None
1325229
def load(self, filename=None, ignore_discard=False, ignore_expires=False):
        """"""
        if filename is None:
            if self.filename is not None: filename = self.filename
            else: raise ValueError(MISSING_FILENAME_TEXT)

        f = open(filename)
        try:
            self._really_load(f, filename, ignore_discard, ignore_expires)
        finally:
            f.close()
643198
def load(self, value):
        """"""

        if not isinstance(value, str):
            raise TypeError('Expected JSON string')

        _value = json.loads(value)
        self._validate_word(value=_value)
        self.word = _value
563654
def _load_fast(filename):
        """"""
        it = json.load(open("{}_items.json".format(filename)))
        words, unk_index, name = it["items"], it["unk_index"], it["name"]
        vectors = np.load(open("{}_vectors.npy".format(filename), 'rb'))
        return words, unk_index, name, vectors
1246365
def loads(s, filename=None, loader=None, implicit_tuple=True, env={}, schema=None):
  """"""
  ast = reads(s, filename=filename, loader=loader, implicit_tuple=implicit_tuple)
  if not isinstance(env, framework.Environment):
    # For backwards compatibility we accept an Environment object. Otherwise assume it's a dict
    # whose bindings will add/overwrite the default bindings.
    env = framework.Environment(dict(_default_bindings, **env))
  obj = framework.eval(ast, env)
  return mod_schema.validate(obj, schema)
94923
def load(self, _override=True, _allow_undeclared=False, **kwargs):
    """"""
    self.load_from_dict(
        kwargs, _override=_override, _allow_undeclared=_allow_undeclared)
40778
def _load(self, filename):
        """"""
        filename = pathlib.Path(filename)
        with filename.open() as fd:
            data = fd.readlines()

        # Get the strings that correspond to self.fileid
        bool_head = [l.strip().startswith("[") for l in data]

        int_head = np.squeeze(np.where(bool_head))
        int_head = np.atleast_1d(int_head)

        start = int_head[self.fileid]+1

        if len(int_head) > self.fileid+1:
            end = int_head[self.fileid+1]
        else:
            end = len(data)

        subdata = data[start:end]

        # separate all elements and strip them
        subdata = [[it.strip() for it in l.split("=")] for l in subdata]

        points = []

        for var, val in subdata:
            if var.lower() == "x axis":
                xaxis = val.lower()
            elif var.lower() == "y axis":
                yaxis = val.lower()
            elif var.lower() == "name":
                self.name = val
            elif var.lower() == "inverted":
                if val == "True":
                    self.inverted = True
            elif var.lower().startswith("point"):
                val = np.array(val.strip("[]").split(), dtype=float)
                points.append([int(var[5:]), val])
            else:
                raise KeyError("Unknown variable: {} = {}".
                               format(var, val))
        self.axes = (xaxis, yaxis)
        # sort points
        points.sort()
        # get only coordinates from points
        self.points = np.array([p[1] for p in points])

        # overwrite unique id
        unique_id = int(data[start-1].strip().strip("Polygon []"))
        self._set_unique_id(unique_id)