Optimized renaming of test parameter ids (#6350)
Optimized renaming of test parameter ids
This commit is contained in:
commit
8be9684ab2
1
AUTHORS
1
AUTHORS
|
@ -235,6 +235,7 @@ Samuele Pedroni
|
||||||
Sankt Petersbug
|
Sankt Petersbug
|
||||||
Segev Finer
|
Segev Finer
|
||||||
Serhii Mozghovyi
|
Serhii Mozghovyi
|
||||||
|
Seth Junot
|
||||||
Simon Gomizelj
|
Simon Gomizelj
|
||||||
Skylar Downes
|
Skylar Downes
|
||||||
Srinivas Reddy Thatiparthy
|
Srinivas Reddy Thatiparthy
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Optimized automatic renaming of test parameter IDs.
|
|
@ -6,6 +6,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
|
from collections import defaultdict
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
|
@ -1190,14 +1191,23 @@ def idmaker(argnames, parametersets, idfn=None, ids=None, config=None, item=None
|
||||||
_idvalset(valindex, parameterset, argnames, idfn, ids, config=config, item=item)
|
_idvalset(valindex, parameterset, argnames, idfn, ids, config=config, item=item)
|
||||||
for valindex, parameterset in enumerate(parametersets)
|
for valindex, parameterset in enumerate(parametersets)
|
||||||
]
|
]
|
||||||
if len(set(ids)) != len(ids):
|
|
||||||
# The ids are not unique
|
# All IDs must be unique!
|
||||||
duplicates = [testid for testid in ids if ids.count(testid) > 1]
|
unique_ids = set(ids)
|
||||||
counters = Counter()
|
if len(unique_ids) != len(ids):
|
||||||
for index, testid in enumerate(ids):
|
|
||||||
if testid in duplicates:
|
# Record the number of occurrences of each test ID
|
||||||
ids[index] = testid + str(counters[testid])
|
test_id_counts = Counter(ids)
|
||||||
counters[testid] += 1
|
|
||||||
|
# Map the test ID to its next suffix
|
||||||
|
test_id_suffixes = defaultdict(int)
|
||||||
|
|
||||||
|
# Suffix non-unique IDs to make them unique
|
||||||
|
for index, test_id in enumerate(ids):
|
||||||
|
if test_id_counts[test_id] > 1:
|
||||||
|
ids[index] = "{}{}".format(test_id, test_id_suffixes[test_id])
|
||||||
|
test_id_suffixes[test_id] += 1
|
||||||
|
|
||||||
return ids
|
return ids
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue