Skip to content

Commit 4b57fd6

Browse files
committed
Clean up; fix Spotbugs messages
1 parent 0c4b550 commit 4b57fd6

11 files changed

Lines changed: 185 additions & 43 deletions

File tree

symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/PatternMatching.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2995,7 +2995,7 @@ public static IExpr optionValueReplace(final IAST ast, boolean quiet, EvalEngine
29952995
}
29962996
if (!quiet) {
29972997
// Option name `2` not found in defaults for `1`
2998-
Errors.printMessage(ast.topHead(), "optnf", F.list(optionsPattern, optionValue), engine);
2998+
Errors.printMessage(ast.topHead(), "optnf", F.list(arg1, optionValue), engine);
29992999
}
30003000
return optionValue;
30013001
}
@@ -3039,7 +3039,7 @@ public static IExpr optionValueReplace(final IAST ast, boolean quiet, EvalEngine
30393039
}
30403040
if (!quiet) {
30413041
// Option name `2` not found in defaults for `1`
3042-
Errors.printMessage(ast.topHead(), "optnf", F.list(optionsPattern, optionValue), engine);
3042+
Errors.printMessage(ast.topHead(), "optnf", F.list(arg1, optionValue), engine);
30433043
}
30443044
return optionValue;
30453045
}
@@ -3071,7 +3071,7 @@ public static IExpr optionValueReplace(final IAST ast, boolean quiet, EvalEngine
30713071
if (optionsPattern != null) {
30723072
if (!quiet) {
30733073
// Option name `2` not found in defaults for `1`
3074-
Errors.printMessage(ast.topHead(), "optnf", F.list(optionsPattern, optionValue), engine);
3074+
Errors.printMessage(ast.topHead(), "optnf", F.list(arg1, optionValue), engine);
30753075
}
30763076
return optionValue;
30773077
}

symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/SeriesFunctions.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.matheclipse.core.eval.util.OptionArgs;
2323
import org.matheclipse.core.expression.ASTSeriesData;
2424
import org.matheclipse.core.expression.F;
25+
import org.matheclipse.core.expression.ImplementationStatus;
2526
import org.matheclipse.core.expression.S;
2627
import org.matheclipse.core.interfaces.IAST;
2728
import org.matheclipse.core.interfaces.IASTAppendable;
@@ -1313,6 +1314,11 @@ public int[] expectedArgSize(IAST ast) {
13131314
return ARGS_2_2;
13141315
}
13151316

1317+
@Override
1318+
public int status() {
1319+
return ImplementationStatus.PARTIAL_SUPPORT;
1320+
}
1321+
13161322
@Override
13171323
public void setUp(final ISymbol newSymbol) {
13181324
newSymbol.setAttributes(ISymbol.NHOLDALL);
@@ -1374,6 +1380,11 @@ private Function<IExpr, IExpr> normal(final IAST heads) {
13741380
public int[] expectedArgSize(IAST ast) {
13751381
return ARGS_1_2;
13761382
}
1383+
1384+
@Override
1385+
public int status() {
1386+
return ImplementationStatus.PARTIAL_SUPPORT;
1387+
}
13771388
}
13781389

13791390

@@ -1501,6 +1512,11 @@ private static IExpr taylorFunction(IExpr function, IExpr x, IExpr bf, int m, in
15011512
public int[] expectedArgSize(IAST ast) {
15021513
return ARGS_2_2;
15031514
}
1515+
1516+
@Override
1517+
public int status() {
1518+
return ImplementationStatus.EXPERIMENTAL;
1519+
}
15041520
}
15051521

15061522

@@ -1556,6 +1572,11 @@ public IExpr evaluate(final IAST ast, EvalEngine engine) {
15561572
}
15571573
return F.NIL;
15581574
}
1575+
1576+
@Override
1577+
public int status() {
1578+
return ImplementationStatus.PARTIAL_SUPPORT;
1579+
}
15591580
}
15601581

15611582

@@ -1593,6 +1614,11 @@ public IExpr evaluate(final IAST ast, EvalEngine engine) {
15931614
}
15941615
return F.NIL;
15951616
}
1617+
1618+
@Override
1619+
public int status() {
1620+
return ImplementationStatus.EXPERIMENTAL;
1621+
}
15961622
}
15971623

15981624

@@ -1648,6 +1674,15 @@ public IExpr evaluate(final IAST ast, EvalEngine engine) {
16481674
return F.NIL;
16491675
}
16501676

1677+
@Override
1678+
public int[] expectedArgSize(IAST ast) {
1679+
return ARGS_2_2;
1680+
}
1681+
1682+
@Override
1683+
public int status() {
1684+
return ImplementationStatus.PARTIAL_SUPPORT;
1685+
}
16511686
}
16521687

16531688

@@ -1932,6 +1967,16 @@ public static IExpr polynomialSeriesCoefficient(IExpr univariatePolynomial, IExp
19321967
return F.NIL;
19331968
}
19341969

1970+
@Override
1971+
public int[] expectedArgSize(IAST ast) {
1972+
return ARGS_2_2;
1973+
}
1974+
1975+
@Override
1976+
public int status() {
1977+
return ImplementationStatus.PARTIAL_SUPPORT;
1978+
}
1979+
19351980
@Override
19361981
public void setUp(final ISymbol newSymbol) {
19371982
MATCHER1 = Suppliers.memoize(SeriesCoefficientRules::init1);
@@ -2000,6 +2045,10 @@ public IExpr evaluate(final IAST ast, EvalEngine engine) {
20002045
return F.NIL;
20012046
}
20022047

2048+
@Override
2049+
public int status() {
2050+
return ImplementationStatus.PARTIAL_SUPPORT;
2051+
}
20032052
}
20042053

20052054

symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/SimplifyFunctions.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.matheclipse.core.eval.util.OptionArgs;
1919
import org.matheclipse.core.expression.F;
2020
import org.matheclipse.core.expression.ID;
21+
import org.matheclipse.core.expression.ImplementationStatus;
2122
import org.matheclipse.core.expression.S;
2223
import org.matheclipse.core.interfaces.IAST;
2324
import org.matheclipse.core.interfaces.IASTAppendable;
@@ -1513,6 +1514,11 @@ public IExpr evaluate(final IAST ast, EvalEngine engine) {
15131514
return F.NIL;
15141515
}
15151516

1517+
@Override
1518+
public int status() {
1519+
return ImplementationStatus.PARTIAL_SUPPORT;
1520+
}
1521+
15161522
@Override
15171523
public int[] expectedArgSize(IAST ast) {
15181524
return ARGS_1_INFINITY;
@@ -1591,6 +1597,11 @@ public boolean isFullSimplifyMode() {
15911597
return true;
15921598
}
15931599

1600+
@Override
1601+
public int status() {
1602+
return ImplementationStatus.PARTIAL_SUPPORT;
1603+
}
1604+
15941605
@Override
15951606
public void setUp(final ISymbol newSymbol) {
15961607
setOptions(newSymbol, //

symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/SourceCodeFunctions.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ public IExpr evaluate(final IAST ast, EvalEngine engine) {
8181
return F.NIL;
8282
}
8383

84+
@Override
85+
public int status() {
86+
return ImplementationStatus.EXPERIMENTAL;
87+
}
88+
8489
@Override
8590
public int[] expectedArgSize(IAST ast) {
8691
return ARGS_1_1;

symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/StructureFunctions.java

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,10 @@ private static class Apply extends AbstractFunctionOptionEvaluator {
197197
@Override
198198
public IExpr evaluate(final IAST ast, final int argSize, final IExpr[] option,
199199
final EvalEngine engine, IAST originalAST) {
200-
return apply(ast, argSize, option, engine);
200+
return applyInternal(ast, argSize, option, engine);
201201
}
202202

203-
public static IExpr apply(IAST ast, int argSize, IExpr[] option, EvalEngine engine) {
203+
public static IExpr applyInternal(IAST ast, int argSize, IExpr[] option, EvalEngine engine) {
204204
if (argSize < 2 || argSize > 4) {
205205
return Errors.printArgMessage(ast, ARGS_2_4, engine);
206206
}
@@ -228,45 +228,40 @@ public static IExpr apply(IAST ast, int argSize, IExpr[] option, EvalEngine engi
228228
if (arg1.isQuantity() || arg2.isQuantity()) {
229229
return F.NIL;
230230
}
231-
return evalApply(arg1, arg2, evaledAST, lastIndex, heads, engine);
231+
IExpr level = F.C0;
232+
if (lastIndex == 3) {
233+
level = evaledAST.get(3);
234+
}
235+
return evalApply(arg1, arg2, level, lastIndex, heads, engine);
232236
}
233237

234238
@Override
235239
public int[] expectedArgSize(IAST ast) {
236240
return ARGS_1_4_2;
237241
}
238242

239-
public static IExpr evalApply(IExpr f, IExpr expr, IAST evaledAST, int lastIndex, boolean heads,
240-
EvalEngine engine) {
243+
public static IExpr evalApply(IExpr f, IExpr expr, IExpr levelExpr, int lastIndex,
244+
boolean heads, EvalEngine engine) {
241245

242246
java.util.function.Function<IExpr, IExpr> af =
243247
x -> x.isAST() ? ((IAST) x).setAtCopy(0, f) : F.NIL;
244248
try {
245249
VisitorLevelSpecification level = null;
246250
if (lastIndex == 3) {
247-
level = new VisitorLevelSpecification(af, evaledAST.get(lastIndex), heads, engine);
251+
level = new VisitorLevelSpecification(af, levelExpr, heads, engine);
248252
} else {
249253
level = new VisitorLevelSpecification(af, 0);
250254
}
251255

252-
if (expr.isAST()) {
253-
return ((IAST) expr).acceptChecked(level).orElse(expr);
254-
} else {
255-
// arg2 is an Atom to which the head f couldn't be applied
256-
if (evaledAST.size() >= 3) {
257-
if (f.isFunction()) {
258-
return F.unaryAST1(f, expr);
259-
}
260-
return expr;
261-
}
262-
}
256+
return apply(f, expr, level);
263257
} catch (final ValidateException ve) {
264258
// see level specification
265259
return Errors.printMessage(S.Apply, ve, engine);
266260
}
267-
return F.NIL;
261+
// return F.NIL;
268262
}
269263

264+
270265
@Override
271266
public void setUp(final ISymbol newSymbol) {
272267
setOptions(newSymbol, S.Heads, S.False);
@@ -2428,6 +2423,20 @@ public static IAST threadListLogicEquationOperators(IExpr expr, IAST replacement
24282423
return F.NIL;
24292424
}
24302425

2426+
public static IExpr apply(IExpr f, IExpr expr, VisitorLevelSpecification level) {
2427+
if (expr.isAST()) {
2428+
return ((IAST) expr).acceptChecked(level).orElse(expr);
2429+
} // else {
2430+
// arg2 is an Atom to which the head f couldn't be applied
2431+
// if (evaledAST.size() >= 3) {
2432+
if (f.isFunction()) {
2433+
return F.unaryAST1(f, expr);
2434+
}
2435+
return expr;
2436+
// }
2437+
// }
2438+
}
2439+
24312440
public static AbstractVisitorLong leafCountVisitor() {
24322441
return new LeafCount.LeafCountVisitor(0);
24332442
}

symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/UnitTestingFunctions.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.matheclipse.core.eval.interfaces.AbstractEvaluator;
2121
import org.matheclipse.core.eval.util.OptionArgs;
2222
import org.matheclipse.core.expression.F;
23+
import org.matheclipse.core.expression.ImplementationStatus;
2324
import org.matheclipse.core.expression.S;
2425
import org.matheclipse.core.expression.data.TestReportObjectExpr;
2526
import org.matheclipse.core.expression.data.TestResultObjectExpr;
@@ -166,6 +167,11 @@ public static IAssociation evaluatePackage(final List<ASTNode> node, final EvalE
166167
return assoc;
167168
}
168169

170+
@Override
171+
public int status() {
172+
return ImplementationStatus.PARTIAL_SUPPORT;
173+
}
174+
169175
@Override
170176
public int[] expectedArgSize(IAST ast) {
171177
return ARGS_1_1;
@@ -265,6 +271,11 @@ private static void success(IAssociation assoc) {
265271
LOGGER.debug(" - Success");
266272
}
267273

274+
@Override
275+
public int status() {
276+
return ImplementationStatus.PARTIAL_SUPPORT;
277+
}
278+
268279
@Override
269280
public int[] expectedArgSize(IAST ast) {
270281
return ARGS_1_4;

symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/WL.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.Closeable;
55
import java.io.IOException;
66
import java.io.InputStream;
7+
import java.io.UnsupportedEncodingException;
78
import java.math.BigInteger;
89
import java.nio.ByteBuffer;
910
import java.nio.ByteOrder;
@@ -864,6 +865,8 @@ private void writeNumericArrayData(byte arrayType, NumericArrayExpr numericArray
864865
writeDouble(doubleArr[i++]);
865866
}
866867
}
868+
default:
869+
throw new UnsupportedEncodingException();
867870
}
868871
}
869872

symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/reflection/system/FrobeniusSolve.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.matheclipse.core.reflection.system;
22

33
import org.matheclipse.core.basic.Config;
4-
import org.matheclipse.core.basic.OperationSystem;
54
import org.matheclipse.core.eval.Errors;
65
import org.matheclipse.core.eval.EvalEngine;
76
import org.matheclipse.core.eval.exception.ASTElementLimitExceeded;

symja_android_library/matheclipse-core/src/test/java/org/matheclipse/core/system/DistributionTest.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -158,22 +158,6 @@ public void testCDF() {
158158
"3/5");
159159
}
160160

161-
@Test
162-
public void testCentralMoment() {
163-
check("CentralMoment({1.1, 1.2, 1.4, 2.1, 2.4}, 4)", //
164-
"0.100845");
165-
check("CentralMoment(BernoulliDistribution(n),m)", //
166-
"Piecewise({{1,m==0},{((1-n)^(-1+m)-1/(-n)^(1-m))*(1-n)*n,m>0}},0)");
167-
check("CentralMoment(ChiSquareDistribution(n),m)", //
168-
"2^m*HypergeometricU(-m,1-m-n/2,-n/2)");
169-
check("CentralMoment(ExponentialDistribution(n),m)", //
170-
"Subfactorial(m)/n^m");
171-
check("CentralMoment(GammaDistribution(a,b),2)", //
172-
"a*b^2");
173-
check("CentralMoment(NormalDistribution(a,b),m)", //
174-
"Piecewise({{b^m*(-1+m)!!,Mod(m,2)==0&&m>=0}},0)");
175-
}
176-
177161
@Test
178162
public void testChiSquareDistribution() {
179163
check("StandardDeviation(ChiSquareDistribution(v))", //

0 commit comments

Comments
 (0)