Determine if two doubles are equal within a default tolerance
436888
static private boolean PE_EQ(double a, double b) {
		return (a == b)
				|| PE_ABS(a - b) <= PE_EPS * (1 + (PE_ABS(a) + PE_ABS(b)) / 2);
	}
516376
def _at_least_x_are_true(a, b, x):
  """"""
  match = tf.equal(a, b)
  match = tf.cast(match, tf.int32)
  return tf.greater_equal(tf.reduce_sum(match), x)
863714
public static function isEqual($value1, $value2, $roundPrecision = 0)
    {
        $equal = false;

        if (static::floor($value1, $roundPrecision) == static::floor($value2, $roundPrecision)) {
            $equal = true;
        }

        return $equal;
    }
1283163
public double getDouble(String key, double defaultValue) {
		addToDefaults(key, Double.toString(defaultValue));
		String value = get(key);
		if (value == null) {
			return defaultValue;
		} else {
			return Double.valueOf(value);
		}
	}
1321981
private static boolean polylineEqualsEnvelope_(Polyline polyline_a,
			Envelope envelope_b, double tolerance,
			ProgressTracker progress_tracker) {
		Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D();
		polyline_a.queryEnvelope2D(env_a);
		envelope_b.queryEnvelope2D(env_b);

		if (env_b.getHeight() > tolerance && env_b.getWidth() > tolerance)
			return false; // area cannot equal a line

		return envelopeEqualsEnvelope_(env_a, env_b, tolerance,
				progress_tracker);
	}
1237686
public static boolean isCloseToIntegral(final double value, final double tolerance) {
    return Math.abs(value - Math.round(value)) <= tolerance;
  }
983980
def _float_almost_equal(float1, float2, places=7):
    

    if round(abs(float2 - float1), places) == 0:
        return True

    return False
643343
private static double computeCosineSimilarity(
        DoubleTuple t0, DoubleTuple t1)
    {
        Utils.checkForEqualSize(t0, t1);
        double dot = DoubleTuples.dot(t0, t1);
        final double epsilon = 1e-10;
        if (Math.abs(dot) < epsilon)
        {
            return 0;
        }
        double tt0 = DoubleTuples.computeL2(t0);
        double tt1 = DoubleTuples.computeL2(t1);
        double tt = tt0 * tt1;
        double result = clamp(dot / tt, -1.0, 1.0);
        return result;
    }
1099777
private static boolean multiPointExactlyEqualsMultiPoint_(
			MultiPoint multipoint_a, MultiPoint multipoint_b, double tolerance,
			ProgressTracker progress_tracker) {
		if (multipoint_a.getPointCount() != multipoint_b.getPointCount())
			return false;

		Point2D ptA = new Point2D(), ptB = new Point2D();
		boolean bAllPointsEqual = true;
		double tolerance_sq = tolerance * tolerance;

		for (int i = 0; i < multipoint_a.getPointCount(); i++) {
			multipoint_a.getXY(i, ptA);
			multipoint_b.getXY(i, ptB);

			if (Point2D.sqrDistance(ptA, ptB) > tolerance_sq) {
				bAllPointsEqual = false;
				break;
			}
		}

		if (!bAllPointsEqual)
			return false;

		return true;
	}
1026832
def _check_convergence(self, F):
        
        normF = linalg.norm(F, Inf)

        if normF < self.tolerance:
            converged = True
        else:
            converged = False
            if self.verbose:
                logger.info("Difference: %.3f" % (normF - self.tolerance))

        return converged
1031350
def doublec(self, j):
        
        if j < 1 or self.b[j] != self.b[j-1]:
            return False
        return self.cons(j)
251239
private static boolean betweenLongitudes(double topLeftLon, double bottomRightLon, double lon) {
        if (topLeftLon <= bottomRightLon)
            return lon >= topLeftLon && lon <= bottomRightLon;
        else
            return lon >= topLeftLon || lon <= bottomRightLon;
    }
886794
def validate_regular_sampling(values, rtol=10e-6):
    
    diffs = np.diff(values)
    return (len(diffs) < 1) or abs(diffs.min()-diffs.max()) < abs(diffs.min()*rtol)
3142
function iszero(x, tolerance) {
    if (tolerance === void 0) { tolerance = constants_1.EPSILON; }
    // the 'less-than-equal' comparision is necessary for correct result
    // when tolerance = 0
    return Math.abs(x) <= tolerance;
}
870502
def _equals(v1_indices, v1_values, v2_indices, v2_values):
        
        v1_size = len(v1_values)
        v2_size = len(v2_values)
        k1 = 0
        k2 = 0
        all_equal = True
        while all_equal:
            while k1 < v1_size and v1_values[k1] == 0:
                k1 += 1
            while k2 < v2_size and v2_values[k2] == 0:
                k2 += 1

            if k1 >= v1_size or k2 >= v2_size:
                return k1 >= v1_size and k2 >= v2_size

            all_equal = v1_indices[k1] == v2_indices[k2] and v1_values[k1] == v2_values[k2]
            k1 += 1
            k2 += 1
        return all_equal
919551
function(b1, b2) {
  var mismatch = 0;
  mismatch |= !(b1 instanceof Buffer);
  mismatch |= !(b2 instanceof Buffer);
  mismatch |= b1.length !== b2.length;
  if (mismatch === 1) {
    return false;
  }
  var n = b1.length;
  for (var i = 0; i < n; i++) {
    mismatch |= b1[i] ^ b2[i];
  }
  return mismatch === 0;
}
829928
@Override
	public boolean isOverlapping(ConstantRange r) {
		if (!(r instanceof DoubleConstantRange))
			throw new IllegalArgumentException();
		if (!isValid() || !r.isValid())
			return false;
		DoubleConstantRange dr = (DoubleConstantRange) r;
		DoubleConstant rh = dr.high;
		boolean rhi = dr.highIncl;
		if (!low.equals(NEG_INF)
				&& ((lowIncl && ((rhi && rh.compareTo(low) < 0) || (!rhi && rh
						.compareTo(low) <= 0))) || (!lowIncl && rh
						.compareTo(low) <= 0)))
			return false;
		DoubleConstant rl = dr.low;
		boolean rli = dr.lowIncl;
		if (!high.equals(INF)
				&& ((highIncl && ((rli && rl.compareTo(high) > 0) || (!rli && rl
						.compareTo(high) >= 0))) || (!highIncl && rl
						.compareTo(high) >= 0)))
			return false;
		return true;
	}