Beispiel #1
0
 def test_mean2(self):
     self.assertTrue(
         np.allclose(
             sml.matrix(m1).mean(axis=0),
             m1.mean(axis=0).reshape(1, dim)))
 def test_plus2(self):
     self.assertTrue(np.allclose(m1 + sml.matrix(m2), m1 + m2))
 def test_power2(self):
     self.assertTrue(np.allclose(m1 ** sml.matrix(m2), m1 ** m2))
 def test_le(self):
     self.assertTrue(np.allclose(sml.matrix(m1) <= sml.matrix(m2), m1 <= m2))
 def test_minus1(self):
     self.assertTrue(np.allclose(sml.matrix(m1) - m2, m1 - m2))
 def test_mul3(self):
     self.assertTrue(np.allclose(sml.matrix(m1) * s, m1 * s))
 def test_minus4(self):
     self.assertTrue(np.allclose(s - sml.matrix(m2), s - m2))
 def test_mean3(self):
     self.assertTrue(np.allclose(sml.matrix(m1).mean(axis=1), m1.mean(axis=1).reshape(dim, 1)))
 def test_vstack(self):
     self.assertTrue(np.allclose(sml.matrix(m1).vstack(sml.matrix(m1)), np.vstack((m1, m1))))
Beispiel #10
0
 def test_var2(self):
     self.assertTrue(
         np.allclose(
             sml.matrix(m1).var(axis=0),
             m1.var(axis=0, ddof=1).reshape(1, dim)))
 def test_mean2(self):
     self.assertTrue(np.allclose(sml.matrix(m1).mean(axis=0), m1.mean(axis=0).reshape(1, dim)))
Beispiel #12
0
 def test_var1(self):
     print(
         str(np.array(sml.matrix(m1).var())) + " " +
         str(np.array(m1.var(ddof=1))))
     self.assertTrue(np.allclose(sml.matrix(m1).var(), m1.var(ddof=1)))
Beispiel #13
0
 def test_vstack(self):
     self.assertTrue(
         np.allclose(
             sml.matrix(m1).vstack(sml.matrix(m1)), np.vstack((m1, m1))))
Beispiel #14
0
 def test_mean3(self):
     self.assertTrue(
         np.allclose(
             sml.matrix(m1).mean(axis=1),
             m1.mean(axis=1).reshape(dim, 1)))
 def test_div2(self):
     self.assertTrue(np.allclose(m1 / sml.matrix(m2), m1 / m2))
 def test_var1(self):
     print(str(np.array(sml.matrix(m1).var())) + " " + str(np.array(m1.var(ddof=1))))
     self.assertTrue(np.allclose(sml.matrix(m1).var(), m1.var(ddof=1)))
 def test_plus3(self):
     self.assertTrue(np.allclose(sml.matrix(m1) + s, m1 + s))
 def test_var2(self):
     self.assertTrue(np.allclose(sml.matrix(m1).var(axis=0), m1.var(axis=0, ddof=1).reshape(1, dim)))
 def test_power3(self):
     self.assertTrue(np.allclose(sml.matrix(m1) ** s, m1 ** s))
 def test_var3(self):
     self.assertTrue(np.allclose(sml.matrix(m1).var(axis=1), m1.var(axis=1, ddof=1).reshape(dim, 1)))
 def test_div4(self):
     self.assertTrue(np.allclose(s / sml.matrix(m2), s / m2))
 def test_moment4(self):
     self.assertTrue(np.allclose(sml.matrix(m1).moment(moment=4, axis=None), moment(m1, moment=4, axis=None)))
 def test_abs(self):
     self.assertTrue(np.allclose(sml.matrix(m1).abs(), np.abs(m1)))
Beispiel #24
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.
#
#-------------------------------------------------------------

import systemml as sml
import numpy as np

from pyspark import SparkContext
sc = SparkContext()

m1 = sml.matrix(np.ones((3, 3)) + 2)
m2 = sml.matrix(np.ones((3, 3)) + 3)
m2 = m1 * (m2 + m1)
m4 = 1.0 - m2
m4.sum(axis=1).toNumPy()
 def test_div1(self):
     self.assertTrue(np.allclose(sml.matrix(m1) / m2, m1 / m2))
 def test_div3(self):
     self.assertTrue(np.allclose(sml.matrix(m1) / s, m1 / s))
 def test_mul2(self):
     self.assertTrue(np.allclose(m1 * sml.matrix(m2), m1 * m2))
 def test_power3(self):
     self.assertTrue(np.allclose(sml.matrix(m1)**s, m1**s))
 def test_minus3(self):
     self.assertTrue(np.allclose(sml.matrix(m1) - s, m1 - s))
 def test_plus4(self):
     self.assertTrue(np.allclose(s + sml.matrix(m2), s + m2))
 def test_mul2(self):
     self.assertTrue(np.allclose(m1 * sml.matrix(m2), m1 * m2))
 def test_minus4(self):
     self.assertTrue(np.allclose(s - sml.matrix(m2), s - m2))
 def test_power2(self):
     self.assertTrue(np.allclose(m1**sml.matrix(m2), m1**m2))
 def test_mul4(self):
     self.assertTrue(np.allclose(s * sml.matrix(m2), s * m2))
 def test_minus3(self):
     self.assertTrue(np.allclose(sml.matrix(m1) - s, m1 - s))
 def test_div4(self):
     self.assertTrue(np.allclose(s / sml.matrix(m2), s / m2))
 def test_div3(self):
     self.assertTrue(np.allclose(sml.matrix(m1) / s, m1 / s))
 def test_power4(self):
     self.assertTrue(np.allclose(s**sml.matrix(m2), s**m2))
 def test_plus4(self):
     self.assertTrue(np.allclose(s + sml.matrix(m2), s + m2))
 def test_le(self):
     self.assertTrue(np.allclose(
         sml.matrix(m1) <= sml.matrix(m2), m1 <= m2))
 def test_mul4(self):
     self.assertTrue(np.allclose(s * sml.matrix(m2), s * m2))
 def test_ge(self):
     self.assertTrue(np.allclose(
         sml.matrix(m1) >= sml.matrix(m2), m1 >= m2))
 def test_power4(self):
     self.assertTrue(np.allclose(s ** sml.matrix(m2), s ** m2))
 def test_abs(self):
     self.assertTrue(np.allclose(sml.matrix(m1).abs(), np.abs(m1)))
 def test_ge(self):
     self.assertTrue(np.allclose(sml.matrix(m1) >= sml.matrix(m2), m1 >= m2))
 def test_plus1(self):
     self.assertTrue(np.allclose(sml.matrix(m1) + m2, m1 + m2))
 def test_plus1(self):
     self.assertTrue(np.allclose(sml.matrix(m1) + m2, m1 + m2))
 def test_minus1(self):
     self.assertTrue(np.allclose(sml.matrix(m1) - m2, m1 - m2))
 def test_mul1(self):
     self.assertTrue(np.allclose(sml.matrix(m1) * m2, m1 * m2))
 def test_mul1(self):
     self.assertTrue(np.allclose(sml.matrix(m1) * m2, m1 * m2))
 def test_power1(self):
     self.assertTrue(np.allclose(sml.matrix(m1) ** m2, m1 ** m2))
 def test_div1(self):
     self.assertTrue(np.allclose(sml.matrix(m1) / m2, m1 / m2))
 def test_minus2(self):
     self.assertTrue(np.allclose(m1 - sml.matrix(m2), m1 - m2))
 def test_power1(self):
     self.assertTrue(np.allclose(sml.matrix(m1)**m2, m1**m2))
 def test_div2(self):
     self.assertTrue(np.allclose(m1 / sml.matrix(m2), m1 / m2))
 def test_plus2(self):
     self.assertTrue(np.allclose(m1 + sml.matrix(m2), m1 + m2))
 def test_plus3(self):
     self.assertTrue(np.allclose(sml.matrix(m1) + s, m1 + s))
 def test_minus2(self):
     self.assertTrue(np.allclose(m1 - sml.matrix(m2), m1 - m2))
 def test_mul3(self):
     self.assertTrue(np.allclose(sml.matrix(m1) * s, m1 * s))
Beispiel #60
0
 def test_mean1(self):
     self.assertTrue(np.allclose(sml.matrix(m1).mean(), m1.mean()))