inflate / decompress an object

 object:: object to decompress.
173361
def inflate_object(object = nil)
      return false unless object.is_a?(Hash)
      filter_array = object[:Filter]
      if filter_array.is_a?(Hash) && filter_array[:is_reference_only]
        filter_array = filter_array[:referenced_object]
      end
      filter_array = [filter_array] if filter_array.is_a?(Symbol)
      filter_array = [] if filter_array.nil?
      params_array = object[:DecodeParms]
      if params_array.is_a?(Hash) && params_array[:is_reference_only]
        params_array = params_array[:referenced_object]
      end
      params_array = [params_array] unless params_array.is_a?(Array)
      object[:Filter] = filter_array
      object[:DecodeParms] = params_array
      while filter_array[0]
        case filter_array[0]
        when :FlateDecode
          raise_unsupported_error params_array[0] unless params_array[0].nil?
          if params_array[0] && params_array[0][:Predictor].to_i > 1
            predictor = params_array[0][:Predictor].to_i
            # bits = params_array[0][:BitsPerComponent] || 8
            # columns = params_array[0][:Columns] || 1
            if (2..9).cover? predictor
              ####
              # prepare TIFF group
              raise_unsupported_error params_array[0]
            elsif (10..15).cover? predictor
              ####
              # prepare PNG group
              raise_unsupported_error params_array[0]
            end
          else
            inflator = Zlib::Inflate.new

            object[:raw_stream_content] = inflator.inflate object[:raw_stream_content]
            begin
              inflator.finish
            rescue
            end
            inflator.close
            object[:Length] = object[:raw_stream_content].bytesize
          end
        when nil
          true
        else
          return false
        end
        params_array.shift
        filter_array.shift
      end
      object.delete :Filter
      object.delete :DecodeParms
      true
    end
798218
def pickle_compress(obj, print_compression_info=False):
    """"""
    p = pickle.dumps(obj)
    c = zlib.compress(p)
    if print_compression_info:
        print ("len = {:,d} compr={:,d} ratio:{:.6f}".format(len(p), len(c), float(len(c))/len(p)))
    return c
794785
function reduceObject(o, fn, init) {
  for (let pair of objectPairs(o)) {
    let [key, val] = pair;
    init = fn(init, val, key, o);
  }
  return init;
}
204260
def destroy_decompress(dinfo):
    """"""
    argtypes = [ctypes.POINTER(DecompressionInfoType)]
    OPENJPEG.opj_destroy_decompress.argtypes = argtypes
    OPENJPEG.opj_destroy_decompress(dinfo)
363270
function zipObject(keys, values) {
  return keys.reduce(function(object, currentValue, currentIndex) {
    object[currentValue] = values[currentIndex];

    return object;
  }, {});
}
702380
def _decompress(self, fp):
        
        decompressor = zlib.decompressobj()
        if self.stream:
            return Proxy(decompressor.decompress, fp)
        else:
            out = io.BytesIO(decompressor.decompress(fp.read()))
            out.write(decompressor.flush())
            out.seek(0)
            return out
553136
function _decompressOther(jsonCopy) {
    var oKeys, str, sKey;

    oKeys = JSON.parse(JSON.stringify(jsonCopy._));
    delete jsonCopy._;
    str = JSON.stringify(jsonCopy);
    for (sKey in oKeys) {
      if (oKeys.hasOwnProperty(sKey)) {
        str = str.replace(new RegExp('"' + sKey + '"', 'g'), '"' + oKeys[sKey] + '"');
      }
    }
    return str;
  }
129802
def uncompress_file(s3_object)
      result = ''

      if s3_object.exists?
        io = StringIO.new
        io.write(s3_object.read)
        io.rewind

        gz = Zlib::GzipReader.new(io)
        result = gz.read

        gz.close
      end

      result
    end
1236436
function _compressOther(json, aKeys) {
    var oKeys,
      aKey,
      str,
      nLenKeys,
      nIndex,
      obj;
    aKeys = _getKeys(json, aKeys);
    aKeys = unique(aKeys);
    oKeys = _biDimensionalArrayToObject(aKeys);

    str = JSON.stringify(json);
    nLenKeys = aKeys.length;

    for (nIndex = 0; nIndex < nLenKeys; nIndex++) {
      aKey = aKeys[nIndex];
      str = str.replace(new RegExp(escapeRegExp('"' + aKey[1] + '"'), 'g'), '"' + aKey[0] + '"');
    }
    obj = JSON.parse(str);
    obj._ = oKeys;
    return obj;
  }
964838
def _setup_decompressor(self, response):
        ''''''
        encoding = response.fields.get('Content-Encoding', '').lower()

        if encoding == 'gzip':
            self._decompressor = wpull.decompression.GzipDecompressor()
        elif encoding == 'deflate':
            self._decompressor = wpull.decompression.DeflateDecompressor()
        else:
            self._decompressor = None
1215655
def inflate_dtype(arr, names):
    """"""
    arr = np.asanyarray(arr)
    if has_structured_dt(arr):
        return arr.dtype
    s_dt = arr.dtype
    dt = [(n, s_dt) for n in names]
    dt = np.dtype(dt)
    return dt
903066
def inflate(deflated_vector):
    """"""
    dv = json.loads(deflated_vector)
    #result = np.zeros(dv['reductions']) # some claim vector length 5555, others
    #5530. this could have occurred doing remote computations? or something.
    # anyhow, we will use 5555.  Let's just hard code it.  Gosh darnit.
    result = np.zeros(5555) # some claim vector length 5555, others
    for n in dv['indices']:
        result[int(n)] = dv['indices'][n]
    #print("Inflated vector. Length", len(result))
    return result
556283
def RegisterDecompressor(cls, decompressor):
    
    compression_method = decompressor.COMPRESSION_METHOD.lower()
    if compression_method in cls._decompressors:
      raise KeyError(
          'Decompressor for compression method: {0:s} already set.'.format(
              decompressor.COMPRESSION_METHOD))

    cls._decompressors[compression_method] = decompressor
1132260
def loads(astring):
        """"""
        try:
            return pickle.loads(zlib.decompress(astring))
        except zlib.error as e:
            raise SerializerError(
                'Cannot decompress object ("{}")'.format(str(e))
            )
        except pickle.UnpicklingError as e:
            raise SerializerError(
                'Cannot restore object ("{}")'.format(str(e))
            )
168488
def decompress_step(source, hparams, first_relu, name):
  """"""
  with tf.variable_scope(name):
    shape = common_layers.shape_list(source)
    multiplier = 2
    kernel = (1, 1)
    thicker = common_layers.conv_block(
        source,
        hparams.hidden_size * multiplier, [((1, 1), kernel)],
        first_relu=first_relu,
        name="decompress_conv")
    return tf.reshape(thicker, [shape[0], shape[1] * 2, 1, hparams.hidden_size])
329534
function (file, compression) {
      var result = new JSZip.CompressedObject(), content;

      // the data has not been decompressed, we might reuse things !
      if (file._data instanceof JSZip.CompressedObject) {
         result.uncompressedSize = file._data.uncompressedSize;
         result.crc32 = file._data.crc32;

         if (result.uncompressedSize === 0 || file.options.dir) {
            compression = JSZip.compressions['STORE'];
            result.compressedContent = "";
            result.crc32 = 0;
         } else if (file._data.compressionMethod === compression.magic) {
            result.compressedContent = file._data.getCompressedContent();
         } else {
            content = file._data.getContent()
            // need to decompress / recompress
            result.compressedContent = compression.compress(JSZip.utils.transformTo(compression.compressInputType, content));
         }
      } else {
         // have uncompressed data
         content = getBinaryData(file);
         if (!content || content.length === 0 || file.options.dir) {
            compression = JSZip.compressions['STORE'];
            content = "";
         }
         result.uncompressedSize = content.length;
         result.crc32 = this.crc32(content);
         result.compressedContent = compression.compress(JSZip.utils.transformTo(compression.compressInputType, content));
      }

      result.compressedSize = result.compressedContent.length;
      result.compressionMethod = compression.magic;

      return result;
   }
1306953
def from_object(self, obj: Union[str, Any]) -> None:
        """"""
        if isinstance(obj, str):
            obj = importer.import_object_str(obj)

        for key in dir(obj):
            if key.isupper():
                value = getattr(obj, key)
                self._setattr(key, value)

        logger.info("Config is loaded from object: %r", obj)