Ejemplo n.º 1
0
    def test_align_array(self):
        """
        Test the align_array function.
        """
        l1 = LongArray(10)
        l1.set_data(numpy.arange(10))

        new_indices = LongArray(10)
        new_indices.set_data(numpy.asarray([1, 5, 3, 2, 4, 7, 8, 6, 9, 0]))

        l1.align_array(new_indices)
        self.assertEqual(numpy.allclose([1, 5, 3, 2, 4, 7, 8, 6, 9, 0],
                                        l1.get_npy_array()), True)
Ejemplo n.º 2
0
    def test_align_array(self):
        """
        Test the align_array function.
        """
        l1 = LongArray(10)
        l1.set_data(numpy.arange(10))

        new_indices = LongArray(10)
        new_indices.set_data(numpy.asarray([1, 5, 3, 2, 4, 7, 8, 6, 9, 0]))

        l1.align_array(new_indices)
        self.assertEqual(
            numpy.allclose([1, 5, 3, 2, 4, 7, 8, 6, 9, 0], l1.get_npy_array()),
            True)
Ejemplo n.º 3
0
    def test_align_array(self):
        l1 = LongArray(10)
        l1.set_data(numpy.arange(10))

        new_indices = LongArray(10)
        new_indices.set_data(numpy.asarray([1, 5, 3, 2, 4, 7, 8, 6, 9, 0]))

        l1.align_array(new_indices)
        self.assertEqual(
            numpy.allclose([1, 5, 3, 2, 4, 7, 8, 6, 9, 0], l1.get_npy_array()),
            True)

        # Test case with strides.
        l1 = LongArray(6)
        l1.set_data(numpy.arange(6))

        new_indices = LongArray(3)
        new_indices.set_data(numpy.asarray([2, 1, 0]))
        l1.align_array(new_indices, 2)
        self.assertEqual(
            numpy.allclose([4, 5, 2, 3, 0, 1], l1.get_npy_array()), True)