Spaces:
Running on Zero
Running on Zero
copilot-swe-agent[bot] raylim commited on
Commit ·
6fcc1b9
1
Parent(s): 8f383ed
Address code review feedback: add deterministic seeds and improve mocks
Browse filesFiles changed (3)
62 unmodified lines6364656667686970717273747576777878 unmodified lines15715815916016116215 unmodified lines17817918018118218362 unmodified lines@pytest.fixturedef sample_features(self):"""Create sample features for testing."""return np.random.rand(100, 768).astype(np.float32)@pytest.fixturedef large_features(self):"""Create large sample features for testing padding/truncation."""return np.random.rand(25000, 768).astype(np.float32)@pytest.fixturedef small_features(self):"""Create small sample features for testing padding."""return np.random.rand(50, 768).astype(np.float32)def test_dataset_initialization(self, sample_features):78 unmodified linesdef test_features_exact_size(self):"""Test that features of exactly n_max_tiles are not modified."""n_max_tiles = 100features = np.random.rand(n_max_tiles, 768).astype(np.float32)dataset = TileFeatureTensorDataset(15 unmodified linesdef test_different_feature_dimensions(self):"""Test dataset with different feature dimensions."""for dim in [256, 512, 768, 1024]:features = np.random.rand(100, dim).astype(np.float32)dataset = TileFeatureTensorDataset(62 unmodified lines6364656667686970717273747576777879808178 unmodified lines16016116216316416516615 unmodified lines18218318418518618718862 unmodified lines@pytest.fixturedef sample_features(self):"""Create sample features for testing."""np.random.seed(42)return np.random.rand(100, 768).astype(np.float32)@pytest.fixturedef large_features(self):"""Create large sample features for testing padding/truncation."""np.random.seed(42)return np.random.rand(25000, 768).astype(np.float32)@pytest.fixturedef small_features(self):"""Create small sample features for testing padding."""np.random.seed(42)return np.random.rand(50, 768).astype(np.float32)def test_dataset_initialization(self, sample_features):78 unmodified linesdef test_features_exact_size(self):"""Test that features of exactly n_max_tiles are not modified."""np.random.seed(42)n_max_tiles = 100features = np.random.rand(n_max_tiles, 768).astype(np.float32)dataset = TileFeatureTensorDataset(15 unmodified linesdef test_different_feature_dimensions(self):"""Test dataset with different feature dimensions."""np.random.seed(42)for dim in [256, 512, 768, 1024]:features = np.random.rand(100, dim).astype(np.float32)dataset = TileFeatureTensorDataset(
156 unmodified lines15715815916016116222 unmodified lines185186187188189190156 unmodified linesdef test_logits_to_point_estimates_shape(self):"""Test that output shape is correct."""# logits shape: (batch_size, 2 * n_tasks)batch_size = 4n_tasks = 5logits = torch.rand(batch_size, 2 * n_tasks)22 unmodified linesdef test_logits_to_point_estimates_multiple_batches(self):"""Test with multiple batches."""logits = torch.rand(10, 8) # 10 batches, 4 tasksresult = logits_to_point_estimates(logits)assert result.shape == (10, 4)156 unmodified lines15715815916016116216322 unmodified lines186187188189190191192156 unmodified linesdef test_logits_to_point_estimates_shape(self):"""Test that output shape is correct."""# logits shape: (batch_size, 2 * n_tasks)torch.manual_seed(42)batch_size = 4n_tasks = 5logits = torch.rand(batch_size, 2 * n_tasks)22 unmodified linesdef test_logits_to_point_estimates_multiple_batches(self):"""Test with multiple batches."""torch.manual_seed(42)logits = torch.rand(10, 8) # 10 batches, 4 tasksresult = logits_to_point_estimates(logits)assert result.shape == (10, 4)
176 unmodified lines177178179180181182183184185186176 unmodified lines"""Test that invalid code returns 'Unknown'."""from mosaic.gradio_app import get_oncotree_code_name, oncotree_code_map# Mock the requests.get call to return 404mock_response = mocker.Mock()mock_response.status_code = 404mock_response.json.return_value = []mocker.patch("requests.get", return_value=mock_response)# Clear cache and use an invalid code176 unmodified lines177178179180181182183184185186176 unmodified lines"""Test that invalid code returns 'Unknown'."""from mosaic.gradio_app import get_oncotree_code_name, oncotree_code_map# Mock the requests.get call to return empty response (no matching codes)mock_response = mocker.Mock()mock_response.status_code = 200mock_response.json.return_value = [] # Empty list means no matching codes foundmocker.patch("requests.get", return_value=mock_response)# Clear cache and use an invalid code
tests/inference/test_data.py+5
tests/inference/test_paladin.py+2
tests/test_gradio_app.py+3-3