Transform the memory into bytes

        :param memory: Compose memory definition. (1g, 24k)
        :type memory: memory string or integer
        :return: The memory in bytes
        :rtype: int
325814
def ingest_memory(self, memory):
        
        def lshift(num, shift):
            return num << shift

        def rshift(num, shift):
            return num >> shift

        if isinstance(memory, int):
            # Memory was specified as an integer, meaning it is in bytes
            memory = '{}b'.format(memory)

        bit_shift = {
            'g': {'func': lshift, 'shift': 30},
            'm': {'func': lshift, 'shift': 20},
            'k': {'func': lshift, 'shift': 10},
            'b': {'func': rshift, 'shift': 0}
        }
        unit = memory[-1]
        number = int(memory[:-1])
        return bit_shift[unit]['func'](number, bit_shift[unit]['shift'])
869952
def convert_bytes(value):
    
    n = np.rint(len(str(value))/4).astype(int)
    return value/(1024**n), sizes[n]
517249
def ingest_memory(self, memory):
        
        def lshift(num, shift):
            return num << shift

        def k(num, thousands):
            return num * thousands

        # if isinstance(memory, int):
        #     # Memory was specified as an integer, meaning it is in bytes
        memory = str(memory)

        bit_shift = {
            'E': {'func': k, 'shift': 10e17},
            'P': {'func': k, 'shift': 10e14},
            'T': {'func': k, 'shift': 10e11},
            'G': {'func': k, 'shift': 10e8},
            'M': {'func': k, 'shift': 10e5},
            'K': {'func': k, 'shift': 10e2},
            'Ei': {'func': lshift, 'shift': 60},
            'Pi': {'func': lshift, 'shift': 50},
            'Ti': {'func': lshift, 'shift': 40},
            'Gi': {'func': lshift, 'shift': 30},
            'Mi': {'func': lshift, 'shift': 20},
            'Ki': {'func': lshift, 'shift': 10},
        }

        if len(memory) > 2 and memory[-2:] in bit_shift.keys():
            unit = memory[-2:]
            number = int(memory[:-2])
            memory = bit_shift[unit]['func'](number, bit_shift[unit]['shift'])
        elif len(memory) > 1 and memory[-1:] in bit_shift.keys():
            unit = memory[-1]
            number = int(memory[:-1])
            memory = bit_shift[unit]['func'](number, bit_shift[unit]['shift'])
        # Cast to a float to properly consume scientific notation
        return int(float(memory))
1083421
def write_to_memory
      len = Vips::SizeStruct.new
      ptr = Vips::vips_image_write_to_memory self, len

      # wrap up as an autopointer
      ptr = FFI::AutoPointer.new(ptr, GLib::G_FREE)

      ptr.get_bytes 0, len[:value]
    end
1172185
def to_bytes(self):
        '''
        
        '''
        # Verify that properties make sense
        self.sanitize()

        # Start with the type
        bitstream = BitArray('uint:4=%d' % self.message_type)

        # Add padding
        bitstream += self._reserved1

        # Add the record count
        bitstream += BitArray('uint:8=%d' % len(self.records))

        # Add the nonce
        bitstream += BitArray(bytes=self.nonce)

        # Add the records
        for record in self.records:
            bitstream += record.to_bitstream()

        return bitstream.bytes
1180673
def parse_memory(mem, resource):
    
    lsf_unit = get_lsf_units(resource=resource)
    return convert_mb(float(mem) * 1024, lsf_unit)
970640
def convert_to_mb(s):
    """"""
    s = s.upper()
    try:
        if s.endswith('G'):
            return float(s[:-1].strip()) * 1024
        elif s.endswith('T'):
            return float(s[:-1].strip()) * 1024 * 1024
        else:
            return float(s[:-1].strip())
    except (IndexError, ValueError, KeyError, TypeError):
        errmsg = ("Invalid memory format: %s") % s
        raise exception.SDKInternalError(msg=errmsg)
15932
def writeBytes(self, b):
        
        self.stream.write(TYPE_STRING)

        self.serialiseBytes(b)
525235
def to_unit_memory(number):
    """"""
    kb = 1024

    number /= kb

    if number < 100:
        return '{} Kb'.format(round(number, 2))

    number /= kb
    if number < 300:
        return '{} Mb'.format(round(number, 2))

    number /= kb

    return '{} Gb'.format(round(number, 2))
593147
def to_bytes(s):
    '''
    '''
    if isinstance(s, six.binary_type):
        return s
    if isinstance(s, six.string_types):
        return s.encode('utf-8')
    raise TypeError('want string or bytes, got {}', type(s))
621188
def __write_byte(self, address, value):
        
        # Save previous address content.
        if address in self._memory:
            self.__memory_prev[address] = self._memory[address]

        self._memory[address] = value & 0xff
54637
def _parse_memory(s):
    
    units = {'g': 1024, 'm': 1, 't': 1 << 20, 'k': 1.0 / 1024}
    if s[-1].lower() not in units:
        raise ValueError("invalid format: " + s)
    return int(float(s[:-1]) * units[s[-1].lower()])
360226
def int_to_bytes(int_value: int, length: int) -> bytes:
    
    if length == 1:
        fmt = "!B"
    elif length == 2:
        fmt = "!H"
    return pack(fmt, int_value)
1079721
def _read_byte(self, address):
        
        # Initialize memory location with a random value.
        if address not in self._memory:
            self._memory[address] = random.randint(0x00, 0xff)

        return self._memory[address]
451008
def to_bytes(s):
    
    if bytes != str:
        if type(s) == str:
            return s.encode('utf-8')
    return s
499556
def bytes(self):
        
        result = []
        op = self.opcode.split(' ')
        argi = 0

        while op:
            q = op.pop(0)

            if q == 'XX':
                for k in range(self.argbytes[argi] - 1):
                    op.pop(0)

                result.extend(num2bytes(self.argval()[argi], self.argbytes[argi]))
                argi += 1
            else:
                result.append(int(q, 16))  # Add opcode

        if len(result) != self.size:
            raise InternalMismatchSizeError(len(result), self)

        return result
342432
def memory():
    

    mem_info = dict()

    for k, v in psutil.virtual_memory()._asdict().items():
           mem_info[k] = int(v)
           
    return mem_info