def test_construct_ragged_array(): rarray = RaggedArray([[1, 2], [], [10, 20, 30], None, [11, 22, 33, 44]], dtype='int32') # Check flat array assert rarray.flat_array.dtype == 'int32' assert np.array_equal( rarray.flat_array, np.array([1, 2, 10, 20, 30, 11, 22, 33, 44], dtype='int32')) # Check start indices assert rarray.start_indices.dtype == 'uint8' assert np.array_equal(rarray.start_indices, np.array([0, 2, 2, 5, 5], dtype='uint64')) # Check len assert len(rarray) == 5 # Check isna assert rarray.isna().dtype == 'bool' assert np.array_equal(rarray.isna(), [False, True, False, True, False]) # Check nbytes expected = ( 9 * np.int32().nbytes + # flat_array 5 * np.uint8().nbytes # start_indices ) assert rarray.nbytes == expected # Check dtype assert type(rarray.dtype) == RaggedDtype
def test_isna(): rarray = RaggedArray( [[], [1, 3], [10, 20, 30], None, [11, 22, 33, 44], []], dtype='int32') np.testing.assert_array_equal( rarray.isna(), np.array([True, False, False, True, False, True]))