def test_create_from_scalar_list(self):
        x = [1, 2, 3, 4, 5]
        s = TensorArray(x)
        self.assertTupleEqual(s.numpy_shape, (len(x),))
        expected = np.array(x)
        npt.assert_array_equal(s.to_numpy(), expected)

        # Now with TensorElement values
        e = [TensorElement(np.array(i)) for i in x]
        s = pd.array(e, dtype=TensorDtype())
        npt.assert_array_equal(s.to_numpy(), expected)

        # Now with list of 1d tensors
        x = [np.array([i]) for i in x]
        s = pd.array(x, dtype=TensorDtype())
        self.assertTupleEqual(s.to_numpy().shape, (len(x), 1))
        npt.assert_array_equal(s.to_numpy(), np.array([[e] for e in expected]))

        # Pandas will create list of copies of the tensor element for the given indices
        s = pd.Series(np.nan, index=[0, 1, 2], dtype=TensorDtype())
        self.assertEqual(len(s), 3)
        self.assertTupleEqual(s.to_numpy().shape, (3,))
        result = s.isna()
        self.assertTrue(np.all(result.to_numpy()))
 def test_asarray(self):
     x = np.array([[1, 2], [3, 4], [5, 6]])
     s = TensorArray(x)
     a = np.asarray(s)
     npt.assert_array_equal(x, a)
     npt.assert_array_equal(x, s.to_numpy())