You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For best results, initiate chat on the files or code changes.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
python3 - <<'EOF'import astimport osimport sysfrom pathlib import Pathdef find_duplicates_in_list(elements): seen = [] dupes = [] for i, el in enumerate(elements): key = ast.dump(el) for j, (prev_key, prev_idx) in enumerate(seen): if key == prev_key: dupes.append((prev_idx, i)) break else: seen.append((key, i)) return dupesresults = []for path in Path("tests").rglob("*.py"): try: src = path.read_text(errors="replace") tree = ast.parse(src, filename=str(path)) except SyntaxError: continue for node in ast.walk(tree): if not isinstance(node, ast.Assign): continue for target in node.targets: if not isinstance(target, ast.Name): continue name = target.id if "TEST" not in name.upper() and "CASES" not in name.upper() and "PARAMS" not in name.upper(): continue val = node.value if not isinstance(val, ast.List): continue elems = val.elts if len(elems) < 2: continue dupes = find_duplicates_in_list(elems) if dupes: results.append((str(path), name, dupes))for fpath, varname, dupes in sorted(results): for (i, j) in dupes: print(f"{fpath} {varname} indices {i} and {j} are identical")if not results: print("No duplicates found.")EOF
Length of output: 16409
@ericspod Here's the full list of files with byte-identical duplicate entries in their test case lists:
tests/data/test_pil_reader.py — TEST_CASE_1 through TEST_CASE_6
tests/data/utils/test_decollate.py — test_case
handlers/
tests/handlers/test_handler_checkpoint_saver.py — TEST_CASE_1 through TEST_CASE_8 (many cross-index duplicates — likely worth a separate look; the list entries may be intentional combinations of primitives)
The test_handler_checkpoint_saver.py cases are likely combining shared primitive values intentionally (not pure parametrize duplicates), so worth manually verifying those. The rest look like straightforward cleanup candidates similar to this PR.
Tip
For best results, initiate chat on the files or code changes.
🧩 Analysis chain
🏁 Script executed:
Length of output: 16409
@ericspodHere's the full list of files with byte-identical duplicate entries in their test case lists:apps/
tests/apps/deepgrow/test_deepgrow_dataset.py—TEST_CASE_4,TEST_CASE_5tests/apps/detection/utils/test_detector_utils.py—TEST_CASE_3tests/apps/pathology/transforms/post/test_generate_succinct_contour.py—TEST_CASE_1tests/apps/pathology/transforms/post/test_generate_succinct_contourd.py—TEST_CASE_1bundle/
tests/bundle/test_bundle_ckpt_export.py—TEST_CASE_1tests/bundle/test_bundle_trt_export.py—TEST_CASE_1,TEST_CASE_2data/
tests/data/test_arraydataset.py—TEST_CASE_1/2/3,test_labelstests/data/test_lmdbdataset.py—TEST_CASE_3tests/data/test_nrrd_reader.py—TEST_CASE_1throughTEST_CASE_8(indices 0 and 2 identical in each)tests/data/test_persistentdataset.py—TEST_CASE_4/5/6/7tests/data/test_pil_reader.py—TEST_CASE_1throughTEST_CASE_6tests/data/utils/test_decollate.py—test_casehandlers/
tests/handlers/test_handler_checkpoint_saver.py—TEST_CASE_1throughTEST_CASE_8(many cross-index duplicates — likely worth a separate look; the list entries may be intentional combinations of primitives)tests/handlers/test_handler_hausdorff_distance.py—TEST_SAMPLE_2,TEST_SAMPLE_4tests/handlers/test_handler_surface_distance.py—TEST_SAMPLE_2,TEST_SAMPLE_4inferers/
tests/inferers/test_patch_inferer.py— 9 differentTEST_CASE_*variables (indices 0 and 3 identical in each)metrics/
tests/metrics/test_calibration_metric.py—TEST_VALUE_1B1Cnetworks/
tests/networks/blocks/test_mlp.py,test_se_blocks.py,test_selfattention.py—test_casetests/networks/layers/test_savitzky_golay_filter.py—TEST_CASE_1D_REP,TEST_CASE_SINGLE_VALUE_REPtests/networks/nets/test_ahnet.py— 5 casestests/networks/nets/test_autoencoder.py—TEST_CASE_0/1/2tests/networks/nets/test_autoencoderkl.py—CASES_ATTENTIONtests/networks/nets/test_cell_sam_wrapper.py,test_fullyconnectednet.py,test_spade_autoencoderkl.py,test_varautoencoder.py,test_vnet.py,test_voxelmorph.pytests/networks/test_save_state.py—TEST_CASE_6,TEST_CASE_10transforms/
tests/transforms/test_border_pad.py,test_border_padd.pytests/transforms/test_center_spatial_crop.pytests/transforms/test_cucim_dict_transform.py,test_cucim_transform.py(and rand variants)tests/transforms/test_fill_holes.py,test_fill_holesd.py— 8 cases eachtests/transforms/test_load_image.py— 5 casestests/transforms/test_rand_torchio.py,test_rand_torchiod.py,test_torchio.py,test_torchiod.pytests/transforms/test_savitzky_golay_smooth.py,test_savitzky_golay_smoothd.pytests/transforms/test_spatial_padd.pyThe
test_handler_checkpoint_saver.pycases are likely combining shared primitive values intentionally (not pure parametrize duplicates), so worth manually verifying those. The rest look like straightforward cleanup candidates similar to this PR.Originally posted by @coderabbitai[bot] in #8896 (comment)