@@ -208,6 +208,32 @@ def test_filter_by_ids():
208208 )
209209
210210
211+ def test_filter_by_ids_reset_ids ():
212+ """Test that reset_ids parameter resets IDs to consecutive integers starting from 0"""
213+ instance = ArrayWithIds (** ARRAY_WITH_IDS_ARRAYS_OF_FLOAT_VALUES_CONFIG_NON_CONSECUTIVE )
214+ # Filter to keep only first and third elements (ids 2 and 6)
215+ instance .filter_by_ids ([2 , 6 ], reset_ids = True )
216+
217+ # Values should be filtered correctly
218+ assert instance .values == [
219+ ARRAY_WITH_IDS_ARRAYS_OF_FLOAT_VALUES_CONFIG_NON_CONSECUTIVE ["values" ][0 ],
220+ ARRAY_WITH_IDS_ARRAYS_OF_FLOAT_VALUES_CONFIG_NON_CONSECUTIVE ["values" ][2 ],
221+ ]
222+ # IDs should be reset to consecutive integers starting from 0
223+ assert instance .ids == [0 , 1 ]
224+
225+ # Test with invert=True
226+ instance = ArrayWithIds (** ARRAY_WITH_IDS_ARRAYS_OF_FLOAT_VALUES_CONFIG_NON_CONSECUTIVE )
227+ # Filter to exclude first element (id 2), keep second and third (ids 4, 6)
228+ instance .filter_by_ids ([2 ], invert = True , reset_ids = True )
229+
230+ assert instance .values == [
231+ ARRAY_WITH_IDS_ARRAYS_OF_FLOAT_VALUES_CONFIG_NON_CONSECUTIVE ["values" ][1 ],
232+ ARRAY_WITH_IDS_ARRAYS_OF_FLOAT_VALUES_CONFIG_NON_CONSECUTIVE ["values" ][2 ],
233+ ]
234+ assert instance .ids == [0 , 1 ]
235+
236+
211237def test_filter_by_ids_invert ():
212238 instance = ArrayWithIds (** ARRAY_WITH_IDS_ARRAYS_OF_FLOAT_VALUES_CONFIG )
213239 instance .filter_by_ids ([0 , 2 ], invert = True )
0 commit comments