IGNITE-5688: Fix SparseDistributedMatrixTest::testCacheBehaviour crash. This 
closes #2272



Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d2fe4374
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d2fe4374
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d2fe4374

Branch: refs/heads/ignite-2.1
Commit: d2fe437426399e2cf36b00ce6f527731da88613e
Parents: 33ae472
Author: artemmalykh <amal...@gridgain.com>
Authored: Mon Jul 10 18:16:49 2017 +0300
Committer: artemmalykh <amal...@gridgain.com>
Committed: Mon Jul 10 18:22:49 2017 +0300

----------------------------------------------------------------------
 modules/ml/pom.xml                              |  3 +-
 .../main/java/org/apache/ignite/ml/Model.java   |  1 -
 .../ml/clustering/BaseKMeansClusterer.java      |  2 -
 .../apache/ignite/ml/clustering/Clusterer.java  |  3 +-
 .../clustering/KMeansDistributedClusterer.java  | 46 ++++++++++----------
 .../ml/clustering/KMeansLocalClusterer.java     | 11 +++--
 .../apache/ignite/ml/math/DistanceMeasure.java  |  1 -
 .../ignite/ml/math/EuclideanDistance.java       |  2 +-
 .../java/org/apache/ignite/ml/math/Matrix.java  |  2 -
 .../java/org/apache/ignite/ml/math/Tracer.java  |  1 -
 .../org/apache/ignite/ml/math/VectorUtils.java  |  4 +-
 .../math/exceptions/ConvergenceException.java   |  5 +--
 .../exceptions/MathIllegalStateException.java   |  4 +-
 .../ignite/ml/math/functions/Functions.java     |  8 +---
 .../apache/ignite/ml/math/impls/CacheUtils.java | 23 ++++++----
 .../ml/math/impls/matrix/AbstractMatrix.java    |  2 -
 .../impls/matrix/SparseDistributedMatrix.java   |  4 +-
 .../impls/storage/matrix/MapWrapperStorage.java |  7 ++-
 .../matrix/SparseDistributedMatrixStorage.java  |  7 ++-
 .../vector/SparseLocalOnHeapVectorStorage.java  |  8 ++--
 .../ml/math/impls/vector/MapWrapperVector.java  |  3 +-
 .../apache/ignite/ml/math/util/MatrixUtil.java  |  1 -
 .../ignite/ml/math/d3-matrix-template.html      |  2 +
 .../ignite/ml/math/d3-vector-template.html      |  2 +
 .../org/apache/ignite/ml/IgniteMLTestSuite.java |  4 +-
 .../ml/clustering/ClusteringTesetSuite.java     | 32 --------------
 .../ml/clustering/ClusteringTestSuite.java      | 32 ++++++++++++++
 .../KMeansDistributedClustererTest.java         | 28 ++++++++----
 .../ignite/ml/math/MathImplLocalTestSuite.java  |  1 -
 .../org/apache/ignite/ml/math/TracerTest.java   |  3 ++
 .../matrix/SparseDistributedMatrixTest.java     | 24 ++++++----
 .../OLSMultipleLinearRegressionTest.java        |  2 +-
 32 files changed, 144 insertions(+), 134 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/pom.xml
----------------------------------------------------------------------
diff --git a/modules/ml/pom.xml b/modules/ml/pom.xml
index 75ebf1b..d619719 100644
--- a/modules/ml/pom.xml
+++ b/modules/ml/pom.xml
@@ -19,7 +19,8 @@
 <!--
     POM file.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
     <modelVersion>4.0.0</modelVersion>
 
     <parent>

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/java/org/apache/ignite/ml/Model.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/Model.java 
b/modules/ml/src/main/java/org/apache/ignite/ml/Model.java
index e4d2117..4dc1aca 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/Model.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/Model.java
@@ -19,7 +19,6 @@ package org.apache.ignite.ml;
 
 import java.util.function.BiFunction;
 
-
 /** Basic interface for all models. */
 @FunctionalInterface
 public interface Model<T, V> {

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/java/org/apache/ignite/ml/clustering/BaseKMeansClusterer.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/main/java/org/apache/ignite/ml/clustering/BaseKMeansClusterer.java
 
b/modules/ml/src/main/java/org/apache/ignite/ml/clustering/BaseKMeansClusterer.java
index a6acb8e..570ea7e 100644
--- 
a/modules/ml/src/main/java/org/apache/ignite/ml/clustering/BaseKMeansClusterer.java
+++ 
b/modules/ml/src/main/java/org/apache/ignite/ml/clustering/BaseKMeansClusterer.java
@@ -18,14 +18,12 @@
 package org.apache.ignite.ml.clustering;
 
 import java.util.List;
-
 import org.apache.ignite.lang.IgniteBiTuple;
 import org.apache.ignite.ml.math.DistanceMeasure;
 import org.apache.ignite.ml.math.Matrix;
 import org.apache.ignite.ml.math.Vector;
 import org.apache.ignite.ml.math.exceptions.ConvergenceException;
 import org.apache.ignite.ml.math.exceptions.MathIllegalArgumentException;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
 
 /**
  * This class is partly based on the corresponding class from Apache Common 
Math lib.

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/java/org/apache/ignite/ml/clustering/Clusterer.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/main/java/org/apache/ignite/ml/clustering/Clusterer.java 
b/modules/ml/src/main/java/org/apache/ignite/ml/clustering/Clusterer.java
index f03dc95..204e28a 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/clustering/Clusterer.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/clustering/Clusterer.java
@@ -23,7 +23,8 @@ import org.apache.ignite.ml.Model;
  * Base interface for clusterers.
  */
 public interface Clusterer<P, M extends Model> {
-    /** Cluster given points set into k clusters.
+    /**
+     * Cluster given points set into k clusters.
      *
      * @param points Points set.
      * @param k Clusters count.

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/java/org/apache/ignite/ml/clustering/KMeansDistributedClusterer.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/main/java/org/apache/ignite/ml/clustering/KMeansDistributedClusterer.java
 
b/modules/ml/src/main/java/org/apache/ignite/ml/clustering/KMeansDistributedClusterer.java
index 09317d6..5f702d2 100644
--- 
a/modules/ml/src/main/java/org/apache/ignite/ml/clustering/KMeansDistributedClusterer.java
+++ 
b/modules/ml/src/main/java/org/apache/ignite/ml/clustering/KMeansDistributedClusterer.java
@@ -22,12 +22,13 @@ import java.util.List;
 import java.util.Map;
 import java.util.Random;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicLong;
 import java.util.stream.Collectors;
-
+import javax.cache.Cache;
 import org.apache.ignite.lang.IgniteBiTuple;
 import org.apache.ignite.lang.IgniteUuid;
-import org.apache.ignite.ml.math.*;
+import org.apache.ignite.ml.math.DistanceMeasure;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.VectorUtils;
 import org.apache.ignite.ml.math.exceptions.ConvergenceException;
 import org.apache.ignite.ml.math.exceptions.MathIllegalArgumentException;
 import org.apache.ignite.ml.math.functions.Functions;
@@ -39,9 +40,7 @@ import 
org.apache.ignite.ml.math.impls.storage.matrix.SparseDistributedMatrixSto
 import org.apache.ignite.ml.math.util.MapUtil;
 import org.apache.ignite.ml.math.util.MatrixUtil;
 
-import javax.cache.Cache;
-
-import static org.apache.ignite.ml.math.impls.CacheUtils.*;
+import static org.apache.ignite.ml.math.impls.CacheUtils.distributedFold;
 import static org.apache.ignite.ml.math.util.MatrixUtil.localCopyOf;
 
 /**
@@ -78,8 +77,8 @@ public class KMeansDistributedClusterer extends 
BaseKMeansClusterer<SparseDistri
 
     /** */
     @Override public KMeansModel cluster(SparseDistributedMatrix points, int 
k) throws
-            MathIllegalArgumentException, ConvergenceException {
-        SparseDistributedMatrix pointsCp = (SparseDistributedMatrix) 
points.like(points.rowSize(), points.columnSize());
+        MathIllegalArgumentException, ConvergenceException {
+        SparseDistributedMatrix pointsCp = 
(SparseDistributedMatrix)points.like(points.rowSize(), points.columnSize());
 
         // TODO: this copy is very ineffective, just for POC. Immutability of 
data should be guaranteed by other methods
         // such as logical locks for example.
@@ -174,7 +173,8 @@ public class KMeansDistributedClusterer extends 
BaseKMeansClusterer<SparseDistri
     }
 
     /** */
-    private List<Vector> getNewCenters(int k, ConcurrentHashMap<Integer, 
Double> costs, IgniteUuid uid, double sumCosts) {
+    private List<Vector> getNewCenters(int k, ConcurrentHashMap<Integer, 
Double> costs, IgniteUuid uid,
+        double sumCosts) {
         return distributedFold(SparseDistributedMatrixStorage.ML_CACHE_NAME,
             (IgniteBiFunction<Cache.Entry<IgniteBiTuple<Integer, IgniteUuid>, 
Map<Integer, Double>>,
                 List<Vector>,
@@ -253,25 +253,25 @@ public class KMeansDistributedClusterer extends 
BaseKMeansClusterer<SparseDistri
     /** */
     private SumsAndCounts getSumsAndCounts(Vector[] centers, int dim, 
IgniteUuid uid) {
         return 
CacheUtils.distributedFold(SparseDistributedMatrixStorage.ML_CACHE_NAME,
-                (IgniteBiFunction<Cache.Entry<IgniteBiTuple<Integer, 
IgniteUuid>, Map<Integer, Double>>, SumsAndCounts, SumsAndCounts>)(entry, 
counts) -> {
-                    Map<Integer, Double> vec = entry.getValue();
+            (IgniteBiFunction<Cache.Entry<IgniteBiTuple<Integer, IgniteUuid>, 
Map<Integer, Double>>, SumsAndCounts, SumsAndCounts>)(entry, counts) -> {
+                Map<Integer, Double> vec = entry.getValue();
 
-                    IgniteBiTuple<Integer, Double> closest = 
findClosest(centers, VectorUtils.fromMap(vec, false));
-                    int bestCenterIdx = closest.get1();
+                IgniteBiTuple<Integer, Double> closest = findClosest(centers, 
VectorUtils.fromMap(vec, false));
+                int bestCenterIdx = closest.get1();
 
-                    counts.totalCost += closest.get2();
-                    counts.sums.putIfAbsent(bestCenterIdx, 
VectorUtils.zeroes(dim));
+                counts.totalCost += closest.get2();
+                counts.sums.putIfAbsent(bestCenterIdx, 
VectorUtils.zeroes(dim));
 
-                    counts.sums.compute(bestCenterIdx,
-                            (IgniteBiFunction<Integer, Vector, Vector>)(ind, 
v) -> v.plus(VectorUtils.fromMap(vec, false)));
+                counts.sums.compute(bestCenterIdx,
+                    (IgniteBiFunction<Integer, Vector, Vector>)(ind, v) -> 
v.plus(VectorUtils.fromMap(vec, false)));
 
-                    counts.counts.merge(bestCenterIdx, 1,
-                            (IgniteBiFunction<Integer, Integer, Integer>)(i1, 
i2) -> i1 + i2);
+                counts.counts.merge(bestCenterIdx, 1,
+                    (IgniteBiFunction<Integer, Integer, Integer>)(i1, i2) -> 
i1 + i2);
 
-                    return counts;
-                },
-                key -> key.get2().equals(uid),
-                SumsAndCounts::merge, new SumsAndCounts()
+                return counts;
+            },
+            key -> key.get2().equals(uid),
+            SumsAndCounts::merge, new SumsAndCounts()
         );
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/java/org/apache/ignite/ml/clustering/KMeansLocalClusterer.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/main/java/org/apache/ignite/ml/clustering/KMeansLocalClusterer.java
 
b/modules/ml/src/main/java/org/apache/ignite/ml/clustering/KMeansLocalClusterer.java
index c98b818..9f2aefb 100644
--- 
a/modules/ml/src/main/java/org/apache/ignite/ml/clustering/KMeansLocalClusterer.java
+++ 
b/modules/ml/src/main/java/org/apache/ignite/ml/clustering/KMeansLocalClusterer.java
@@ -22,9 +22,11 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Random;
-
 import org.apache.ignite.internal.util.GridArgumentCheck;
-import org.apache.ignite.ml.math.*;
+import org.apache.ignite.ml.math.DistanceMeasure;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.VectorUtils;
 import org.apache.ignite.ml.math.exceptions.ConvergenceException;
 import org.apache.ignite.ml.math.exceptions.MathIllegalArgumentException;
 import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
@@ -97,7 +99,7 @@ public class KMeansLocalClusterer extends 
BaseKMeansClusterer<DenseLocalOnHeapMa
 
             for (int p = 0; p < points.rowSize(); p++)
                 costs.setX(p, 
Math.min(getDistanceMeasure().compute(localCopyOf(points.viewRow(p)), 
centers[i]),
-                        costs.get(p)));
+                    costs.get(p)));
         }
 
         int[] oldClosest = new int[points.rowSize()];
@@ -135,7 +137,8 @@ public class KMeansLocalClusterer extends 
BaseKMeansClusterer<DenseLocalOnHeapMa
                 if (counts[j] == 0.0) {
                     // Assign center to a random point
                     centers[j] = 
points.viewRow(rand.nextInt(points.rowSize()));
-                } else {
+                }
+                else {
                     sums[j] = sums[j].times(1.0 / counts[j]);
                     centers[j] = sums[j];
                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/java/org/apache/ignite/ml/math/DistanceMeasure.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/DistanceMeasure.java 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/DistanceMeasure.java
index 0fd74ac..09be0c3 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/DistanceMeasure.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/DistanceMeasure.java
@@ -17,7 +17,6 @@
 package org.apache.ignite.ml.math;
 
 import java.io.Externalizable;
-
 import org.apache.ignite.ml.math.exceptions.CardinalityException;
 
 /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/java/org/apache/ignite/ml/math/EuclideanDistance.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/EuclideanDistance.java 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/EuclideanDistance.java
index b748ac5..5f962ce 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/EuclideanDistance.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/EuclideanDistance.java
@@ -32,7 +32,7 @@ public class EuclideanDistance implements DistanceMeasure {
     /** {@inheritDoc} */
     @Override
     public double compute(Vector a, Vector b)
-    throws CardinalityException {
+        throws CardinalityException {
         return MatrixUtil.localCopyOf(a).minus(b).kNorm(2.0);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
index db822e6..2cf4e63 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
@@ -18,8 +18,6 @@
 package org.apache.ignite.ml.math;
 
 import java.io.Externalizable;
-import java.util.function.BiFunction;
-import java.util.function.BinaryOperator;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.ml.math.exceptions.CardinalityException;
 import org.apache.ignite.ml.math.exceptions.IndexException;

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java
index d343ce8..1928f46 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java
@@ -32,7 +32,6 @@ import java.nio.file.StandardOpenOption;
 import java.util.Locale;
 import java.util.function.Function;
 import java.util.stream.Collectors;
-
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.lang.IgniteUuid;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/java/org/apache/ignite/ml/math/VectorUtils.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/VectorUtils.java 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/VectorUtils.java
index f41a5fe..061d5ae 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/VectorUtils.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/VectorUtils.java
@@ -18,10 +18,8 @@
 package org.apache.ignite.ml.math;
 
 import java.util.Map;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
 import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
 import org.apache.ignite.ml.math.impls.vector.MapWrapperVector;
-import org.apache.ignite.ml.math.impls.vector.SparseLocalVector;
 
 public class VectorUtils {
     /** Create new vector like given vector initialized by zeroes. */
@@ -31,7 +29,7 @@ public class VectorUtils {
 
     /** Create new */
     public static DenseLocalOnHeapVector zeroes(int n) {
-        return (DenseLocalOnHeapVector) new 
DenseLocalOnHeapVector(n).assign(0.0);
+        return (DenseLocalOnHeapVector)new 
DenseLocalOnHeapVector(n).assign(0.0);
     }
 
     /** */

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/ConvergenceException.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/ConvergenceException.java
 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/ConvergenceException.java
index 2cf0bcf..64687b6 100644
--- 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/ConvergenceException.java
+++ 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/ConvergenceException.java
@@ -38,11 +38,10 @@ public class ConvergenceException extends 
MathIllegalStateException {
     /**
      * Construct the exception with a specific context and arguments.
      *
-     * @param msg Message pattern providing the specific context of
-     * the error.
+     * @param msg Message pattern providing the specific context of the error.
      * @param args Arguments.
      */
-    public ConvergenceException(String msg, Object ... args) {
+    public ConvergenceException(String msg, Object... args) {
         super(msg, args);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/MathIllegalStateException.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/MathIllegalStateException.java
 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/MathIllegalStateException.java
index 13ef5ca..6c63086 100644
--- 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/MathIllegalStateException.java
+++ 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/exceptions/MathIllegalStateException.java
@@ -27,7 +27,7 @@ public class MathIllegalStateException extends 
MathRuntimeException {
     private static final long serialVersionUID = -6024911025449780478L;
 
     /** */
-    private static final String ILLEGAL_STATE= "Illegal state.";
+    private static final String ILLEGAL_STATE = "Illegal state.";
 
     /**
      * Simple constructor.
@@ -35,7 +35,7 @@ public class MathIllegalStateException extends 
MathRuntimeException {
      * @param msg Message pattern explaining the cause of the error.
      * @param args Arguments.
      */
-    public MathIllegalStateException(String msg, Object ... args) {
+    public MathIllegalStateException(String msg, Object... args) {
         super(msg, args);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java
index 22a453d..022dd04 100644
--- 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java
+++ 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java
@@ -17,9 +17,8 @@
 
 package org.apache.ignite.ml.math.functions;
 
-import org.apache.ignite.lang.IgniteBiTuple;
-
 import java.util.List;
+import org.apache.ignite.lang.IgniteBiTuple;
 
 /**
  * Compatibility with Apache Mahout.
@@ -89,11 +88,6 @@ public final class Functions {
     public static final IgniteBiFunction<Double, Double, Double> COMPARE = (a, 
b) -> a < b ? -1.0 : a > b ? 1.0 : 0.0;
 
     /** */
-    public  static <A, B, C> IgniteFunction<B, C> curry(IgniteBiFunction<A, B, 
C> f, A a) {
-        return (IgniteFunction<B, C>)b -> f.apply(a, b);
-    }
-
-    /** */
     public static <A, B extends Comparable<B>> IgniteBiTuple<Integer, A> 
argmin(List<A> args, IgniteFunction<A, B> f) {
         A res = null;
         B fRes = null;

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/CacheUtils.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/CacheUtils.java 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/CacheUtils.java
index 836789b..1bda5e6 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/CacheUtils.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/CacheUtils.java
@@ -40,7 +40,6 @@ import org.apache.ignite.ml.math.ValueMapper;
 import org.apache.ignite.ml.math.functions.IgniteBiFunction;
 import org.apache.ignite.ml.math.functions.IgniteConsumer;
 import org.apache.ignite.ml.math.functions.IgniteFunction;
-import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
 import 
org.apache.ignite.ml.math.impls.storage.matrix.SparseDistributedMatrixStorage;
 
 /**
@@ -137,7 +136,8 @@ public class CacheUtils {
                 double sum = sum(map.values());
 
                 return acc == null ? sum : acc + sum;
-            } else
+            }
+            else
                 return acc;
         }, key -> key.get2().equals(matrixUuid));
 
@@ -199,7 +199,8 @@ public class CacheUtils {
                     return min;
                 else
                     return Math.min(acc, min);
-            } else
+            }
+            else
                 return acc;
         }, key -> key.get2().equals(matrixUuid));
 
@@ -222,7 +223,8 @@ public class CacheUtils {
                     return max;
                 else
                     return Math.max(acc, max);
-            } else
+            }
+            else
                 return acc;
         }, key -> key.get2().equals(matrixUuid));
 
@@ -307,7 +309,8 @@ public class CacheUtils {
      * @param <K> Cache key object type.
      * @param <V> Cache value object type.
      */
-    public static <K, V> void foreach(String cacheName, 
IgniteConsumer<CacheEntry<K, V>> fun, IgnitePredicate<K> keyFilter) {
+    public static <K, V> void foreach(String cacheName, 
IgniteConsumer<CacheEntry<K, V>> fun,
+        IgnitePredicate<K> keyFilter) {
         bcast(cacheName, () -> {
             Ignite ignite = Ignition.localIgnite();
             IgniteCache<K, V> cache = ignite.getOrCreateCache(cacheName);
@@ -355,7 +358,8 @@ public class CacheUtils {
      * @param <A> Fold result type.
      * @return Fold operation result.
      */
-    public static <K, V, A> Collection<A> fold(String cacheName, 
IgniteBiFunction<CacheEntry<K, V>, A, A> folder, IgnitePredicate<K> keyFilter) {
+    public static <K, V, A> Collection<A> fold(String cacheName, 
IgniteBiFunction<CacheEntry<K, V>, A, A> folder,
+        IgnitePredicate<K> keyFilter) {
         return bcast(cacheName, () -> {
             Ignite ignite = Ignition.localIgnite();
             IgniteCache<K, V> cache = ignite.getOrCreateCache(cacheName);
@@ -385,12 +389,13 @@ public class CacheUtils {
 
     public static <K, V, A> A distributedFold(String cacheName, 
IgniteBiFunction<Cache.Entry<K, V>, A, A> folder,
         IgnitePredicate<K> keyFilter, BinaryOperator<A> accumulator, A 
zeroVal) {
-        return sparseFold(cacheName, folder, keyFilter, accumulator, zeroVal, 
null, null, 0 ,
+        return sparseFold(cacheName, folder, keyFilter, accumulator, zeroVal, 
null, null, 0,
             false);
     }
 
     private static <K, V, A> A sparseFold(String cacheName, 
IgniteBiFunction<Cache.Entry<K, V>, A, A> folder,
-        IgnitePredicate<K> keyFilter, BinaryOperator<A> accumulator, A 
zeroVal, V defVal, K defKey, long defValCnt, boolean isNilpotent) {
+        IgnitePredicate<K> keyFilter, BinaryOperator<A> accumulator, A 
zeroVal, V defVal, K defKey, long defValCnt,
+        boolean isNilpotent) {
 
         A defRes = zeroVal;
 
@@ -417,7 +422,7 @@ public class CacheUtils {
                 // Iterate over given partition.
                 // Query returns an empty cursor if this partition is not 
stored on this node.
                 for (Cache.Entry<K, V> entry : cache.query(new ScanQuery<K, 
V>(part,
-                    (k, v) -> affinity.mapPartitionToNode(p) == localNode  && 
(keyFilter == null || keyFilter.apply(k)))))
+                    (k, v) -> affinity.mapPartitionToNode(p) == localNode && 
(keyFilter == null || keyFilter.apply(k)))))
                     a = folder.apply(entry, a);
             }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/AbstractMatrix.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/AbstractMatrix.java
 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/AbstractMatrix.java
index 106a425..d1d3904 100644
--- 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/AbstractMatrix.java
+++ 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/AbstractMatrix.java
@@ -24,8 +24,6 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Random;
-import java.util.function.BiFunction;
-import java.util.function.BinaryOperator;
 import org.apache.ignite.lang.IgniteUuid;
 import org.apache.ignite.ml.math.Matrix;
 import org.apache.ignite.ml.math.MatrixStorage;

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java
 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java
index 50c7da8..df2ddc4 100644
--- 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java
+++ 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java
@@ -147,7 +147,7 @@ public class SparseDistributedMatrix extends AbstractMatrix 
implements StorageCo
     }
 
     /** */
-    public IgniteUuid getUUID(){
-        return ((SparseDistributedMatrixStorage) getStorage()).getUUID();
+    public IgniteUuid getUUID() {
+        return ((SparseDistributedMatrixStorage)getStorage()).getUUID();
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/MapWrapperStorage.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/MapWrapperStorage.java
 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/MapWrapperStorage.java
index 6cefb25..c0bcde0 100644
--- 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/MapWrapperStorage.java
+++ 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/MapWrapperStorage.java
@@ -17,14 +17,13 @@
 
 package org.apache.ignite.ml.math.impls.storage.matrix;
 
-import org.apache.ignite.internal.util.GridArgumentCheck;
-import org.apache.ignite.ml.math.VectorStorage;
-
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.Map;
 import java.util.Set;
+import org.apache.ignite.internal.util.GridArgumentCheck;
+import org.apache.ignite.ml.math.VectorStorage;
 
 /**
  * Storage for wrapping given map.
@@ -80,7 +79,7 @@ public class MapWrapperStorage implements VectorStorage {
 
     /** {@inheritDoc} */
     @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
-        data = (Map<Integer, Double>) in.readObject();
+        data = (Map<Integer, Double>)in.readObject();
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseDistributedMatrixStorage.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseDistributedMatrixStorage.java
 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseDistributedMatrixStorage.java
index 816bf44..1513502 100644
--- 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseDistributedMatrixStorage.java
+++ 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseDistributedMatrixStorage.java
@@ -44,7 +44,7 @@ import 
org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
  * {@link MatrixStorage} implementation for {@link SparseDistributedMatrix}.
  */
 public class SparseDistributedMatrixStorage extends CacheUtils implements 
MatrixStorage, StorageConstants {
-    /** Cache name used for all instances of {@link 
SparseDistributedMatrixStorage}.*/
+    /** Cache name used for all instances of {@link 
SparseDistributedMatrixStorage}. */
     public static final String ML_CACHE_NAME = "ML_SPARSE_MATRICES_CONTAINER";
     /** Amount of rows in the matrix. */
     private int rows;
@@ -93,7 +93,7 @@ public class SparseDistributedMatrixStorage extends 
CacheUtils implements Matrix
     }
 
     /**
-     *  Create new ML cache if needed.
+     * Create new ML cache if needed.
      */
     private IgniteCache<IgniteBiTuple<Integer, IgniteUuid>, Map<Integer, 
Double>> newCache() {
         CacheConfiguration<IgniteBiTuple<Integer, IgniteUuid>, Map<Integer, 
Double>> cfg = new CacheConfiguration<>();
@@ -198,7 +198,6 @@ public class SparseDistributedMatrixStorage extends 
CacheUtils implements Matrix
             // Local get.
             Map<Integer, Double> map = cache.localPeek(getCacheKey(a), 
CachePeekMode.PRIMARY);
 
-
             if (map == null) {
                 map = cache.get(getCacheKey(a)); //Remote entry get.
 
@@ -217,7 +216,7 @@ public class SparseDistributedMatrixStorage extends 
CacheUtils implements Matrix
     }
 
     /** Build cache key for row/column. */
-    private IgniteBiTuple<Integer, IgniteUuid> getCacheKey(int idx){
+    private IgniteBiTuple<Integer, IgniteUuid> getCacheKey(int idx) {
         return new IgniteBiTuple<>(idx, uuid);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
index f07a16e..f2efe74 100644
--- 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
+++ 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
@@ -47,7 +47,6 @@ public class SparseLocalOnHeapVectorStorage implements 
VectorStorage, StorageCon
     }
 
     /**
-     *
      * @param map
      */
     public SparseLocalOnHeapVectorStorage(Map<Integer, Double> map, boolean 
copy) {
@@ -57,11 +56,10 @@ public class SparseLocalOnHeapVectorStorage implements 
VectorStorage, StorageCon
 
         if (map instanceof Int2DoubleRBTreeMap)
             acsMode = SEQUENTIAL_ACCESS_MODE;
+        else if (map instanceof Int2DoubleOpenHashMap)
+            acsMode = RANDOM_ACCESS_MODE;
         else
-            if (map instanceof Int2DoubleOpenHashMap)
-                acsMode = RANDOM_ACCESS_MODE;
-            else
-                acsMode = UNKNOWN_STORAGE_MODE;
+            acsMode = UNKNOWN_STORAGE_MODE;
 
         if (copy)
             switch (acsMode) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MapWrapperVector.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MapWrapperVector.java
 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MapWrapperVector.java
index c04cc45..a093d0e 100644
--- 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MapWrapperVector.java
+++ 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MapWrapperVector.java
@@ -17,12 +17,11 @@
 
 package org.apache.ignite.ml.math.impls.vector;
 
+import java.util.Map;
 import org.apache.ignite.ml.math.Matrix;
 import org.apache.ignite.ml.math.Vector;
 import org.apache.ignite.ml.math.impls.storage.matrix.MapWrapperStorage;
 
-import java.util.Map;
-
 /**
  * Vector wrapping a given map.
  */

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/java/org/apache/ignite/ml/math/util/MatrixUtil.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/main/java/org/apache/ignite/ml/math/util/MatrixUtil.java 
b/modules/ml/src/main/java/org/apache/ignite/ml/math/util/MatrixUtil.java
index 5ef7176..7a90ba1 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/util/MatrixUtil.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/util/MatrixUtil.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.ml.math.util;
 
 import java.util.List;
-
 import org.apache.ignite.internal.util.GridArgumentCheck;
 import org.apache.ignite.ml.math.Matrix;
 import org.apache.ignite.ml.math.Vector;

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/resources/org/apache/ignite/ml/math/d3-matrix-template.html
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/main/resources/org/apache/ignite/ml/math/d3-matrix-template.html
 
b/modules/ml/src/main/resources/org/apache/ignite/ml/math/d3-matrix-template.html
index 0639f07..055344b 100644
--- 
a/modules/ml/src/main/resources/org/apache/ignite/ml/math/d3-matrix-template.html
+++ 
b/modules/ml/src/main/resources/org/apache/ignite/ml/math/d3-matrix-template.html
@@ -39,6 +39,7 @@
         margin-left: 5px;
         vertical-align: bottom;
     }
+
 </style>
 <body>
 <img style="margin-top: 15px" width="100px" 
src="https://ignite.apache.org/images/logo3.png";>
@@ -116,4 +117,5 @@
             })
             .attr("width", rw)
             .attr("height", rh);
+
 </script>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/main/resources/org/apache/ignite/ml/math/d3-vector-template.html
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/main/resources/org/apache/ignite/ml/math/d3-vector-template.html
 
b/modules/ml/src/main/resources/org/apache/ignite/ml/math/d3-vector-template.html
index 9593e86..a615b7c 100644
--- 
a/modules/ml/src/main/resources/org/apache/ignite/ml/math/d3-vector-template.html
+++ 
b/modules/ml/src/main/resources/org/apache/ignite/ml/math/d3-vector-template.html
@@ -39,6 +39,7 @@
         margin-left: 5px;
         vertical-align: bottom;
     }
+
 </style>
 <body>
 <img style="margin-top: 15px" width="100px" 
src="https://ignite.apache.org/images/logo3.png";>
@@ -101,4 +102,5 @@
         })
         .attr("width", rw)
         .attr("height", rh);
+
 </script>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/test/java/org/apache/ignite/ml/IgniteMLTestSuite.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/test/java/org/apache/ignite/ml/IgniteMLTestSuite.java 
b/modules/ml/src/test/java/org/apache/ignite/ml/IgniteMLTestSuite.java
index dea3edf..5ac7443 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/IgniteMLTestSuite.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/IgniteMLTestSuite.java
@@ -17,7 +17,7 @@
 
 package org.apache.ignite.ml;
 
-import org.apache.ignite.ml.clustering.ClusteringTesetSuite;
+import org.apache.ignite.ml.clustering.ClusteringTestSuite;
 import org.apache.ignite.ml.math.MathImplMainTestSuite;
 import org.apache.ignite.ml.regressions.RegressionsTestSuite;
 import org.junit.runner.RunWith;
@@ -30,7 +30,7 @@ import org.junit.runners.Suite;
 @Suite.SuiteClasses({
     MathImplMainTestSuite.class,
     RegressionsTestSuite.class,
-    ClusteringTesetSuite.class
+    ClusteringTestSuite.class
 })
 public class IgniteMLTestSuite {
     // No-op.

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/test/java/org/apache/ignite/ml/clustering/ClusteringTesetSuite.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/test/java/org/apache/ignite/ml/clustering/ClusteringTesetSuite.java
 
b/modules/ml/src/test/java/org/apache/ignite/ml/clustering/ClusteringTesetSuite.java
deleted file mode 100644
index fb756ba..0000000
--- 
a/modules/ml/src/test/java/org/apache/ignite/ml/clustering/ClusteringTesetSuite.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.ml.clustering;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Test suite for all tests located in org.apache.ignite.ml.clustering package.
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
-        KMeansDistributedClustererTest.class,
-        KMeansLocalClustererTest.class
-})
-public class ClusteringTesetSuite {
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/test/java/org/apache/ignite/ml/clustering/ClusteringTestSuite.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/test/java/org/apache/ignite/ml/clustering/ClusteringTestSuite.java
 
b/modules/ml/src/test/java/org/apache/ignite/ml/clustering/ClusteringTestSuite.java
new file mode 100644
index 0000000..c39eeef
--- /dev/null
+++ 
b/modules/ml/src/test/java/org/apache/ignite/ml/clustering/ClusteringTestSuite.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ml.clustering;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Test suite for all tests located in org.apache.ignite.ml.clustering package.
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+    KMeansDistributedClustererTest.class,
+    KMeansLocalClustererTest.class
+})
+public class ClusteringTestSuite {
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/test/java/org/apache/ignite/ml/clustering/KMeansDistributedClustererTest.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/test/java/org/apache/ignite/ml/clustering/KMeansDistributedClustererTest.java
 
b/modules/ml/src/test/java/org/apache/ignite/ml/clustering/KMeansDistributedClustererTest.java
index 7fb3534..cdc2651 100644
--- 
a/modules/ml/src/test/java/org/apache/ignite/ml/clustering/KMeansDistributedClustererTest.java
+++ 
b/modules/ml/src/test/java/org/apache/ignite/ml/clustering/KMeansDistributedClustererTest.java
@@ -18,13 +18,23 @@
 package org.apache.ignite.ml.clustering;
 
 import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.internal.util.IgniteUtils;
-import org.apache.ignite.ml.math.*;
+import org.apache.ignite.ml.math.DistanceMeasure;
+import org.apache.ignite.ml.math.EuclideanDistance;
+import org.apache.ignite.ml.math.StorageConstants;
 import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.VectorUtils;
 import org.apache.ignite.ml.math.functions.Functions;
 import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
 import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
@@ -36,8 +46,10 @@ import static 
org.apache.ignite.ml.clustering.KMeansUtil.checkIsInEpsilonNeighbo
 
 /** */
 public class KMeansDistributedClustererTest extends GridCommonAbstractTest {
-    /** Number of nodes in grid. We should use 1 in this test because 
otherwise algorithm will be unstable
-     * (We cannot guarantee the order in which results are returned from each 
node). */
+    /**
+     * Number of nodes in grid. We should use 1 in this test because otherwise 
algorithm will be unstable
+     * (We cannot guarantee the order in which results are returned from each 
node).
+     */
     private static final int NODE_COUNT = 1;
 
     /** Grid instance. */
@@ -79,7 +91,7 @@ public class KMeansDistributedClustererTest extends 
GridCommonAbstractTest {
         double[] v2 = new double[] {1960, 373200};
 
         SparseDistributedMatrix points = new SparseDistributedMatrix(2, 2, 
StorageConstants.ROW_STORAGE_MODE,
-                StorageConstants.RANDOM_ACCESS_MODE);
+            StorageConstants.RANDOM_ACCESS_MODE);
 
         points.setRow(0, v1);
         points.setRow(1, v2);
@@ -110,7 +122,7 @@ public class KMeansDistributedClustererTest extends 
GridCommonAbstractTest {
         int centersCnt = centers.size();
 
         SparseDistributedMatrix points = new SparseDistributedMatrix(ptsCnt, 
2, StorageConstants.ROW_STORAGE_MODE,
-                StorageConstants.RANDOM_ACCESS_MODE);
+            StorageConstants.RANDOM_ACCESS_MODE);
 
         List<Integer> permutation = IntStream.range(0, 
ptsCnt).boxed().collect(Collectors.toList());
         Collections.shuffle(permutation, rnd);
@@ -146,7 +158,7 @@ public class KMeansDistributedClustererTest extends 
GridCommonAbstractTest {
         Vector[] resCenters = mdl.centers();
         Arrays.sort(resCenters, comp);
 
-        checkIsInEpsilonNeighbourhood(resCenters, massCenters.toArray(new 
Vector[]{}), 30.0);
+        checkIsInEpsilonNeighbourhood(resCenters, massCenters.toArray(new 
Vector[] {}), 30.0);
     }
 
     /** */
@@ -178,7 +190,7 @@ public class KMeansDistributedClustererTest extends 
GridCommonAbstractTest {
                 return signum;
 
             return (int)Math.signum(orderedNodes.get(ind1).minus(v1).kNorm(2) -
-                    orderedNodes.get(ind2).minus(v2).kNorm(2));
+                orderedNodes.get(ind2).minus(v2).kNorm(2));
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/test/java/org/apache/ignite/ml/math/MathImplLocalTestSuite.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/test/java/org/apache/ignite/ml/math/MathImplLocalTestSuite.java
 
b/modules/ml/src/test/java/org/apache/ignite/ml/math/MathImplLocalTestSuite.java
index d164be9..216fd7b 100644
--- 
a/modules/ml/src/test/java/org/apache/ignite/ml/math/MathImplLocalTestSuite.java
+++ 
b/modules/ml/src/test/java/org/apache/ignite/ml/math/MathImplLocalTestSuite.java
@@ -59,7 +59,6 @@ import 
org.apache.ignite.ml.math.impls.vector.VectorIterableTest;
 import org.apache.ignite.ml.math.impls.vector.VectorNormTest;
 import org.apache.ignite.ml.math.impls.vector.VectorToMatrixTest;
 import org.apache.ignite.ml.math.impls.vector.VectorViewTest;
-import org.apache.ignite.ml.regressions.OLSMultipleLinearRegressionTest;
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java 
b/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
index 0bc393f..407f3a0 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
@@ -26,6 +26,7 @@ import java.util.Optional;
 import org.apache.ignite.ml.math.impls.MathTestConstants;
 import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
 import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
+import org.junit.Ignore;
 import org.junit.Test;
 
 import static java.nio.file.Files.createTempFile;
@@ -108,6 +109,7 @@ public class TracerTest {
      *
      */
     @Test
+    @Ignore("Can not run on TeamCity yet, see IGNITE-5725")
     public void testHtmlVectorTracer() throws IOException {
         Vector vec1 = makeRandomVector(1000);
 
@@ -125,6 +127,7 @@ public class TracerTest {
      *
      */
     @Test
+    @Ignore("Can not run on TeamCity yet, see IGNITE-5725")
     public void testHtmlMatrixTracer() throws IOException {
         Matrix mtx1 = makeRandomMatrix(100, 100);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrixTest.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrixTest.java
 
b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrixTest.java
index 54975f0..a7cd6b5 100644
--- 
a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrixTest.java
+++ 
b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrixTest.java
@@ -24,6 +24,7 @@ import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
@@ -108,7 +109,7 @@ public class SparseDistributedMatrixTest extends 
GridCommonAbstractTest {
                 double v = Math.random();
                 cacheMatrix.set(i, j, v);
 
-                assertEquals("Unexpected value for matrix element["+ i +" " + 
j + "]", v, cacheMatrix.get(i, j), PRECISION);
+                assertEquals("Unexpected value for matrix element[" + i + " " 
+ j + "]", v, cacheMatrix.get(i, j), PRECISION);
             }
         }
     }
@@ -223,7 +224,7 @@ public class SparseDistributedMatrixTest extends 
GridCommonAbstractTest {
     }
 
     /** */
-    public void testCacheBehaviour(){
+    public void testCacheBehaviour() {
         
IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
 
         SparseDistributedMatrix cacheMatrix1 = new 
SparseDistributedMatrix(rows, cols, StorageConstants.ROW_STORAGE_MODE, 
StorageConstants.RANDOM_ACCESS_MODE);
@@ -236,22 +237,27 @@ public class SparseDistributedMatrixTest extends 
GridCommonAbstractTest {
 
         assert 
cacheNames.contains(SparseDistributedMatrixStorage.ML_CACHE_NAME);
 
-        IgniteCache<IgniteBiTuple<Integer, IgniteUuid>, Object> cache = 
ignite.getOrCreateCache(SparseDistributedMatrixStorage.ML_CACHE_NAME);
+        IgniteCache<IgniteBiTuple<Integer, IgniteUuid>, Map<Integer, Double>> 
cache = ignite.getOrCreateCache(SparseDistributedMatrixStorage.ML_CACHE_NAME);
 
         Set<IgniteBiTuple<Integer, IgniteUuid>> keySet1 = 
buildKeySet(cacheMatrix1);
         Set<IgniteBiTuple<Integer, IgniteUuid>> keySet2 = 
buildKeySet(cacheMatrix2);
 
-        assert cache.containsKeys(keySet1);
-        assert cache.containsKeys(keySet2);
+        assert cache.containsKeys(keySet1) ||
+            keySet1.stream().allMatch(k -> cache.invoke(k, (entry, arguments) 
-> entry.getKey().equals(k) && entry.getValue().size() == 100));
+        assert cache.containsKeys(keySet2) ||
+            keySet2.stream().allMatch(k -> cache.invoke(k, (entry, arguments) 
-> entry.getKey().equals(k) && entry.getValue().size() == 100));
 
         cacheMatrix2.destroy();
 
-        assert cache.containsKeys(keySet1);
-        assert !cache.containsKeys(keySet2);
+        assert cache.containsKeys(keySet1) ||
+            keySet1.stream().allMatch(k -> cache.invoke(k, (entry, arguments) 
-> entry.getKey().equals(k) && entry.getValue().size() == 100));
+        assert !cache.containsKeys(keySet2) &&
+            keySet2.stream().allMatch(k -> cache.invoke(k, (entry, arguments) 
-> entry.getKey().equals(k) && entry.getValue() == null));
 
         cacheMatrix1.destroy();
 
-        assert !cache.containsKeys(keySet1);
+        assert !cache.containsKeys(keySet1) &&
+            keySet1.stream().allMatch(k -> cache.invoke(k, (entry, arguments) 
-> entry.getKey().equals(k) && entry.getValue() == null));
     }
 
     /** */
@@ -287,7 +293,7 @@ public class SparseDistributedMatrixTest extends 
GridCommonAbstractTest {
     }
 
     /** Build key set for SparseDistributedMatrix. */
-    private Set<IgniteBiTuple<Integer, IgniteUuid>> 
buildKeySet(SparseDistributedMatrix m){
+    private Set<IgniteBiTuple<Integer, IgniteUuid>> 
buildKeySet(SparseDistributedMatrix m) {
         Set<IgniteBiTuple<Integer, IgniteUuid>> set = new HashSet<>();
 
         SparseDistributedMatrixStorage storage = 
(SparseDistributedMatrixStorage)m.getStorage();

http://git-wip-us.apache.org/repos/asf/ignite/blob/d2fe4374/modules/ml/src/test/java/org/apache/ignite/ml/regressions/OLSMultipleLinearRegressionTest.java
----------------------------------------------------------------------
diff --git 
a/modules/ml/src/test/java/org/apache/ignite/ml/regressions/OLSMultipleLinearRegressionTest.java
 
b/modules/ml/src/test/java/org/apache/ignite/ml/regressions/OLSMultipleLinearRegressionTest.java
index e992163..7f76750 100644
--- 
a/modules/ml/src/test/java/org/apache/ignite/ml/regressions/OLSMultipleLinearRegressionTest.java
+++ 
b/modules/ml/src/test/java/org/apache/ignite/ml/regressions/OLSMultipleLinearRegressionTest.java
@@ -812,7 +812,7 @@ public class OLSMultipleLinearRegressionTest extends 
AbstractMultipleLinearRegre
 
     /** */
     @Test(expected = MathIllegalArgumentException.class)
-    public void testMathIllegalArgumentException(){
+    public void testMathIllegalArgumentException() {
         OLSMultipleLinearRegression mdl = new OLSMultipleLinearRegression();
         mdl.validateSampleData(new DenseLocalOnHeapMatrix(1, 2), new 
DenseLocalOnHeapVector(1));
     }

Reply via email to