예제 #1
0
    def test_std_with_axis(self):
        np_2d = np.random.randn(10, 10)
        sp_2d = spartan.from_numpy(np_2d)
        Assert.all_close(spartan.std(sp_2d, 0).glom(), np.std(np_2d, 0))
        Assert.all_close(spartan.std(sp_2d, 1).glom(), np.std(np_2d, 1))

        np_uneven_0 = np.random.randn(15, 13)
        sp_uneven_0 = spartan.from_numpy(np_uneven_0)
        Assert.all_close(
            spartan.std(sp_uneven_0, 0).glom(), np.std(np_uneven_0, 0))
        Assert.all_close(
            spartan.std(sp_uneven_0, 1).glom(), np.std(np_uneven_0, 1))

        np_uneven_1 = np.random.randn(13, 15)
        sp_uneven_1 = spartan.from_numpy(np_uneven_1)
        Assert.all_close(
            spartan.std(sp_uneven_1, 0).glom(), np.std(np_uneven_1, 0))
        Assert.all_close(
            spartan.std(sp_uneven_1, 1).glom(), np.std(np_uneven_1, 1))

        np_big = np.random.randn(17, 17)
        sp_big = spartan.from_numpy(np_big)
        Assert.all_close(spartan.std(sp_big, 0).glom(), np.std(np_big, 0))
        Assert.all_close(spartan.std(sp_big, 1).glom(), np.std(np_big, 1))
예제 #2
0
    def test_ln(self):
        a = 1.0 + expr.ones((100, ), dtype=np.float32)
        b = 1.0 + np.ones(100).astype(np.float32)

        Assert.all_close(expr.ln(a).glom(), np.log(b))
예제 #3
0
  def test_std_with_axis(self):
    np_2d = np.random.randn(10, 10)
    sp_2d = spartan.from_numpy(np_2d)
    Assert.all_close(spartan.std(sp_2d, 0).glom(), np.std(np_2d, 0))
    Assert.all_close(spartan.std(sp_2d, 1).glom(), np.std(np_2d, 1))

    np_uneven_0 = np.random.randn(15, 13)
    sp_uneven_0 = spartan.from_numpy(np_uneven_0)
    Assert.all_close(spartan.std(sp_uneven_0, 0).glom(), np.std(np_uneven_0, 0))
    Assert.all_close(spartan.std(sp_uneven_0, 1).glom(), np.std(np_uneven_0, 1))

    np_uneven_1 = np.random.randn(13, 15)
    sp_uneven_1 = spartan.from_numpy(np_uneven_1)
    Assert.all_close(spartan.std(sp_uneven_1, 0).glom(), np.std(np_uneven_1, 0))
    Assert.all_close(spartan.std(sp_uneven_1, 1).glom(), np.std(np_uneven_1, 1))

    np_big = np.random.randn(17, 17)
    sp_big = spartan.from_numpy(np_big)
    Assert.all_close(spartan.std(sp_big, 0).glom(), np.std(np_big, 0))
    Assert.all_close(spartan.std(sp_big, 1).glom(), np.std(np_big, 1))
예제 #4
0
  def test_ln(self):
    a = 1.0 + expr.ones((100,), dtype=np.float32)
    b = 1.0 + np.ones(100).astype(np.float32)

    Assert.all_close(expr.ln(a).glom(), np.log(b))