This returns 150 minerals for OrbitalCommand instead of 550
971435
def morph_cost(self) -> Optional["Cost"]:
        
        # Fix for BARRACKSREACTOR which has tech alias [REACTOR] which has (0, 0) cost
        if self.tech_alias is None or self.tech_alias[0] in {UnitTypeId.TECHLAB, UnitTypeId.REACTOR}:
            return None
        # Morphing a HIVE would have HATCHERY and LAIR in the tech alias - now subtract HIVE cost from LAIR cost instead of from HATCHERY cost
        tech_alias_cost_minerals = max([self._game_data.units[tech_alias.value].cost.minerals for tech_alias in self.tech_alias])
        tech_alias_cost_vespene = max([self._game_data.units[tech_alias.value].cost.vespene for tech_alias in self.tech_alias])
        return Cost(
                self._proto.mineral_cost - tech_alias_cost_minerals,
                self._proto.vespene_cost - tech_alias_cost_vespene,
                self._proto.build_time
            )
373850
def _adjust_stoichiometry(self):
        
        num_O = len(list(self.particles_by_name('O')))
        num_Si = len(list(self.particles_by_name('Si')))
        n_deletions = num_O - 2*num_Si

        bottom_Os = [atom for atom in self.particles()
                     if atom.name == 'O' and
                        atom.pos[2] < self._O_buffer and
                        len(self.bond_graph.neighbors(atom)) == 1]

        for _ in range(n_deletions):
            O1 = random.choice(bottom_Os)
            bottom_Os.remove(O1)
            self.remove(O1)
777412
def results(self, limit=100):
        
        limited = True if self.high_mark is not None else False
        rmax = self.high_mark - self.low_mark if limited else None
        rnum = 0

        params = self.get_params()
        params["offset"] = self.low_mark
        params["limit"] = limit

        while not limited and rmax is None or rnum < rmax:
            if limited or rmax is not None:
                rleft = rmax - rnum
                params["limit"] = rleft if rleft < limit else limit

            r = self.resource._meta.api.http_resource("GET", self.resource._meta.resource_name, params=params)
            data = self.resource._meta.api.resource_deserialize(r.text)

            if not limited:
                rmax = data["meta"]["total_count"]

            if data["meta"]["total_count"] < rmax:
                rmax = data["meta"]["total_count"]

            params["offset"] = data["meta"]["offset"] + data["meta"]["limit"]

            for item in data["objects"]:
                rnum += 1
                yield item
425050
def to_s(n_cmds)
      show_size = n_cmds ? specific_max_size(n_cmds) : default_max_size

      commands = buffer.last(show_size)

      last_ids(show_size).zip(commands).map do |l|
        format("%<position>5d  %<command>s", position: l[0], command: l[1])
      end.join("\n") + "\n"
    end
876507
def range_n(self):
        """"""
        return self.sphere_index - self.dn, self.sphere_index + self.dn
1150930
def N50(arr):
  
  if len(arr) == 0:
    sys.stderr.write("ERROR: no content in array to take N50\n")
    sys.exit()
  tot = sum(arr)
  half = float(tot)/float(2)
  cummulative = 0
  for l in sorted(arr):
    cummulative += l
    if float(cummulative) > half: 
      return l
  sys.stderr.write("ERROR: problem finding M50\n")
  sys.exit()
462192
def calcMzFromMass(mass, charge):
    
    mz = (mass + (maspy.constants.atomicMassProton * charge)) / charge
    return mz
51042
def match(command, options, args):
    """"""
    build = ""
    possible = commands
    for l in command:
        build += l
        possible = filter(lambda w: w.startswith(build), possible)
    
    if len(possible) == 0:
        raise ArgError("Command invalid: %s" % command)
    
    if len(possible) > 1:
        raise ArgError("Ambiguous command: %s" % command)

    command = possible.pop()

    if not num_args[command](len(args)):
        raise ArgError("Bad number of args for command %s" % command)

    return command
560376
def _get_more(collection_name, num_to_return, cursor_id):
    """"""
    return b"".join([
        _ZERO_32,
        _make_c_string(collection_name),
        _pack_int(num_to_return),
        _pack_long_long(cursor_id)])
151071
def result(self):
        
        return {k: torch.stack(v) for k, v in self.accumulants.items()}
764749
private Double fetchDeploySuccessRatio(ObjectId collectorItemId) {
    int totalDeploys = 0, totalDeploySuccess = 0;
    Double deploySuccessScore = null;

    List<EnvironmentComponent> components = environmentComponentRepository
      .findByCollectorItemId(collectorItemId);

    if (null == components || components.isEmpty()) {
      return null;
    }

    for (EnvironmentComponent environmentComponent : components) {
      totalDeploys++;
      if (environmentComponent.isDeployed()) {
        totalDeploySuccess++;
      }
    }
    deploySuccessScore = ((totalDeploySuccess * 100) / (double) totalDeploys);
    LOGGER.info("totalDeploys " + totalDeploys + " totalDeploySuccess " + totalDeploySuccess + " deploySuccessScore " + deploySuccessScore);

    return deploySuccessScore;
  }
1365366
def _compute_site_term(self, C, vs30):
        
        # for rock values the site term is zero
        site_term = np.zeros_like(vs30)

        # hard soil
        site_term[(vs30 >= 360) & (vs30 < 800)] = C['aB']

        # medium soil
        site_term[(vs30 >= 180) & (vs30 < 360)] = C['aC']

        # soft soil
        site_term[vs30 < 180] = C['aD']

        return site_term
633738
def _alloc(self):
        
        nzeros = [0] * self.n
        for var in self._states:
            self.__dict__[var] = nzeros[:]
        for var in self._algebs:
            self.__dict__[var] = nzeros[:]
145516
def get_pelecs_and_pions(self, convert_to_muC_per_cm2=False):
        

        if not convert_to_muC_per_cm2:
            return self.p_elecs, self.p_ions

        if convert_to_muC_per_cm2:
            p_elecs = self.p_elecs.T
            p_ions = self.p_ions.T

            volumes = [s.lattice.volume for s in self.structures]
            e_to_muC = -1.6021766e-13
            cm2_to_A2 = 1e16
            units = 1.0 / np.array(volumes)
            units *= e_to_muC * cm2_to_A2

            p_elecs = np.matmul(units, p_elecs)
            p_ions = np.matmul(units, p_ions)

            p_elecs, p_ions = p_elecs.T, p_ions.T

            return p_elecs, p_ions
907581
function swarmHashBlock (data, totalLength) {
  var hash = new Keccak(256)
  var tmp = Buffer.alloc(8)
  tmp.writeUIntLE(totalLength, 0, 6)
  hash.update(tmp)
  hash.update(data)
  return Buffer.from(hash.digest('bin'), 'binary')
}
562904
def send_command_return_multilines(self, obj, command, *arguments):
        
        index_command = obj._build_index_command(command, *arguments)
        return self.chassis_list[obj.chassis].sendQuery(index_command, True)
492467
def to(self, unit):
        """"""
        from astropy.units import au, d
        return (self.au_per_d * au / d).to(unit)