### Question:
JVMTensor implements Tensor<T, TENSOR> { @Override public String toString() { return "{\n" + "shape = " + Arrays.toString(shape) + "\ndata = \n" + arrayToString(buffer.asArray(), shape, stride) + "\n}"; } protected  JVMTensor(B buffer, long[] shape, long[] stride); B getBuffer(); @Override int getRank(); @Override long[] getShape(); @Override long[] getStride(); @Override long getLength(); @Override TENSOR duplicate(); @Override TENSOR get(BooleanTensor booleanIndex); @Override TENSOR diagPart(); static ResultWrapper<T, B> diagPart(long[] shape,
                                 B buffer, JVMBuffer.ArrayWrapperFactory<T, B> factory); @Override TENSOR diag(); static ResultWrapper<T, B> diag(long[] shape,
                             B buffer, JVMBuffer.ArrayWrapperFactory<T, B> factory); @Override TENSOR triUpper(int k); @Override TENSOR triLower(int k); @Override TENSOR fillTriangular(boolean fillUpper, boolean fillLower); @Override TENSOR trianglePart(boolean upperPart); @Override TENSOR permute(int... rearrange); static ResultWrapper<T, B> permute(JVMBuffer.ArrayWrapperFactory<T, B> factory,
                                B buffer,
                                long[] shape, long[] stride,
                                int... rearrange); @Override List<TENSOR> split(int dimension, long... splitAtIndices); static List<ResultWrapper<T, B>> split(JVMBuffer.ArrayWrapperFactory<T, B> factory,
                                    B fromBuffer, long[] shape, long[] stride, int dimension, long... splitAtIndices); @Override TENSOR take(long... index); @Override TENSOR slice(int dimension, long index); @Override TENSOR slice(Slicer slicer); static ResultWrapper<T, B> slice(JVMBuffer.ArrayWrapperFactory<T, B> factory,
                              B buffer,
                              IndexMapper indexMapper); @Override TENSOR reverseSlice(TENSOR setTo, Slicer slicer); static void reverseSlice(FlattenedView<T> from,
                                        FlattenedView<T> to,
                                        IndexMapper indexMapper); static ResultWrapper<T, B> concat(JVMBuffer.ArrayWrapperFactory<T, B> factory,
                               Tensor[] tensors,
                               int dimension, List<B> toConcat); static B concatOnDimensionZero(JVMBuffer.ArrayWrapperFactory<T, B> factory,
                            long[] concatShape, List<B> toConcat); @Override TENSOR reshape(long... newShape); @Override TENSOR broadcast(long... toShape); @Override TENSOR where(BooleanTensor predicate, TENSOR els); IntegerTensor argCompare(BiFunction<T, T, Boolean> compareOp, int axis); static IntegerTensor argCompare(JVMBuffer.ArrayWrapperFactory<T, B> factory,
                             B buffer,
                             BiFunction<T, T, Boolean> compareOp,
                             long[] shape, long[] stride, int axis); int argCompare(BiFunction<T, T, Boolean> compareOp); static int argCompare(B buffer,
                                                                                      BiFunction<T, T, Boolean> compareOp); BooleanTensor isApply(Function<T, Boolean> op); @Override FlattenedView<T> getFlattenedView(); @Override BooleanTensor elementwiseEquals(T value); @Override boolean equals(Object o); @Override String toString(); @Override int hashCode();  }### Answer:
@Test public void canToStringVector() { DoubleTensor vector = JVMDoubleTensorFactory.INSTANCE.arange(0, 3); String actual = vector.toString(); assertThat(actual, equalTo( "{\n" + "shape = [3]\n" + "data = \n" + "[0.0, 1.0, 2.0]\n" + "}")); }
@Test public void canToStringScalar() { DoubleTensor scalar = JVMDoubleTensorFactory.INSTANCE.scalar(9); String actual = scalar.toString(); assertThat(actual, equalTo( "{\n" + "shape = []\n" + "data = \n9.0\n}")); }