A way of getting the weight of an edge with or without weight as a parameter
    returns a the value of the weight parameter converted to returnType if it is given or 1 (also converted) if not
8828
def getWeight(grph, nd1, nd2, weightString = "weight", returnType = int):
    
    if not weightString:
        return returnType(1)
    else:
        return returnType(grph.edges[nd1, nd2][weightString])
708551
def k_weights_int(self):
        
        nk = np.prod(self.k_mesh)
        _weights = self.k_weights * nk
        weights = np.rint(_weights).astype('intc')
        assert (np.abs(weights - _weights) < 1e-7 * nk).all()
        return np.array(weights, dtype='intc')
582837
@Override
  public double getWeight(double distance, double max, double stddev) {
    if(max <= 0) {
      return 1.0;
    }
    double relativedistance = distance / max;
    // the scaling was picked such that getWeight(a,a,0) is 0.1
    // since erfc(1.1630871536766736) == 1.0
    return NormalDistribution.erfc(1.1630871536766736 * relativedistance);
  }
705660
def blkio_weight_device(val, **kwargs):  # pylint: disable=unused-argument
    '''
    
    '''
    val = helpers.map_vals(val, 'Path', 'Weight')
    for idx in range(len(val)):
        try:
            val[idx]['Weight'] = int(val[idx]['Weight'])
        except (TypeError, ValueError):
            raise SaltInvocationError(
                'Weight \'{Weight}\' for path \'{Path}\' is not an '
                'integer'.format(**val[idx])
            )
    return val
876798
double getWeight(Token tok) {
		Double f = (Double)weightMap.get(tok);
		return f==null ? 0 : f.doubleValue();
	}
541443
@Override
    public double getMean() {
        if (values.length == 0) {
            return 0;
        }

        double sum = 0;
        for (int i = 0; i < values.length; i++) {
            sum += values[i] * normWeights[i];
        }
        return sum;
    }
1052125
def edge_weight(self, edge):
        
        return self.get_edge_properties( edge ).setdefault( self.WEIGHT_ATTRIBUTE_NAME, self.DEFAULT_WEIGHT )
590980
private static <T, ET> boolean hasNullValueEdges(DataSet<Edge<T, ET>> edges) {
		TypeInformation<?> genericTypeInfo = edges.getType();
		@SuppressWarnings("unchecked")
		TupleTypeInfo<Tuple3<T, T, ET>> tupleTypeInfo = (TupleTypeInfo<Tuple3<T, T, ET>>) genericTypeInfo;

		return tupleTypeInfo.getTypeAt(2).equals(ValueTypeInfo.NULL_VALUE_TYPE_INFO);
	}
159615
def getParameterByValue(self, value):
        """"""
        result = None
        for parameter in self.getParameters():
            valueParam = parameter.getValue()
            if valueParam == value:
                result = parameter
                break
        return result
329131
public double getWeight(int i)
    {
        if(i >= size() || i < 0)
            throw new IndexOutOfBoundsException("Dataset has only " + size() + " members, can't access index " + i );
        
        if(weights == null)
            return 1;
        else if(weights.length <= i)
            return 1;
        else return weights[i];
    }
1197469
@Override
  public double getWeight(double distance, double max, double stddev) {
    if(stddev <= 0) {
      return 1;
    }
    double scaleddistance = distance / stddev;
    return stddev * FastMath.exp(-.5 * scaleddistance);
  }
541799
def convert_float(value, parameter):
    '''
    
    '''
    value = _check_default(value, parameter, ( '', '-', None ))
    if value is None or isinstance(value, float):
        return value
    try:
        return float(value)
    except Exception as e:
        raise ValueError(str(e))
973110
@Override
  public GallicWeight plus(GallicWeight a, GallicWeight b) {
    if (isZero(a)) return b;
    if (isZero(b)) return a;
    if (mode == RESTRICT_GALLIC) {
      if (SHORTLEX_ORDERING.compare(a, b) != 0) {
        throw new IllegalArgumentException("Trying to plus two different gallic weights, which isn't allowed in " +
          "this context. Did you pass a non-functional FST where a functional one was required? a = " + a +
          "; b = " + b);
      }
      double newWeight = this.weightSemiring.plus(a.getWeight(), b.getWeight());
      return GallicWeight.create(new IntArrayList(a.getLabels()), newWeight);
    } else {
      Preconditions.checkState(mode == MIN_GALLIC);
      return this.weightSemiring.naturalLess(a.getWeight(), b.getWeight()) ? a : b;
    }
  }
304814
public static List<Double> getWeights(ZParams params) {
		Collection<byte[]> collect = params.getParams();
		Iterator<byte[]> iterator = collect.iterator();
		boolean hasWeights = false;
		while (iterator.hasNext()) {
			String value = new String(iterator.next());
			// System.out.println("value:" + value);
			if ("weights".equals(value)) {
				hasWeights = true;
				break;
			}
		}
		if (!hasWeights) {
			return null;
		}
		List<Double> result = new ArrayList<Double>();
		while (iterator.hasNext()) {
			String weight = new String(iterator.next());
			result.add(Double.parseDouble(weight));
		}
		return result;
	}
599966
public Weight invertSign() {
        if (isInfinity) {
            if (posOrNeg) {
                return WeightFactory.NEG_INFINITY;
            } else {
                return WeightFactory.POS_INFINITY;
            }
        }
        return new Weight(-val);
    }
925662
public Edge getIncomingEdgeWithType(BasicBlock basicBlock, @Type int edgeType) {
        return getEdgeWithType(incomingEdgeIterator(basicBlock), edgeType);
    }
921170
@Override
  public double getWeight(double distance, double max, double stddev) {
    if(stddev <= 0) {
      return 1;
    }
    double scaleddistance = distance / (scaling * stddev);
    // After this, the result would be negative.
    if(scaleddistance >= 1.0) {
      return 0.0;
    }
    return 1.0 - scaleddistance * scaleddistance;
  }