//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: protected void assertInputs(final Minimizer<java.util.function.Function<com.opengamma.strata.collect.array.DoubleArray, double>, com.opengamma.strata.collect.array.DoubleArray> minimizer)
        protected internal virtual void assertInputs(Minimizer <System.Func <DoubleArray, double>, DoubleArray> minimizer)
        {
            try
            {
                minimizer.minimize(null, DoubleArray.of(2d, 3d));
                Assert.fail();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (legalArgumentException)
            {
                // Expected
            }
            try
            {
                minimizer.minimize(F_2D, null);
                Assert.fail();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (legalArgumentException)
            {
                // Expected
            }
        }
예제 #2
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: protected void assertInverseCDF(final double[] x, final ProbabilityDistribution<double> dist)
        protected internal virtual void assertInverseCDF(double[] x, ProbabilityDistribution <double> dist)
        {
            assertInverseCDFWithNull(dist);
            foreach (double d in x)
            {
                assertEquals(dist.getInverseCDF(dist.getCDF(d)), d, EPS);
            }
            try
            {
                dist.getInverseCDF(3.4);
                Assert.fail();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (legalArgumentException)
            {
                // Expected
            }
            try
            {
                dist.getInverseCDF(-0.2);
                Assert.fail();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (legalArgumentException)
            {
                // Expected
            }
        }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: private void assertLimit(final ProbabilityDistribution<double> dist, final double limit)
        private void assertLimit(ProbabilityDistribution <double> dist, double limit)
        {
            try
            {
                dist.getCDF(limit);
                Assert.fail();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (legalArgumentException)
            {
                // Expected
            }
            try
            {
                dist.getPDF(limit);
                Assert.fail();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (legalArgumentException)
            {
                // Expected
            }
        }
 private void assertNull(System.Func <double[], double> calculator)
 {
     try
     {
         calculator(null);
         Assert.fail();
     }
     catch (System.ArgumentException)
     {
         // Expected
     }
 }
 private void assertEmpty(System.Func <double[], double> calculator)
 {
     double[] x = new double[0];
     try
     {
         calculator(x);
         Assert.fail();
     }
     catch (System.ArgumentException)
     {
         // Expected
     }
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMode()
        public virtual void testMode()
        {
            double[] x = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 };
            try
            {
                MODE.apply(x);
                Assert.fail();
            }
            catch (MathException)
            {
                // Expected
            }
            assertEquals(MODE.apply(DATA), 5.7, EPS);
        }
예제 #7
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: protected void assertInverseCDFWithNull(final ProbabilityDistribution<double> dist)
        protected internal virtual void assertInverseCDFWithNull(ProbabilityDistribution <double> dist)
        {
            try
            {
                dist.getInverseCDF(null);
                Assert.fail();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (legalArgumentException)
            {
                // Expected
            }
        }
예제 #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void test()
        public virtual void test()
        {
            try
            {
                FINDER.getRoots(null);
                Assert.fail();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (legalArgumentException)
            {
                // Expected
            }
            try
            {
                FINDER.getRoots(new RealPolynomialFunction1D(1.0, 2.0, 3.0, 4.0));
                Assert.fail();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (legalArgumentException)
            {
                // Expected
            }
            try
            {
                FINDER.getRoots(new RealPolynomialFunction1D(12.0, 1.0, 12.0));
                Assert.fail();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final com.opengamma.strata.math.MathException e)
            catch (m.opengamma.strata.math.MathException)
            {
                // Expected
            }
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final System.Nullable<double>[] roots = FINDER.getRoots(F);
            double?[] roots = FINDER.getRoots(F);
            assertEquals(roots[0], -4.0, EPS);
            assertEquals(roots[1], -3.0, EPS);
        }
예제 #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void test()
        public virtual void test()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LeastSquaresRegression regression = new OrdinaryLeastSquaresRegression();
            LeastSquaresRegression regression = new OrdinaryLeastSquaresRegression();

            try
            {
                regression.checkData(null, null);
                Assert.fail();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (legalArgumentException)
            {
                // Expected
            }
            double[][] x = new double[0][];
            try
            {
                regression.checkData(x, null);
                Assert.fail();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (legalArgumentException)
            {
                // Expected
            }
            double[] y = new double[0];
            try
            {
                regression.checkData(x, (double[])null, y);
                Assert.fail();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (legalArgumentException)
            {
                // Expected
            }
//JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java:
//ORIGINAL LINE: x = new double[1][2];
            x = RectangularArrays.ReturnRectangularDoubleArray(1, 2);
            y = new double[3];
            try
            {
                regression.checkData(x, (double[])null, y);
                Assert.fail();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (legalArgumentException)
            {
                // Expected
            }
            x = new double[][]
            {
                new double[] { 1.0, 2.0, 3.0 },
                new double[] { 4.0, 5.0 },
                new double[] { 6.0, 7.0, 8.0 },
                new double[] { 9.0, 0.0, 0.0 }
            };
            try
            {
                regression.checkData(x, (double[])null, y);
                Assert.fail();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (legalArgumentException)
            {
                // Expected
            }
            x[1] = new double[] { 4.0, 5.0, 6.0 };
            try
            {
                regression.checkData(x, (double[])null, y);
                Assert.fail();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (legalArgumentException)
            {
                // Expected
            }
            y = new double[] { 1.0, 2.0, 3.0, 4.0 };
            double[] w1 = new double[0];
            try
            {
                regression.checkData(x, w1, y);
                Assert.fail();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (legalArgumentException)
            {
                // Expected
            }
            double[][] w = new double[0][];
            try
            {
                regression.checkData(x, w, y);
                Assert.fail();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (legalArgumentException)
            {
                // Expected
            }
            w1 = new double[3];
            try
            {
                regression.checkData(x, w1, y);
                Assert.fail();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (legalArgumentException)
            {
                // Expected
            }
//JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java:
//ORIGINAL LINE: w = new double[3][0];
            w = RectangularArrays.ReturnRectangularDoubleArray(3, 0);
            try
            {
                regression.checkData(x, w, y);
                Assert.fail();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (legalArgumentException)
            {
                // Expected
            }
            w = new double[][]
            {
                new double[] { 1.0, 2.0, 3.0 },
                new double[] { 4.0, 5.0 },
                new double[] { 6.0, 7.0, 8.0 },
                new double[] { 9.0, 0.0, 0.0 }
            };
            try
            {
                regression.checkData(x, w, y);
                Assert.fail();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalArgumentException e)
            catch (legalArgumentException)
            {
                // Expected
            }
        }