diff --git a/NeuroFlex/scientific_domains/xarray_integration.py b/NeuroFlex/scientific_domains/xarray_integration.py index 4691c8b..a8921bb 100644 --- a/NeuroFlex/scientific_domains/xarray_integration.py +++ b/NeuroFlex/scientific_domains/xarray_integration.py @@ -70,4 +70,29 @@ def save_dataset(self, dataset_name, file_path): self.datasets[dataset_name].to_netcdf(file_path) print(f"Dataset '{dataset_name}' saved to {file_path}") + def load_dataset(self, file_path, dataset_name=None): + """ + Load a dataset from a NetCDF file and register it in the datasets dictionary. + + Args: + file_path (str): Path to the NetCDF file to load. + dataset_name (str, optional): Name to assign to the loaded dataset. + If not provided, the filename (without extension) will be used. + + Returns: + xarray.Dataset: The loaded dataset. + + Raises: + IOError: If there's an error loading the file. + """ + try: + dataset = xr.open_dataset(file_path) + if dataset_name is None: + dataset_name = file_path.split('/')[-1].split('.')[0] + self.datasets[dataset_name] = dataset + print(f"Dataset loaded from {file_path} and registered as '{dataset_name}'") + return dataset + except Exception as e: + raise IOError(f"Error loading dataset from {file_path}: {str(e)}") + # Additional methods can be added here as needed diff --git a/tests/ai_ethics/test_security_integration.py b/tests/ai_ethics/test_security_integration.py index 9d9047b..404e3dc 100644 --- a/tests/ai_ethics/test_security_integration.py +++ b/tests/ai_ethics/test_security_integration.py @@ -91,7 +91,6 @@ def test_perform_security_check(self, mock_agent): self.assertEqual(report, mock_report) mock_agent.return_value.security_check.assert_called_once() - @unittest.skip("Skipping due to issues with bioinformatics data loading") @patch('NeuroFlex.ai_ethics.advanced_security_agent.AdvancedSecurityAgent') def test_security_integration_in_training(self, mock_agent): mock_agent.return_value.security_check.return_value = None