Beispiel #1
0
def test_sparse_minimum():
    s1 = SparseNDArray(s1_data)
    s2 = SparseNDArray(s2_data)

    np.testing.assert_array_equal(
        s1.minimum(s2).toarray(),
        s1.minimum(s2).toarray())

    v = SparseVector(v1, shape=(3, ))
    np.testing.assert_array_equal(v.minimum(d1), np.minimum(v1_data, d1))
Beispiel #2
0
    def testSparseMinimum(self):
        s1 = SparseNDArray(self.s1)
        s2 = SparseNDArray(self.s2)

        np.testing.assert_array_equal(
            s1.minimum(s2).toarray(),
            self.s1.minimum(self.s2).toarray())

        v1 = SparseVector(self.v1, shape=(3, ))
        np.testing.assert_array_equal(v1.minimum(self.d1),
                                      np.minimum(self.v1_data, self.d1))
Beispiel #3
0
    def testSparseSetitem(self):
        s1 = SparseNDArray(self.s1.copy())
        s1[1:2, 1] = [2]
        ss1 = self.s1.tolil()
        ss1[1:2, 1] = [2]
        np.testing.assert_array_equal(s1.toarray(), ss1.toarray())

        v1 = SparseVector(self.v1, shape=(3, ))
        v1[1:2] = [2]
        vv1 = self.v1_data
        vv1[1:2] = [2]
        np.testing.assert_array_equal(v1.toarray(), vv1)
Beispiel #4
0
def test_sparse_setitem():
    s1 = SparseNDArray(s1_data.copy())
    s1[1:2, 1] = [2]
    ss1 = s1_data.tolil()
    ss1[1:2, 1] = [2]
    np.testing.assert_array_equal(s1.toarray(), ss1.toarray())

    v = SparseVector(v1, shape=(3, ))
    v[1:2] = [2]
    vv1 = v1_data.copy()
    vv1[1:2] = [2]
    np.testing.assert_array_equal(v.toarray(), vv1)
Beispiel #5
0
 def testSparseGetitem(self):
     s1 = SparseNDArray(self.s1)
     v1 = SparseVector(self.v1, shape=(3, ))
     self.assertEqual(s1[0, 1], self.s1[0, 1])
     self.assertEqual(v1[1], self.v1_data[1])