@@ -65,17 +65,22 @@ def test_getitem_array_one_column(fancy_test_array: FancyTestArray):
6565
6666def test_getitem_array_multiple_columns (fancy_test_array : FancyTestArray ):
6767 columns = ["id" , "test_int" , "test_float" ]
68- assert fancy_test_array .data [columns ].tolist () == fancy_test_array [columns ].tolist ()
69- assert_array_equal (fancy_test_array [columns ].dtype .names , ("id" , "test_int" , "test_float" ))
68+ assert_array_equal (fancy_test_array .data [columns ].dtype .names , ("id" , "test_int" , "test_float" ))
7069
7170
72- def test_getitem_unique_multiple_columns (fancy_test_array : FancyTestArray ):
73- columns = ["id" , "test_int" , "test_float" ]
74- assert np .array_equal (np .unique (fancy_test_array [columns ]), fancy_test_array [columns ])
71+ def test_getitem_array_index (fancy_test_array : FancyTestArray ):
72+ assert fancy_test_array [0 ].data .tolist () == fancy_test_array .data [0 :1 ].tolist ()
73+
74+
75+ def test_getitem_array_nested_index (fancy_test_array : FancyTestArray ):
76+ nested_array = fancy_test_array [0 ][0 ][0 ][0 ][0 ][0 ]
77+ assert isinstance (nested_array , FancyArray )
78+ assert nested_array .data .shape == (1 ,)
79+ assert nested_array .data .tolist () == fancy_test_array .data [0 :1 ].tolist ()
7580
7681
7782def test_getitem_array_slice (fancy_test_array : FancyTestArray ):
78- assert fancy_test_array . data [0 :2 ].tolist () == fancy_test_array [0 :2 ].tolist ()
83+ assert fancy_test_array [0 :2 ].data . tolist () == fancy_test_array . data [0 :2 ].tolist ()
7984
8085
8186def test_getitem_with_array_mask (fancy_test_array : FancyTestArray ):
@@ -86,19 +91,19 @@ def test_getitem_with_array_mask(fancy_test_array: FancyTestArray):
8691
8792def test_getitem_with_tuple_mask (fancy_test_array : FancyTestArray ):
8893 mask = (True , False , True )
89- assert isinstance ( fancy_test_array [ mask ], FancyArray )
90- assert np . array_equal ( fancy_test_array . data [mask ], fancy_test_array [ mask ]. data )
94+ with pytest . raises ( NotImplementedError ):
95+ fancy_test_array [mask ] # type: ignore[call-overload] # noqa
9196
9297
9398def test_getitem_with_list_mask (fancy_test_array : FancyTestArray ):
9499 mask = [True , False , True ]
95- assert isinstance ( fancy_test_array [ mask ], FancyArray )
96- assert np . array_equal ( fancy_test_array . data [mask ], fancy_test_array [ mask ]. data )
100+ with pytest . raises ( NotImplementedError ):
101+ fancy_test_array [mask ] # type: ignore[call-overload] # noqa
97102
98103
99104def test_getitem_with_empty_list_mask ():
100105 array = FancyTestArray ()
101- mask = []
106+ mask = np . array ([], dtype = bool )
102107 assert isinstance (array [mask ], FancyArray )
103108 assert np .array_equal (array .data [mask ], array [mask ].data )
104109
@@ -233,16 +238,16 @@ def test_unique_return_counts_and_inverse(fancy_test_array: FancyTestArray):
233238
234239
235240def test_sort (fancy_test_array : FancyTestArray ):
236- assert_array_equal (fancy_test_array . test_float , [4.0 , 4.0 , 1.0 ])
237- fancy_test_array .sort (order = "test_float" )
238- assert_array_equal (fancy_test_array . test_float , [1.0 , 4.0 , 4.0 ])
241+ assert_array_equal (fancy_test_array [ " test_float" ] , [4.0 , 4.0 , 1.0 ])
242+ fancy_test_array .data . sort (order = "test_float" )
243+ assert_array_equal (fancy_test_array [ " test_float" ] , [1.0 , 4.0 , 4.0 ])
239244
240245
241246def test_copy_function (fancy_test_array : FancyTestArray ):
242247 array_copy = copy (fancy_test_array )
243- array_copy . test_int = 123
248+ array_copy [ " test_int" ] = 123
244249 assert not id (fancy_test_array ) == id (array_copy )
245- assert not fancy_test_array . test_int [0 ] == array_copy . test_int [0 ]
250+ assert not fancy_test_array [ " test_int" ] [0 ] == array_copy [ " test_int" ] [0 ]
246251
247252
248253def test_copy_method (fancy_test_array : FancyTestArray ):
@@ -302,4 +307,4 @@ def test_from_extended_array():
302307
303308 array = LineArray .from_extended (extended_array )
304309 assert not isinstance (array , ExtendedLineArray )
305- array_equal_with_nan (array .data , extended_array [array .columns ])
310+ array_equal_with_nan (array .data , extended_array . data [array .columns ])
0 commit comments