Convert pwm array to pssm array
182159
def pwm_array2pssm_array(arr, background_probs=DEFAULT_BASE_BACKGROUND):
    
    b = background_probs2array(background_probs)
    b = b.reshape([1, 4, 1])
    return np.log(arr / b).astype(arr.dtype)
397026
public int[] Multi8p(int x, int y, int masc[][]) {
        //a b c
        //d e f
        //g h i
        int aR = getIntComponent0(x - 1, y - 1);
        int bR = getIntComponent0(x - 1, y);
        int cR = getIntComponent0(x - 1, y + 1);
        int aG = getIntComponent1(x - 1, y - 1);
        int bG = getIntComponent1(x - 1, y);
        int cG = getIntComponent1(x - 1, y + 1);
        int aB = getIntComponent2(x - 1, y - 1);
        int bB = getIntComponent2(x - 1, y);
        int cB = getIntComponent2(x - 1, y + 1);


        int dR = getIntComponent0(x, y - 1);
        int eR = getIntComponent0(x, y);
        int fR = getIntComponent0(x, y + 1);
        int dG = getIntComponent1(x, y - 1);
        int eG = getIntComponent1(x, y);
        int fG = getIntComponent1(x, y + 1);
        int dB = getIntComponent2(x, y - 1);
        int eB = getIntComponent2(x, y);
        int fB = getIntComponent2(x, y + 1);


        int gR = getIntComponent0(x + 1, y - 1);
        int hR = getIntComponent0(x + 1, y);
        int iR = getIntComponent0(x + 1, y + 1);
        int gG = getIntComponent1(x + 1, y - 1);
        int hG = getIntComponent1(x + 1, y);
        int iG = getIntComponent1(x + 1, y + 1);
        int gB = getIntComponent2(x + 1, y - 1);
        int hB = getIntComponent2(x + 1, y);
        int iB = getIntComponent2(x + 1, y + 1);

        int rgb[] = new int[3];

        rgb[0] = ((aR * masc[0][0]) + (bR * masc[0][1]) + (cR * masc[0][2]) +
                (dR * masc[1][0]) + (eR * masc[1][1]) + (fR * masc[1][2]) +
                (gR * masc[2][0]) + (hR * masc[2][1]) + (iR * masc[2][2]));

        rgb[1] = ((aG * masc[0][0]) + (bG * masc[0][1]) + (cG * masc[0][2]) +
                (dG * masc[1][0]) + (eG * masc[1][1]) + (fG * masc[1][2]) +
                (gG * masc[2][0]) + (hG * masc[2][1]) + (iG * masc[2][2]));

        rgb[2] = ((aB * masc[0][0]) + (bB * masc[0][1]) + (cB * masc[0][2]) +
                (dB * masc[1][0]) + (eB * masc[1][1]) + (fB * masc[1][2]) +
                (gB * masc[2][0]) + (hB * masc[2][1]) + (iB * masc[2][2]));

        // return the value for all channel
        return (rgb);

    }
192516
public static void bits2prm_ld8k(
	 short bits[], int bitss,          /* input : serial bits (80)                       */
	 int   prm[], int ps            /* output: decoded parameters (11 parameters)     */
	)
	{
	   short i;
	   for (i = 0; i < LD8KConstants.PRM_SIZE; i++)
	     {
	        prm[i+ps] = bin2int(TabLD8k.bitsno[i], bits,bitss);
	        bitss  += TabLD8k.bitsno[i];
	     }

	}
1010051
def pulse_width(self):
        
        if self.pwm_device.pin.frequency is None:
            return None
        else:
            return self.pwm_device.pin.state * self.frame_width
815236
def set_pwm(self, channel, on, off):
        """"""
        self.i2c.write8(LED0_ON_L+4*channel, on & 0xFF)
        self.i2c.write8(LED0_ON_H+4*channel, on >> 8)
        self.i2c.write8(LED0_OFF_L+4*channel, off & 0xFF)
        self.i2c.write8(LED0_OFF_H+4*channel, off >> 8)
831609
private function getCpu(): array
	{
		$result = [];
		$cpuInfo = $this->readFile('/proc/cpuinfo');
		if ($cpuInfo) {
			$processors = preg_split('/\s?\n\s?\n/', trim($cpuInfo));
			$procname = null;
			foreach ($processors as $processor) {
				$cpu = new Obj;
				$proc = null;
				$arch = null;
				$details = preg_split("/\n/", $processor, -1, PREG_SPLIT_NO_EMPTY);
				foreach ($details as $detail) {
					$arrBuff = preg_split('/\s*:\s*/', trim($detail));
					if (count($arrBuff) == 2) {
						switch (strtolower($arrBuff[0])) {
							case 'processor':
								$proc = trim($arrBuff[1]);
								if (is_numeric($proc)) {
									if ($procname !== null && strlen($procname) > 0) {
										$cpu->model = $procname;
									}
								} else {
									$procname = $proc;
									$cpu->model = $procname;
								}
								break;
							case 'model name':
							case 'cpu model':
							case 'cpu type':
							case 'cpu':
								$cpu->model = $arrBuff[1];
								break;
							case 'cpu mhz':
							case 'clock':
								if ($arrBuff[1] > 0) { //openSUSE fix
									$cpu->speed = $arrBuff[1] * 1000 * 1000;
								}
								break;
							case 'cycle frequency [hz]':
								$cpu->speed = $arrBuff[1] * 1000 * 1000;
								break;
							case 'cpu0clktck':
								$cpu->speed = hexdec($arrBuff[1] * 1000 * 1000);
								break;
							case 'l2 cache':
							case 'cache size':
								$cpu->cache = ((float) preg_replace("/[a-zA-Z]/", "", $arrBuff[1])) * 1024;
								break;
							case 'initial bogomips':
							case 'bogomips':
							case 'cpu0bogo':
								$cpu->bogomips = $arrBuff[1];
								break;
							case 'i size':
							case 'd size':
								if ($cpu->cache === null) {
									$cpu->cache = $arrBuff[1] * 1024;
								} else {
									$cpu->cache = $cpu->cache + ($arrBuff[1] * 1024);
								}
								break;
							case 'cpu architecture':
								$arch = trim($arrBuff[1]);
								break;
						}
					}
				}

				// sparc64 specific code follows
				// This adds the ability to display the cache that a CPU has
				// Originally made by Sven Blumenstein <bazik@gentoo.org> in 2004
				// Modified by Tom Weustink <freshy98@gmx.net> in 2004
				$sparclist = array('SUNW,UltraSPARC@0,0', 'SUNW,UltraSPARC-II@0,0', 'SUNW,UltraSPARC@1c,0', 'SUNW,UltraSPARC-IIi@1c,0', 'SUNW,UltraSPARC-II@1c,0', 'SUNW,UltraSPARC-IIe@0,0');
				foreach ($sparclist as $name) {
					$str = $this->readFile('/proc/openprom/' . $name . '/ecache-size');
					if ($str) {
						$cpu->cache = base_convert($str, 16, 10);
					}
				}

				// sparc64 specific code ends
				// XScale detection code
				if (($arch === "5TE") && ($cpu->bogomips != null)) {
					$cpu->speed = $cpu->bogomips; //BogoMIPS are not BogoMIPS on this CPU, it's the speed
					$cpu->bogomips = null; // no BogoMIPS available, unset previously set BogoMIPS
				}

				if ($proc != null) {
					if (!is_numeric($proc)) {
						$proc = 0;
					}
					// variable speed processors specific code follows
					if ($str = $this->readFile('/sys/devices/system/cpu/cpu' . $proc . '/cpufreq/cpuinfo_cur_freq')) {
						$cpu->speed = ((float) $str) * 1000;
					} elseif ($str = $this->readFile('/sys/devices/system/cpu/cpu' . $proc . '/cpufreq/scaling_cur_freq')) {
						$cpu->speed = ((float) $str) * 1000;
					}
					if ($str = $this->readFile('/sys/devices/system/cpu/cpu' . $proc . '/cpufreq/cpuinfo_max_freq')) {
						$cpu->speedMax = ((float) $str) * 1000;
					}
					if ($str = $this->readFile('/sys/devices/system/cpu/cpu' . $proc . '/cpufreq/cpuinfo_min_freq')) {
						$cpu->speedMin = ((float) $str) * 1000;
					}
					if ($str = $this->readFile('/proc/acpi/thermal_zone/THRM/temperature')) {
						$cpu->temperature = substr($str, 25, 2);
					}
				}

				$cpu->usage = null;
				$result[] = $cpu;
			}


			// CPU usage
			$command = "grep 'cpu' /proc/stat";
			$cpuStats1 = $this->readCommandAsArray($command, "\n");
			sleep(1);
			$cpuStats2 = $this->readCommandAsArray($command, "\n");

			$counter = 0;
			for ($i = 0; $i < count($cpuStats1); $i++) {
				if (preg_match('/cpu[0-9]{1,2}/', $cpuStats1[$i]) > 0) {
					$stats1 = explode(' ', $cpuStats1[$i]);
					$stats2 = explode(' ', $cpuStats2[$i]);

					$prevIdle = $stats1[4] + $stats1[5];
					$idle = $stats2[4] + $stats2[5];
					$prevNonIdle = $stats1[1] + $stats1[2] + $stats1[3] + $stats1[6] + $stats1[7] + $stats1[8];
					$nonIdle = $stats2[1] + $stats2[2] + $stats2[3] + $stats2[6] + $stats2[7] + $stats2[8];
					$prevTotal = $prevIdle + $prevNonIdle;
					$total = $idle + $nonIdle;

					$result[$counter++]->usage = (float) (($total - $prevTotal) - ($idle - $prevIdle)) / ($total - $prevTotal) * 100;
				}
			}
		}
		return $result;
	}
236106
def steps(self, start, end):
        
        if not 0 <= start <= 1:
            raise ValueError('Values must be between 0 and 1.')
        if not 0 <= end <= 1:
            raise ValueError('Values must be between 0 and 1.')

        raw_start = self._to_single_raw_pwm(start)
        raw_end = self._to_single_raw_pwm(end)
        return abs(raw_start - raw_end)
1172176
function SmD(ms_per_unit, range) {
  this.ms_per_unit = ms_per_unit;
  this.range = range;
  this.range_in_ms = ms_per_unit * range;
}
420755
def generate_psms_split(fn, oldheader, bioset, splitcol):
    """"""
    try:
        splitcolnr = get_splitcolnr(oldheader, bioset, splitcol)
    except IndexError:
        raise RuntimeError('Cannot find bioset header column in '
                           'input file {}, though --bioset has '
                           'been passed'.format(fn))
    for psm in tsvreader.generate_tsv_psms(fn, oldheader):
        yield {'psm': psm,
               'split_pool': psm[oldheader[splitcolnr]]
               }
678074
def IPT_to_XYZ(cobj, *args, **kwargs):
    
    ipt_values = numpy.array(cobj.get_value_tuple())
    lms_values = numpy.dot(
        numpy.linalg.inv(IPTColor.conversion_matrices['lms_to_ipt']),
        ipt_values)

    lms_prime = numpy.sign(lms_values) * numpy.abs(lms_values) ** (1 / 0.43)

    xyz_values = numpy.dot(
        numpy.linalg.inv(IPTColor.conversion_matrices['xyz_to_lms']),
        lms_prime)
    return XYZColor(*xyz_values, observer='2', illuminant='d65')
594723
def convertSequenceMachineSequence(generatedSequences):
  
  sequenceList = []
  currentSequence = []
  for s in generatedSequences:
    if s is None:
      sequenceList.append(currentSequence)
      currentSequence = []
    else:
      currentSequence.append(s)

  return sequenceList
212933
public final void pcmpistrm(XMMRegister dst, XMMRegister src, Immediate imm8)
  {
    emitX86(INST_PCMPISTRM, dst, src, imm8);
  }
657419
public float[] calculate(float pSample[])
	{
		final int wAps = pSample.length / ss;
		int n2 = ss2;
//		int nu1 = nu - 1;
		int a = 0;

		for (int b=0; a<pSample.length; b++)
		{
			xre[b] = (long)(pSample[a]*FRAC_FAC);
			xim[b] = 0;
			a += wAps;
		}

		int x = 0;
		for (int l=1; l<=nu; l++)
		{
			for (int k=0; k<ss; k+=n2)
			{
				for (int i=1; i<=n2; i++)
				{
					final long c = fftCos[x];
					final long s = fftSin[x];
					final int kn2 = k + n2;
					final long tr = (xre[kn2]*c + xim[kn2]*s)>>FRAC_BITS;
					final long ti = (xim[kn2]*c - xre[kn2]*s)>>FRAC_BITS;
					xre[kn2] = xre[k] - tr;
					xim[kn2] = xim[k] - ti;
					xre[k] += tr;
					xim[k] += ti;
					k++;
					x++;
				}

			}

//			nu1--;
			n2 >>= 1;
		}

		for (int k=0; k<ss; k++)
		{
			final int r = fftBr[k];
			if (r > k)
			{
				final long tr = xre[k];
				final long ti = xim[k];
				xre[k] = xre[r];
				xim[k] = xim[r];
				xre[r] = tr;
				xim[r] = ti;
			}
		}

		mag[0] = ((float)((longSqrt(xre[0]*xre[0] + xim[0]*xim[0]))>>FRAC_BITS)) / ((float)ss);
		for (int i=1; i<ss2; i++)
			mag[i] = ((float)((longSqrt(xre[i]*xre[i] + xim[i]*xim[i])<<1)>>FRAC_BITS)) / ((float)ss);

		return mag;
	}
558500
def _to_raw_pwm(self, values):
        
        return [self._to_single_raw_pwm(values[i])
                for i in range(len(self._pins))]
1318390
def pwm_max_score(self):
        
        if self.max_score is None:
            score = 0
            for row in self.pwm:
                score += log(max(row) / 0.25 + 0.01)
            self.max_score = score
        
        return self.max_score
1247043
async def pin_6_pwm_128(my_board):
    
    # set the pin mode
    await my_board.set_pin_mode(6, Constants.PWM)

    # set the pin to 128
    await my_board.analog_write(6, 128)

    # let the led stay lit for 3 seconds
    await asyncio.sleep(3)

    # shutdown
    await my_board.shutdown()
956893
def convert_ram_sdp_wf(ADDR_WIDTH=8, DATA_WIDTH=8):
    '''  '''
    clk = Signal(bool(0))
    we = Signal(bool(0))
    addrw = Signal(intbv(0)[ADDR_WIDTH:])
    addrr = Signal(intbv(0)[ADDR_WIDTH:])
    di = Signal(intbv(0)[DATA_WIDTH:])
    do = Signal(intbv(0)[DATA_WIDTH:])
    toVerilog(ram_sdp_wf, clk, we, addrw, addrr, di, do)