@@ -1276,6 +1276,56 @@ def try_rt(name, df, pq_args={}):
12761276 basic3 = make_dataframe_basic3 ()
12771277 try_rt ("basic3" , basic3 )
12781278
1279+ @pytest .mark .parametrize (
1280+ "dim_data, attr_data, dtype, domain" ,
1281+ [
1282+ (pyarrow .array ([1 , 2 , 3 ]), pyarrow .array ([1 , 2 , 3 ]), np .int64 , (1 , 3 )),
1283+ (pyarrow .array (["a" , "b" , "c" ]), pyarrow .array ([1 , 2 , 3 ]), "ascii" , None ),
1284+ ],
1285+ )
1286+ def test_read_indexing_with_pyarrow_and_numpy_arrays (
1287+ self , dim_data , attr_data , dtype , domain
1288+ ):
1289+ # This test is to ensure that .df can be indexed with both PyArrow and NumPy arrays.
1290+ uri = self .path ("read_indexing_with_pyarrow_and_numpy_arrays" )
1291+
1292+ dim = (
1293+ tiledb .Dim (name = "dim_a" , dtype = dtype , domain = domain )
1294+ if domain
1295+ else tiledb .Dim (name = "dim_a" , dtype = dtype )
1296+ )
1297+ schema = tiledb .ArraySchema (
1298+ domain = tiledb .Domain (dim ),
1299+ sparse = True ,
1300+ attrs = [tiledb .Attr (name = "rand" , dtype = np .int32 )],
1301+ allows_duplicates = True ,
1302+ )
1303+ tiledb .Array .create (uri , schema )
1304+
1305+ with tiledb .open (uri , "w" ) as arr :
1306+ arr [dim_data ] = attr_data
1307+
1308+ with tiledb .open (uri , "r" ) as arr :
1309+ expected_df = pd .DataFrame (
1310+ {"dim_a" : dim_data .tolist (), "rand" : attr_data .tolist ()}
1311+ )
1312+
1313+ assert_array_equal (arr .df [:], expected_df )
1314+ assert_array_equal (arr .df [pyarrow .array (dim_data )], expected_df )
1315+ assert_array_equal (arr .df [np .array (dim_data )], expected_df )
1316+
1317+ partial_dim_data = dim_data [:2 ]
1318+ expected_partial_df = expected_df .iloc [:2 ]
1319+
1320+ assert_array_equal (
1321+ arr .df [pyarrow .array (partial_dim_data )], expected_partial_df
1322+ )
1323+ assert_array_equal (arr .df [np .array (partial_dim_data )], expected_partial_df )
1324+
1325+ expected_dict = OrderedDict (
1326+ [("dim_a" , dim_data .tolist ()), ("rand" , attr_data .tolist ())]
1327+ )
1328+
12791329 def test_nullable_integers (self ):
12801330 nullable_int_dtypes = (
12811331 pd .Int64Dtype (),
0 commit comments