In case of buffer size not aligned to sample_width pad it with 0s
438720
def align_buf(buf, sample_width):
    """"""
    remainder = len(buf) % sample_width
    if remainder != 0:
        buf += b'\0' * (sample_width - remainder)
    return buf
605519
def serialtoflat(self, bytes, width=None):
        

        if self.bitdepth == 8:
            return bytes
        if self.bitdepth == 16:
            bytes = tostring(bytes)
            return array('H',
              struct.unpack('!%dH' % (len(bytes)//2), bytes))
        assert self.bitdepth < 8
        if width is None:
            width = self.width
        # Samples per byte
        spb = 8//self.bitdepth
        out = array('B')
        mask = 2**self.bitdepth - 1
        shifts = map(self.bitdepth.__mul__, reversed(range(spb)))
        l = width
        for o in bytes:
            out.extend([(mask&(o>>s)) for s in shifts][:l])
            l -= spb
            if l <= 0:
                l = width
        return out
492720
def _resize_buffers(self, font_scale):
        """"""
        new_sizes = (font_scale,) + self.size
        if new_sizes == self._current_sizes:  # don't need resize
            return
        self._n_rows = int(max(self.size[1] /
                               (self._char_height * font_scale), 1))
        self._n_cols = int(max(self.size[0] /
                               (self._char_width * font_scale), 1))
        self._bytes_012 = np.zeros((self._n_rows, self._n_cols, 3), np.float32)
        self._bytes_345 = np.zeros((self._n_rows, self._n_cols, 3), np.float32)
        pos = np.empty((self._n_rows, self._n_cols, 2), np.float32)
        C, R = np.meshgrid(np.arange(self._n_cols), np.arange(self._n_rows))
        # We are in left, top orientation
        x_off = 4.
        y_off = 4 - self.size[1] / font_scale
        pos[..., 0] = x_off + self._char_width * C
        pos[..., 1] = y_off + self._char_height * R
        self._position = VertexBuffer(pos)

        # Restore lines
        for ii, line in enumerate(self._text_lines[:self._n_rows]):
            self._insert_text_buf(line, ii)
        self._current_sizes = new_sizes
802348
def padding(self):
        
        pad = self.ntiles - self.windowsize
        return (int((pad - 1)/2.), int((pad + 1)/2.))
515902
def padded_ds(ll_input, size=(250, 300), resize_method=ResizeMethod.CROP, padding_mode='zeros', **kwargs):
        ""
        return ll_input.transform(tfms=crop_pad(), size=size, resize_method=resize_method, padding_mode=padding_mode)
232096
def dump_uvarint_b_into(n, buffer, offset=0):
    
    shifted = True
    while shifted:
        shifted = n >> 7
        buffer[offset] = (n & 0x7F) | (0x80 if shifted else 0x00)
        offset += 1
        n = shifted
    return buffer
446873
private void resizeBuffer() {
        if (buffer == null) {
            buffer = new byte[getDefaultBufferSize()];
            pos = 0;
            readPos = 0;
        } else {
            byte[] b = new byte[buffer.length * DEFAULT_BUFFER_RESIZE_FACTOR];
            System.arraycopy(buffer, 0, b, 0, buffer.length);
            buffer = b;
        }
    }
550471
def _check_buffer(self, data, ctype):
        """"""
        assert ctype in _ffi_types.values()
        if not isinstance(data, bytes):
            data = _ffi.from_buffer(data)
        frames, remainder = divmod(len(data),
                                   self.channels * _ffi.sizeof(ctype))
        if remainder:
            raise ValueError("Data size must be a multiple of frame size")
        return data, frames
884021
def serialtoflat(self, raw, width=None):
        """"""
        if self.bitdepth == 8:
            return raw
        if self.bitdepth == 16:
            raw = bytearray_to_bytes(raw)
            return array('H',
              struct.unpack('!%dH' % (len(raw) // 2), raw))
        assert self.bitdepth < 8
        if width is None:
            width = self.width
        # Samples per byte
        spb = 8 // self.bitdepth
        out = newBarray()
        mask = 2**self.bitdepth - 1
        #                                      reversed range(spb)
        shifts = [self.bitdepth * it for it in range(spb - 1, -1, -1)]
        l = width
        for o in raw:
            out.extend([(mask&(o>>s)) for s in shifts][:l])
            l -= spb
            if l <= 0:
                l = width
        return out
824175
void zeroWidthSpace(int indentLevel) throws IOException {
    if (closed) throw new IllegalStateException("closed");

    if (column == 0) return;
    if (this.nextFlush != null) flush(nextFlush);
    this.nextFlush = FlushType.EMPTY;
    this.indentLevel = indentLevel;
  }
658561
function truncateSamples(samples) {
  /** @type {number} */   
  let len = samples.length;
  for (let i=0; i<len; i++) {
    if (samples[i] > 1) {
      samples[i] = 1;
    } else if (samples[i] < -1) {
      samples[i] = -1;
    }
  }
}
1164041
function getBufferPadded(buffer) {
    const boundary = 4;
    const byteLength = buffer.length;
    const remainder = byteLength % boundary;
    if (remainder === 0) {
        return buffer;
    }
    const padding = (remainder === 0) ? 0 : boundary - remainder;
    const emptyBuffer = Buffer.alloc(padding);
    return Buffer.concat([buffer, emptyBuffer]);
}
1288593
def _check_trim(data):
    
    trim = data["algorithm"].get("trim_reads")
    if trim:
        if trim == "fastp" and data["algorithm"].get("align_split_size") is not False:
            raise ValueError("In sample %s, `trim_reads: fastp` currently requires `align_split_size: false`" %
                             (dd.get_sample_name(data)))
757682
def _reformat(p, buf):
    
    if numpy.ndim(buf) != 1:
        raise ValueError("Buffer ``buf`` must be 1-d.")
    if hasattr(p, 'keys'):
        ans = _gvar.BufferDict(p)
        if ans.size != len(buf):
            raise ValueError(       #
                "p, buf size mismatch: %d, %d"%(ans.size, len(buf)))
        ans = _gvar.BufferDict(ans, buf=buf)
    else:
        if numpy.size(p) != len(buf):
            raise ValueError(       #
                "p, buf size mismatch: %d, %d"%(numpy.size(p), len(buf)))
        ans = numpy.array(buf).reshape(numpy.shape(p))
    return ans
198832
def _pad_string(self, str, colwidth):
        """"""
        width = self._disp_width(str)
        prefix = (colwidth - 1 - width) // 2
        suffix = colwidth - prefix - width
        return ' ' * prefix + str + ' ' * suffix
1296033
function fullWidth(text, param) {
    let cols = process.stdout.columns;
    let lines = text.split('\n');

    for (i = 0; i < lines.length; i++) {
        let size = cols;
        if (i === 0) size = size - 15;
        if ((lines[i].indexOf('%') > 0) && (param !== undefined)) size = size - param.length + 2;
        while (lines[i].length < size) {
            lines[i] = lines[i] + ' ';
        }
    }
    text = lines.join('\n');

    return text;
}
1139281
boolean checkPaddingBytes(QrCode qr, int lengthBytes) {
		boolean a = true;

		for (int i = lengthBytes; i < qr.corrected.length; i++) {
			if (a) {
				if (0b00110111 != (qr.corrected[i] & 0xFF))
					return false;
			} else {
				if (0b10001000 != (qr.corrected[i] & 0xFF)) {
					// the pattern starts over at the beginning of a block. Strictly enforcing the standard
					// requires knowing size of a data chunk and where it starts. Possible but
					// probably not worth the effort the implement as a strict requirement.
					if (0b00110111 == (qr.corrected[i] & 0xFF)) {
						a = true;
					} else {
						return false;
					}
				}
			}
			a = !a;
		}

		return true;
	}