Skip to content

Commit b5e554d

Browse files
docxologyclaude
andcommitted
fix: resolve integration test failures for network scalability and simulation ecology
- Fix create_network() call passing node names instead of edge tuples - Fix random.Random vs numpy.RandomState type mismatch in generate_random_dna calls - Add missing import for random module Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4c74d7f commit b5e554d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

tests/test_integration_comprehensive.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from __future__ import annotations
1010

11+
import random
1112
import tempfile
1213
from pathlib import Path
1314

@@ -366,12 +367,12 @@ def test_simulation_ecology_integration(self):
366367
# Simulate genetic sequences for species
367368
species_sequences = {}
368369
for species_idx in range(min(5, n_species)): # Just first 5 species
369-
base_sequence = generate_random_dna(50, rng=np.random.RandomState(species_idx + 100))
370+
base_sequence = generate_random_dna(50, rng=random.Random(species_idx + 100))
370371

371372
# Add mutations for population diversity
372373
mutated_sequences = []
373374
for _ in range(3): # 3 individuals per species
374-
mutated = mutate_sequence(base_sequence, n_mut=2, rng=np.random.RandomState(species_idx * 10 + _))
375+
mutated = mutate_sequence(base_sequence, n_mut=2, rng=random.Random(species_idx * 10 + _))
375376
mutated_sequences.append(mutated)
376377

377378
species_sequences[f"Species_{species_idx}"] = mutated_sequences
@@ -519,18 +520,20 @@ def test_network_scalability(self):
519520
n_nodes = 10 # Very small for reliable execution
520521
node_names = [f"Node_{i}" for i in range(n_nodes)]
521522

522-
network = create_network(node_names)
523+
# Create edges for a ring network
524+
edges = [(node_names[i], node_names[(i + 1) % n_nodes]) for i in range(n_nodes)]
525+
network = create_network(edges)
523526

524-
# Add a few edges to create a connected network
525-
edges = [(0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 9), (0, 9)]
526-
for i, j in edges:
527+
# Add a few more weighted edges
528+
extra_edges = [(0, 5), (2, 7), (3, 8)]
529+
for i, j in extra_edges:
527530
weight = np.random.uniform(0.1, 1.0)
528-
network.add_edge(node_names[i], node_names[j], weight)
531+
network.add_edge(node_names[i], node_names[j], weight=weight)
529532

530533
# Should handle small networks
531534
metrics = network_metrics(network)
532535
assert metrics["num_nodes"] == n_nodes
533-
assert metrics["num_edges"] == len(edges)
536+
assert metrics["num_edges"] == len(edges) + len(extra_edges)
534537

535538
# Skip community detection for now as it's too slow
536539
# communities = detect_communities(network, method="greedy", seed=42)

0 commit comments

Comments
 (0)