Restore object from mat-file. TODO: determine format specification
505304
def restore(self, filename):
        
        matfile = loadmat(filename)
        matfile['originals'] = matfile['originals'][0, 0]

        if matfile['dim'] == 1:
            matfile['init_solution'] = matfile['init_solution'][0, :]
            matfile['pumping'] = matfile['pumping'][0, :]

        self.coeffs = matfile['dimlesses'][0, :]
        self.init_sol = matfile['init_solution']
        self.num_nodes = matfile['num_nodes'][0, 0]
        self.num_iters = matfile['num_iters'][0, 0]
        self.pumping = GridPumping(matfile['pumping'])
        self.dx = matfile['spatial_step'][0, 0]
        self.dt = matfile['time_step'][0, 0]

        types = matfile['originals'].dtype
        values = matfile['originals']

        self.originals = dict(zip(types.names, (value[0, 0] for value in values)))

        if 'desc' in matfile:
            self.desc = str(matfile['desc'][0])
        if 'label' in matfile:
            self.label = str(matfile['label'][0])

        return self
713423
def store(self, filename=None, label=None, desc=None, date=None):
        
        date = date if date else datetime.now()
        date = date.replace(microsecond=0).isoformat()
        filename = filename if filename else date + '.mat'

        matfile = {
            'model': str(type(self)),
            'date': date,
            'dim': len(self.init_sol.shape),
            'dimlesses': self.coeffs,
            'init_solution': self.init_sol,
            'num_iters': self.num_iters,
            'num_nodes': self.num_nodes,
            'order': self.order,
            'originals': self.originals,
            'pumping': self.getPumping(),
            'spatial_step': self.dx,
            'time_step': self.dt,
        }

        if desc:
            matfile['desc'] = desc
        if label:
            matfile['label'] = label

        savemat(filename, matfile)
848927
def dump(self, obj, context=None):
        """"""
        return self.schema_class(context=context).dump(obj).data
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
1323573
def _restore_file_lmt(self):
        # type: (Descriptor) -> None
        
        if not self._restore_file_properties.lmt or self._ase.lmt is None:
            return
        # timestamp() func is not available in py27
        ts = time.mktime(self._ase.lmt.timetuple())
        os.utime(str(self.final_path), (ts, ts))
89289
def load_data_to_net(net, inst_net):
  ''' '''
  net.dat['nodes'] = inst_net['nodes']
  net.dat['mat'] = inst_net['mat']
  data_formats.mat_to_numpy_arr(net)
943092
function format (obj, sub) {
    var x = utils.clone(obj);
    if (x) {
        if ('Binary' === x.constructor.name) {
            x = '[object Buffer]';
        } else if ('ObjectID' === x.constructor.name) {
            var representation = 'ObjectId("' + x.toHexString() + '")';
            x = { inspect: function() { return representation; } };
        } else if ('Date' === x.constructor.name) {
            var representation = 'new Date("' + x.toUTCString() + '")';
            x = { inspect: function() { return representation; } };
        } else if ('Object' === x.constructor.name) {
            var keys = Object.keys(x)
                , i = keys.length
                , key
            while (i--) {
                key = keys[i];
                if (x[key]) {
                    if ('Binary' === x[key].constructor.name) {
                        x[key] = '[object Buffer]';
                    } else if ('Object' === x[key].constructor.name) {
                        x[key] = format(x[key], true);
                    } else if ('ObjectID' === x[key].constructor.name) {
                        ;(function(x){
                            var representation = 'ObjectId("' + x[key].toHexString() + '")';
                            x[key] = { inspect: function() { return representation; } };
                        })(x)
                    } else if ('Date' === x[key].constructor.name) {
                        ;(function(x){
                            var representation = 'new Date("' + x[key].toUTCString() + '")';
                            x[key] = { inspect: function() { return representation; } };
                        })(x)
                    } else if (Array.isArray(x[key])) {
                        x[key] = x[key].map(function (o) {
                            return format(o, true)
                        });
                    }
                }
            }
        }
        if (sub) return x;
    }

    return require('util')
        .inspect(x, false, 10, true)
        .replace(/\n/g, '')
        .replace(/\s{2,}/g, ' ')
}
110707
def restore_from_object(self, obj):
        

        info = pickle.loads(obj)
        data = info["data"]
        tmpdir = tempfile.mkdtemp("restore_from_object", dir=self.logdir)
        checkpoint_path = os.path.join(tmpdir, info["checkpoint_name"])

        for file_name, file_contents in data.items():
            with open(os.path.join(tmpdir, file_name), "wb") as f:
                f.write(file_contents)

        self.restore(checkpoint_path)
        shutil.rmtree(tmpdir)
1334222
private static DataNormalization restoreNormalizerFromFileDeprecated(File file) {
        try (ZipFile zipFile = new ZipFile(file)) {
            ZipEntry norm = zipFile.getEntry(NORMALIZER_BIN);

            // checking for file existence
            if (norm == null)
                return null;

            InputStream stream = zipFile.getInputStream(norm);
            ObjectInputStream ois = new ObjectInputStream(stream);

            try {
                DataNormalization normalizer = (DataNormalization) ois.readObject();
                return normalizer;
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
1163141
def resolve(object):
    """"""


    import re
    sesame_cmd = 'curl -s http://cdsweb.u-strasbg.fr/viz-bin/nph-sesame/-oI?'+string.replace(object,' ','')
    f = os.popen(sesame_cmd)
    lines = f.readlines()
    f.close()
    for line in lines:        
        if re.search('%J ', line):
            result2 = line.split()
            ra_deg = float(result2[1])
            dec_deg = float(result2[2])
            return (ra_deg, dec_deg)
        
    return (0,0)
404518
def loads(astring):
        """"""
        try:
            return pickle.loads(lzma.decompress(astring))
        except lzma.LZMAError as e:
            raise SerializerError(
                'Cannot decompress object ("{}")'.format(str(e))
            )
        except pickle.UnpicklingError as e:
            raise SerializerError(
                'Cannot restore object ("{}")'.format(str(e))
            )
284938
def pretty_format(obj, indent=None):
        
        if indent is None:
            if isinstance(obj, TLObject):
                obj = obj.to_dict()

            if isinstance(obj, dict):
                return '{}({})'.format(obj.get('_', 'dict'), ', '.join(
                    '{}={}'.format(k, TLObject.pretty_format(v))
                    for k, v in obj.items() if k != '_'
                ))
            elif isinstance(obj, str) or isinstance(obj, bytes):
                return repr(obj)
            elif hasattr(obj, '__iter__'):
                return '[{}]'.format(
                    ', '.join(TLObject.pretty_format(x) for x in obj)
                )
            else:
                return repr(obj)
        else:
            result = []
            if isinstance(obj, TLObject):
                obj = obj.to_dict()

            if isinstance(obj, dict):
                result.append(obj.get('_', 'dict'))
                result.append('(')
                if obj:
                    result.append('\n')
                    indent += 1
                    for k, v in obj.items():
                        if k == '_':
                            continue
                        result.append('\t' * indent)
                        result.append(k)
                        result.append('=')
                        result.append(TLObject.pretty_format(v, indent))
                        result.append(',\n')
                    result.pop()  # last ',\n'
                    indent -= 1
                    result.append('\n')
                    result.append('\t' * indent)
                result.append(')')

            elif isinstance(obj, str) or isinstance(obj, bytes):
                result.append(repr(obj))

            elif hasattr(obj, '__iter__'):
                result.append('[\n')
                indent += 1
                for x in obj:
                    result.append('\t' * indent)
                    result.append(TLObject.pretty_format(x, indent))
                    result.append(',\n')
                indent -= 1
                result.append('\t' * indent)
                result.append(']')

            else:
                result.append(repr(obj))

            return ''.join(result)
74738
def restore(self, x):
    
    with tf.name_scope("pad_reduce/restore"):
      x = tf.scatter_nd(
          indices=self.nonpad_ids,
          updates=x,
          shape=tf.concat([self.dim_origin, tf.shape(x)[1:]], axis=0),
      )
    return x
521527
function toMap(arr, fn) {
  var obj = {};
  var i, elem;
  for (i = 0; i < arr.length; i++) {
    elem = arr[i];
    obj[fn(elem)] = elem;
  }
  return obj;
}
956357
def restore_type(self, type):
        

        # All dialects
        mapping = {
            ARRAY: 'array',
            sa.Boolean: 'boolean',
            sa.Date: 'date',
            sa.DateTime: 'datetime',
            sa.Float: 'number',
            sa.Integer: 'integer',
            JSONB: 'object',
            JSON: 'object',
            sa.Numeric: 'number',
            sa.Text: 'string',
            sa.Time: 'time',
            sa.VARCHAR: 'string',
            UUID: 'string',
        }

        # Get field type
        field_type = None
        for key, value in mapping.items():
            if isinstance(type, key):
                field_type = value

        # Not supported
        if field_type is None:
            message = 'Type "%s" is not supported'
            raise tableschema.exceptions.StorageError(message % type)

        return field_type
1337931
def reconstruct(self, X=None):
        """"""

        if X is None:
            X = self.X
        return self.D.dot(self.X)
520927
def pformat(
    object,
    indent=_UNSET_SENTINEL,
    width=_UNSET_SENTINEL,
    depth=_UNSET_SENTINEL,
    *,
    ribbon_width=_UNSET_SENTINEL,
    max_seq_len=_UNSET_SENTINEL,
    compact=_UNSET_SENTINEL,
    sort_dict_keys=_UNSET_SENTINEL
):
    
    sdocs = python_to_sdocs(
        object,
        **_merge_defaults(
            indent=indent,
            width=width,
            depth=depth,
            ribbon_width=ribbon_width,
            max_seq_len=max_seq_len,
            sort_dict_keys=sort_dict_keys,
        )
    )
    stream = StringIO()
    default_render_to_stream(stream, sdocs)
    return stream.getvalue()