Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,12 @@ void testGetMinPts() {

@Test
void testNegativeEps() {
assertThrows(MathIllegalArgumentException.class, () -> {
new DBSCANClusterer<DoublePoint>(-2.0, 5);
});
assertThrows(MathIllegalArgumentException.class, () -> new DBSCANClusterer<DoublePoint>(-2.0, 5));
}

@Test
void testNegativeMinPts() {
assertThrows(MathIllegalArgumentException.class, () -> {
new DBSCANClusterer<DoublePoint>(2.0, -5);
});
assertThrows(MathIllegalArgumentException.class, () -> new DBSCANClusterer<DoublePoint>(2.0, -5));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ void testCluster() {

@Test
void testTooSmallFuzzynessFactor() {
assertThrows(MathIllegalArgumentException.class, () -> {
new FuzzyKMeansClusterer<DoublePoint>(3, 1.0);
});
assertThrows(MathIllegalArgumentException.class, () -> new FuzzyKMeansClusterer<DoublePoint>(3, 1.0));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ public void testSign() {

@Test
public void testLinearCombinationReference() {
doTestLinearCombinationReference(x -> build(x), 5.0e-16, 1.0);
doTestLinearCombinationReference(this::build, 5.0e-16, 1.0);
}

protected void doTestLinearCombinationReference(final DoubleFunction<T> builder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,7 @@ public static Object serializeAndRecover(Object o) {
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream si = new ObjectInputStream(bis);
return si.readObject();
} catch (IOException ioe) {
return null;
} catch (ClassNotFoundException cnfe) {
} catch (IOException | ClassNotFoundException ioe) {
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public <T extends CalculusFieldElement<T>> T value(T x) {
}
};
CalculusFieldUnivariateFunction<Binary64> f1Converted = f1.toCalculusFieldUnivariateFunction(Binary64Field.getInstance());
CalculusFieldUnivariateFunction<Binary64> f2 = x -> x.twice();
CalculusFieldUnivariateFunction<Binary64> f2 = CalculusFieldElement::twice;

for (double x = 0; x < 1; x += 0.01) {
assertEquals(f2.value(new Binary64(x)).getReal(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,23 +226,17 @@ void testFixingArguments() {

@Test
void testSampleWrongBounds(){
assertThrows(MathIllegalArgumentException.class, () -> {
FunctionUtils.sample(new Sin(), FastMath.PI, 0.0, 10);
});
assertThrows(MathIllegalArgumentException.class, () -> FunctionUtils.sample(new Sin(), FastMath.PI, 0.0, 10));
}

@Test
void testSampleNegativeNumberOfPoints(){
assertThrows(MathIllegalArgumentException.class, () -> {
FunctionUtils.sample(new Sin(), 0.0, FastMath.PI, -1);
});
assertThrows(MathIllegalArgumentException.class, () -> FunctionUtils.sample(new Sin(), 0.0, FastMath.PI, -1));
}

@Test
void testSampleNullNumberOfPoints(){
assertThrows(MathIllegalArgumentException.class, () -> {
FunctionUtils.sample(new Sin(), 0.0, FastMath.PI, 0);
});
assertThrows(MathIllegalArgumentException.class, () -> FunctionUtils.sample(new Sin(), 0.0, FastMath.PI, 0));
}

@Test
Expand All @@ -260,24 +254,9 @@ void testSample() {
@Test
void testToDifferentiableUnivariate() {

final UnivariateFunction f0 = new UnivariateFunction() {
@Override
public double value(final double x) {
return x * x;
}
};
final UnivariateFunction f1 = new UnivariateFunction() {
@Override
public double value(final double x) {
return 2 * x;
}
};
final UnivariateFunction f2 = new UnivariateFunction() {
@Override
public double value(final double x) {
return 2;
}
};
final UnivariateFunction f0 = x -> x * x;
final UnivariateFunction f1 = x -> 2 * x;
final UnivariateFunction f2 = x -> 2;
final UnivariateDifferentiableFunction f = FunctionUtils.toDifferentiable(f0, f1, f2);

DSFactory factory = new DSFactory(1, 2);
Expand Down Expand Up @@ -306,18 +285,8 @@ void testToDifferentiableMultivariate() {

final double a = 1.5;
final double b = 0.5;
final MultivariateFunction f = new MultivariateFunction() {
@Override
public double value(final double[] point) {
return a * point[0] + b * point[1];
}
};
final MultivariateVectorFunction gradient = new MultivariateVectorFunction() {
@Override
public double[] value(final double[] point) {
return new double[] { a, b };
}
};
final MultivariateFunction f = point -> a * point[0] + b * point[1];
final MultivariateVectorFunction gradient = point -> new double[] { a, b };
final MultivariateDifferentiableFunction mdf = FunctionUtils.toDifferentiable(f, gradient);

DSFactory factory11 = new DSFactory(1, 1);
Expand Down Expand Up @@ -358,18 +327,8 @@ void testToDifferentiableMultivariateInconsistentGradient() {

final double a = 1.5;
final double b = 0.5;
final MultivariateFunction f = new MultivariateFunction() {
@Override
public double value(final double[] point) {
return a * point[0] + b * point[1];
}
};
final MultivariateVectorFunction gradient = new MultivariateVectorFunction() {
@Override
public double[] value(final double[] point) {
return new double[] { a, b, 0.0 };
}
};
final MultivariateFunction f = point -> a * point[0] + b * point[1];
final MultivariateVectorFunction gradient = point -> new double[] { a, b, 0.0 };
final MultivariateDifferentiableFunction mdf = FunctionUtils.toDifferentiable(f, gradient);

DSFactory factory = new DSFactory(1, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,12 @@ void testIndices() {

@Test
void testIncompatibleParams() {
assertThrows(MathIllegalArgumentException.class, () -> {
DSCompiler.getCompiler(3, 2).checkCompatibility(DSCompiler.getCompiler(4, 2));
});
assertThrows(MathIllegalArgumentException.class, () -> DSCompiler.getCompiler(3, 2).checkCompatibility(DSCompiler.getCompiler(4, 2)));
}

@Test
void testIncompatibleOrder() {
assertThrows(MathIllegalArgumentException.class, () -> {
DSCompiler.getCompiler(3, 3).checkCompatibility(DSCompiler.getCompiler(3, 2));
});
assertThrows(MathIllegalArgumentException.class, () -> DSCompiler.getCompiler(3, 3).checkCompatibility(DSCompiler.getCompiler(3, 2)));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,17 @@ protected DerivativeStructure build(final double x) {

@Test
void testWrongVariableIndex() {
assertThrows(MathIllegalArgumentException.class, () -> {
new DSFactory(3, 1).variable(3, 1.0);
});
assertThrows(MathIllegalArgumentException.class, () -> new DSFactory(3, 1).variable(3, 1.0));
}

@Test
void testMissingOrders() {
assertThrows(MathIllegalArgumentException.class, () -> {
new DSFactory(3, 1).variable(0, 1.0).getPartialDerivative(0, 1);
});
assertThrows(MathIllegalArgumentException.class, () -> new DSFactory(3, 1).variable(0, 1.0).getPartialDerivative(0, 1));
}

@Test
void testTooLargeOrder() {
assertThrows(MathIllegalArgumentException.class, () -> {
new DSFactory(3, 1).variable(0, 1.0).getPartialDerivative(1, 1, 2);
});
assertThrows(MathIllegalArgumentException.class, () -> new DSFactory(3, 1).variable(0, 1.0).getPartialDerivative(1, 1, 2));
}

@Test
Expand Down Expand Up @@ -1518,9 +1512,7 @@ void testDegRad() {

@Test
void testComposeMismatchedDimensions() {
assertThrows(MathIllegalArgumentException.class, () -> {
new DSFactory(1, 3).variable(0, 1.2).compose(new double[3]);
});
assertThrows(MathIllegalArgumentException.class, () -> new DSFactory(1, 3).variable(0, 1.2).compose(new double[3]));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ protected FieldDerivativeStructure<T> build(final double x) {

@Test
public void testWrongFieldVariableIndex() {
assertThrows(MathIllegalArgumentException.class, () -> {
buildFactory(3, 1).variable(3, buildScalar(1.0));
});
assertThrows(MathIllegalArgumentException.class, () -> buildFactory(3, 1).variable(3, buildScalar(1.0)));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,7 @@ public void testHypotNoOverflow() {
@Override
@Test
public void testLinearCombinationReference() {
doTestLinearCombinationReference(x -> build(x), 4.8e-16, 1.0);
}

@Override
@Test
public void testLinearCombination1DSDS() {
doTestLinearCombination1DSDS(1.0e-15);
}

@Override
@Test
public void testLinearCombination1FieldDS() {
doTestLinearCombination1FieldDS(1.0e-15);
}

@Override
@Test
public void testLinearCombination1DoubleDS() {
doTestLinearCombination1DoubleDS(1.0e-15);
doTestLinearCombinationReference(this::build, 4.8e-16, 1.0);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void testHypotNoOverflow() {
@Override
@Test
public void testLinearCombinationReference() {
doTestLinearCombinationReference(x -> build(x), 4.15e-9, 4.21e-9);
doTestLinearCombinationReference(this::build, 4.15e-9, 4.21e-9);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ public void testHashcode() {
@Override
@Test
public void testLinearCombinationReference() {
doTestLinearCombinationReference(x -> build(x), 5.0e-16, 1.0);
doTestLinearCombinationReference(this::build, 5.0e-16, 1.0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void testHashcode() {
@Override
@Test
public void testLinearCombinationReference() {
doTestLinearCombinationReference(x -> build(x), 5.0e-9, 4.212e-9);
doTestLinearCombinationReference(this::build, 5.0e-9, 4.212e-9);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ void testHashcode() {
@Override
@Test
public void testLinearCombinationReference() {
doTestLinearCombinationReference(x -> build(x), 5.0e-9, 1.0);
doTestLinearCombinationReference(this::build, 5.0e-9, 1.0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void testHashcode() {
@Override
@Test
public void testLinearCombinationReference() {
doTestLinearCombinationReference(x -> build(x), 5.0e-9, 4.212e-9);
doTestLinearCombinationReference(this::build, 5.0e-9, 4.212e-9);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ public void testHashcode() {
@Override
@Test
public void testLinearCombinationReference() {
doTestLinearCombinationReference(x -> build(x), 5.0e-16, 1.0);
doTestLinearCombinationReference(this::build, 5.0e-16, 1.0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void testHashcode() {
@Override
@Test
public void testLinearCombinationReference() {
doTestLinearCombinationReference(x -> build(x), 5.0e-9, 4.212e-9);
doTestLinearCombinationReference(this::build, 5.0e-9, 4.212e-9);
}

@Override
Expand Down
Loading