de-mix a mixed servo output
775136
def demix1(servo1, servo2, gain=0.5):
    ''''''
    s1 = servo1 - 1500
    s2 = servo2 - 1500
    out1 = (s1+s2)*gain
    out2 = (s1-s2)*gain
    return out1+1500
465938
function mix(objs, deep) {
	const gobj = gawk(objs.shift());
	if (!isGawked(gobj) || Array.isArray(gobj)) {
		throw new TypeError('Expected destination to be a gawked object');
	}

	if (!objs.length) {
		return gobj;
	}

	// validate the objects are good
	for (const obj of objs) {
		if (!obj || typeof obj !== 'object' || Array.isArray(obj)) {
			throw new TypeError('Expected merge source to be an object');
		}
	}

	// we need to detach the parent and all listeners so that they will be notified after everything
	// has been merged
	gobj.__gawk__.pause();

	/**
	 * Mix an object or gawked object into a gawked object.
	 * @param {Object} gobj - The destination gawked object.
	 * @param {Object} src - The source object to copy from.
	 */
	const mixer = (gobj, src) => {
		for (const key of Object.getOwnPropertyNames(src)) {
			if (key === '__gawk__') {
				continue;
			}

			const srcValue = src[key];

			if (deep && srcValue !== null && typeof srcValue === 'object' && !Array.isArray(srcValue)) {
				if (!isGawked(gobj[key])) {
					gobj[key] = gawk({}, gobj);
				}
				mixer(gobj[key], srcValue);
			} else if (Array.isArray(gobj[key]) && Array.isArray(srcValue)) {
				// overwrite destination with new values
				gobj[key].splice(0, gobj[key].length, ...srcValue);
			} else {
				gobj[key] = gawk(srcValue, gobj);
			}
		}
	};

	for (const obj of objs) {
		mixer(gobj, obj);
	}

	gobj.__gawk__.resume();

	return gobj;
}
749163
def _out(ins):
    
    output = _8bit_oper(ins.quad[2])
    output.extend(_16bit_oper(ins.quad[1]))
    output.append('ld b, h')
    output.append('ld c, l')
    output.append('out (c), a')

    return output
492659
def mixin(self):
        
        methods = self.obj
        for i, k in enumerate(methods):
            setattr(underscore, k, methods[k])

        self.makeStatic()
        return self._wrap(self.obj)
424297
def mix_wave(src, dst):
    """"""
    if len(src) > len(dst):
        # output should be longer
        dst, src = src, dst

    for i, sv in enumerate(src):
        dv = dst[i]
        if sv < 128 and dv < 128:
            dst[i] = int(sv * dv / 128)
        else:
            dst[i] = int(2 * (sv + dv) - sv * dv / 128 - 256)
    return dst
818142
def update_channels(self):
        ''''''
        self.interlock_channel = -1
        self.override_channel = -1
        self.zero_I_channel = -1
        self.no_vtol_channel = -1

        # output channels
        self.rsc_out_channel = 9
        self.fwd_thr_channel = 10

        for ch in range(1,16):
            option = self.get_mav_param("RC%u_OPTION" % ch, 0)
            if option == 32:
                self.interlock_channel = ch;
            elif option == 63:
                self.override_channel = ch;
            elif option == 64:
                self.zero_I_channel = ch;
            elif option == 65:
                self.override_channel = ch;
            elif option == 66:
                self.no_vtol_channel = ch;

            function = self.get_mav_param("SERVO%u_FUNCTION" % ch, 0)
            if function == 32:
                self.rsc_out_channel = ch
            if function == 70:
                self.fwd_thr_channel = ch
911214
def strip_command(self, command_string, output):
        """"""
        output_list = output.split(command_string)
        return self.RESPONSE_RETURN.join(output_list)
124953
def disable_all(self, disable):
        """"""
        commands = ['ENBH 0', #disable high freq. rear output
                    'ENBL 0', #disable low freq. front bnc
                    'MODL 0'   #disable modulation
                    ]
        command_string = '\n'.join(commands)
        print_string = '\n\t' + command_string.replace('\n', '\n\t')
        logging.info(print_string)
        if disable:
            self.instr.write(command_string)
714220
def qwarp_invert(warp_param_dset,output_dset,affine_1Dfile=None):
    ''''''

    cmd = ['3dNwarpCat','-prefix',output_dset]

    if affine_1Dfile:
        cmd += ['-warp1','INV(%s)' % affine_1Dfile, '-warp2','INV(%s)' % warp_param_dset]
    else:
        cmd += ['-warp1','INV(%s)' % warp_param_dset]

    nl.run(cmd,products=output_dset)
280743
def disassemble(self, code, lasti=-1, file=None):
        """"""
        return self.disco(code, lasti, file)
849176
def clear_signal_handlers(self):
        '''

        '''
        signal.signal(signal.SIGABRT, self.old_sigabrt)
        signal.signal(signal.SIGINT, self.old_sigint)
        signal.signal(signal.SIGPIPE, self.old_sigpipe)
        signal.signal(signal.SIGTERM, self.old_sigterm)
658638
function mixin(a, b) {
  Object.keys(b).forEach(function(key) {
    a[key] = b[key];
  });
}
562245
def _at_dump_mixins(self, calculator, rule, scope, block):
        
        sys.stderr.write("%s\n" % repr(rule.namespace._mixins))
347364
def scale_rc(self, servo, min, max, param):
        ''''''
        # default to servo range of 1000 to 2000
        min_pwm  = self.get_mav_param('%s_MIN'  % param, 0)
        max_pwm  = self.get_mav_param('%s_MAX'  % param, 0)
        if min_pwm == 0 or max_pwm == 0:
            return 0
        if max_pwm == min_pwm:
            p = 0.0
        else:
            p = (servo-min_pwm) / float(max_pwm-min_pwm)
        v = min + p*(max-min)
        if v < min:
            v = min
        if v > max:
            v = max
        return v
1132850
public static void removeZeros( DMatrixSparseCSC input , DMatrixSparseCSC  output , double tol ) {
        ImplCommonOps_DSCC.removeZeros(input,output,tol);
    }
1334089
function mixin(rework, declarations, mixins) {
  for (var i = 0; i < declarations.length; ++i) {
    var decl = declarations[i];
    if ('comment' == decl.type) continue;

    var key = decl.property;
    var val = decl.value;
    var fn = mixins[key];
    if (!fn) continue;

    // invoke mixin
    var ret = fn.call(rework, val);

    // apply properties
    for (var key in ret) {
      var val = ret[key];
      if (Array.isArray(val)) {
        val.forEach(function(val){
          declarations.splice(i++, 0, {
            type: 'declaration',
            property: key,
            value: val
          });
        });
      } else {
        declarations.splice(i++, 0, {
          type: 'declaration',
          property: key,
          value: val
        });
      }
    }

    // remove original
    declarations.splice(i--, 1);
  }
}
1328073
void freeOutput() {
        state.pool.free( output );
        output = outputs.size() > 0 ? outputs.removeLast() : null;
    }