예제 #1
0
    def test_remove_with_strides(self):
        # Given
        l1 = LongArray(12)
        l1.set_data(numpy.arange(12))

        # When
        rem = [3, 1]
        l1.remove(numpy.array(rem, dtype=numpy.int), stride=3)

        # Then
        self.assertEqual(l1.length, 6)
        self.assertEqual(
            numpy.allclose([0, 1, 2, 6, 7, 8], l1.get_npy_array()), True)

        # Given
        l1 = LongArray(12)
        l1.set_data(numpy.arange(12))

        # When
        rem = [0, 2]
        l1.remove(numpy.array(rem, dtype=numpy.int), stride=3)

        # Then
        self.assertEqual(l1.length, 6)
        [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
        self.assertEqual(
            numpy.allclose([9, 10, 11, 3, 4, 5], l1.get_npy_array()), True)
예제 #2
0
    def test_remove(self):
        l1 = LongArray(10)
        l1.set_data(numpy.arange(10))
        rem = [0, 4, 3]
        l1.remove(numpy.array(rem, dtype=numpy.int))
        self.assertEqual(l1.length, 7)
        self.assertEqual(
            numpy.allclose([7, 1, 2, 8, 9, 5, 6], l1.get_npy_array()), True)

        l1.remove(numpy.array(rem, dtype=numpy.int))
        self.assertEqual(l1.length, 4)
        self.assertEqual(numpy.allclose([6, 1, 2, 5], l1.get_npy_array()),
                         True)

        rem = [0, 1, 3]
        l1.remove(numpy.array(rem, dtype=numpy.int))
        self.assertEqual(l1.length, 1)
        self.assertEqual(numpy.allclose([2], l1.get_npy_array()), True)

        l1.remove(numpy.array([0], dtype=numpy.int))
        self.assertEqual(l1.length, 0)
        self.assertEqual(len(l1.get_npy_array()), 0)