Skip to content

Commit 4d3354d

Browse files
jucorclaude
andcommitted
Address Copilot review: drop unused cache, validate --runs, tighten type assert
- Remove unused group_vote_matrices dict (comment 3) - Validate --runs >= 1 in benchmark script (comment 4) - Tighten correlation type check to exact `float` (comment 5) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 97b8c32 commit 4d3354d

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

delphi/polismath/conversation/conversation.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -793,17 +793,15 @@ def _compute_participant_info_optimized(self, vote_matrix: pd.DataFrame, group_c
793793

794794
# OPTIMIZATION 3: Precompute group vote matrices and average votes
795795

796-
# Precompute group vote matrices and their valid comment masks
797-
group_vote_matrices = {}
796+
# Precompute group average votes and valid comment masks
798797
group_avg_votes = {}
799798
group_valid_masks = {}
800-
799+
801800
for group_id, member_indices in group_member_indices.items():
802801
if len(member_indices) >= 3: # Only calculate for groups with enough members
803802
# Extract the group vote matrix
804803
group_vote_matrix = matrix_values[member_indices, :]
805-
group_vote_matrices[group_id] = group_vote_matrix
806-
804+
807805
# Calculate average votes per comment for this group
808806
group_avg_votes[group_id] = np.mean(group_vote_matrix, axis=0)
809807

delphi/scripts/benchmark_participant_info.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,12 @@ def main():
211211
parser = argparse.ArgumentParser(description="Benchmark participant info: old loop vs vectorized")
212212
parser.add_argument('--include-local', action='store_true', help="Include private datasets")
213213
parser.add_argument('--datasets', type=str, default=None, help="Comma-separated dataset names")
214-
parser.add_argument('--runs', type=int, default=3, help="Number of runs per implementation")
214+
parser.add_argument('--runs', type=int, default=3, help="Number of runs per implementation (>=1)")
215215
args = parser.parse_args()
216216

217+
if args.runs < 1:
218+
parser.error("--runs must be a positive integer (got %d)" % args.runs)
219+
217220
all_datasets = discover_datasets(include_local=args.include_local)
218221
valid = [name for name, info in all_datasets.items() if info.is_valid]
219222

delphi/tests/test_participant_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def test_stats_value_types(self):
546546
assert type(s["n_pass"]) is int
547547
assert type(s["n_votes"]) is int
548548
for gid, corr in s["group_correlations"].items():
549-
assert isinstance(corr, (float, np.floating)), (
549+
assert type(corr) is float, (
550550
f"corr for pid={pid}, gid={gid} is {type(corr)}"
551551
)
552552

0 commit comments

Comments
 (0)