Module neuralops.tests.test_imports

Basic tests for the trainer module.

Tests core trainer functionality including model initialization, training setup, and results management.

Classes

class TestConfigModule
Expand source code
class TestConfigModule:
    """Test suite for configuration module."""

    def test_config_imports(self):
        """Test that Config classes can be imported."""
        try:
            from neuralops.config import Config, load_config
            assert Config is not None
            assert load_config is not None
        except ImportError as e:
            pytest.fail(f"Failed to import config: {e}")

    def test_config_initialization(self):
        """Test Config can be initialized."""
        try:
            from neuralops.config import Config
            cfg = Config()
            assert cfg is not None
            assert hasattr(cfg, "model")
            assert hasattr(cfg, "training")
            assert hasattr(cfg, "hardware")
        except ImportError:
            pytest.skip("torch not installed")
        except Exception as e:
            pytest.fail(f"Config initialization failed: {e}")

Test suite for configuration module.

Methods

def test_config_imports(self)
Expand source code
def test_config_imports(self):
    """Test that Config classes can be imported."""
    try:
        from neuralops.config import Config, load_config
        assert Config is not None
        assert load_config is not None
    except ImportError as e:
        pytest.fail(f"Failed to import config: {e}")

Test that Config classes can be imported.

def test_config_initialization(self)
Expand source code
def test_config_initialization(self):
    """Test Config can be initialized."""
    try:
        from neuralops.config import Config
        cfg = Config()
        assert cfg is not None
        assert hasattr(cfg, "model")
        assert hasattr(cfg, "training")
        assert hasattr(cfg, "hardware")
    except ImportError:
        pytest.skip("torch not installed")
    except Exception as e:
        pytest.fail(f"Config initialization failed: {e}")

Test Config can be initialized.

class TestDataModule
Expand source code
class TestDataModule:
    """Test suite for data loading module."""

    def test_data_imports(self):
        """Test that data loading components can be imported."""
        try:
            from neuralops.data import (DataConfig, TaskType,
                                        create_dataloader, preprocess_function)
            assert DataConfig is not None
            assert TaskType is not None
            assert callable(preprocess_function)
            assert callable(create_dataloader)
        except ImportError as e:
            pytest.fail(f"Failed to import data components: {e}")

Test suite for data loading module.

Methods

def test_data_imports(self)
Expand source code
def test_data_imports(self):
    """Test that data loading components can be imported."""
    try:
        from neuralops.data import (DataConfig, TaskType,
                                    create_dataloader, preprocess_function)
        assert DataConfig is not None
        assert TaskType is not None
        assert callable(preprocess_function)
        assert callable(create_dataloader)
    except ImportError as e:
        pytest.fail(f"Failed to import data components: {e}")

Test that data loading components can be imported.

class TestFrameworkImports
Expand source code
class TestFrameworkImports:
    """Test that all critical framework packages can be imported."""

    def test_core_module(self):
        """Test core module imports."""
        try:
            import neuralops.core
            assert framework.core is not None
        except ImportError as e:
            pytest.fail(f"Failed to import neuralops.core: {e}")

    def test_attentions_module(self):
        """Test attentions module imports."""
        try:
            import neuralops.attentions
            assert framework.attentions is not None
        except ImportError:
            # torch may not be installed
            pytest.skip("torch not installed")

    def test_compression_engine_module(self):
        """Test compression engine module imports."""
        try:
            import neuralops.compression_engine
            assert framework.compression_engine is not None
        except ImportError:
            pytest.skip("torch not installed")

    def test_router_module(self):
        """Test router module imports."""
        try:
            import neuralops.router
            assert framework.router is not None
        except ImportError as e:
            pytest.fail(f"Failed to import neuralops.router: {e}")

    def test_visualization_module(self):
        """Test visualization module imports."""
        try:
            import neuralops.visualization
            assert framework.visualization is not None
        except ImportError:
            pytest.skip("torch not installed")

Test that all critical framework packages can be imported.

Methods

def test_attentions_module(self)
Expand source code
def test_attentions_module(self):
    """Test attentions module imports."""
    try:
        import neuralops.attentions
        assert framework.attentions is not None
    except ImportError:
        # torch may not be installed
        pytest.skip("torch not installed")

Test attentions module imports.

def test_compression_engine_module(self)
Expand source code
def test_compression_engine_module(self):
    """Test compression engine module imports."""
    try:
        import neuralops.compression_engine
        assert framework.compression_engine is not None
    except ImportError:
        pytest.skip("torch not installed")

Test compression engine module imports.

def test_core_module(self)
Expand source code
def test_core_module(self):
    """Test core module imports."""
    try:
        import neuralops.core
        assert framework.core is not None
    except ImportError as e:
        pytest.fail(f"Failed to import neuralops.core: {e}")

Test core module imports.

def test_router_module(self)
Expand source code
def test_router_module(self):
    """Test router module imports."""
    try:
        import neuralops.router
        assert framework.router is not None
    except ImportError as e:
        pytest.fail(f"Failed to import neuralops.router: {e}")

Test router module imports.

def test_visualization_module(self)
Expand source code
def test_visualization_module(self):
    """Test visualization module imports."""
    try:
        import neuralops.visualization
        assert framework.visualization is not None
    except ImportError:
        pytest.skip("torch not installed")

Test visualization module imports.

class TestTrainerModule
Expand source code
class TestTrainerModule:
    """Test suite for trainer module imports and basic functionality."""

    def test_trainer_imports(self):
        """Test that all trainer components can be imported."""
        try:
            from neuralops.trainer import (HuggingFaceTrainer, MemoryCallback,
                                           ResultsManager, TimeCallback,
                                           get_task_metrics)
            assert HuggingFaceTrainer is not None
            assert ResultsManager is not None
            assert get_task_metrics is not None
            assert MemoryCallback is not None
            assert TimeCallback is not None
        except ImportError as e:
            pytest.fail(f"Failed to import trainer components: {e}")

    def test_trainer_methods_imports(self):
        """Test that trainer methods can be imported."""
        try:
            from neuralops.trainer.methods import available_methods, get_method
            assert callable(get_method)
            assert callable(available_methods)
        except ImportError as e:
            pytest.fail(f"Failed to import trainer methods: {e}")

    def test_results_manager_initialization(self):
        """Test ResultsManager can be initialized with basic config."""
        try:
            from neuralops.trainer import ResultsManager
            rm = ResultsManager(
                experiment_name="test_exp",
                base_dir="/tmp/test_results",
                config={}
            )
            assert rm is not None
            assert rm.experiment_name == "test_exp"
        except ImportError:
            pytest.skip("torch not installed")
        except Exception as e:
            pytest.fail(f"ResultsManager initialization failed: {e}")

Test suite for trainer module imports and basic functionality.

Methods

def test_results_manager_initialization(self)
Expand source code
def test_results_manager_initialization(self):
    """Test ResultsManager can be initialized with basic config."""
    try:
        from neuralops.trainer import ResultsManager
        rm = ResultsManager(
            experiment_name="test_exp",
            base_dir="/tmp/test_results",
            config={}
        )
        assert rm is not None
        assert rm.experiment_name == "test_exp"
    except ImportError:
        pytest.skip("torch not installed")
    except Exception as e:
        pytest.fail(f"ResultsManager initialization failed: {e}")

Test ResultsManager can be initialized with basic config.

def test_trainer_imports(self)
Expand source code
def test_trainer_imports(self):
    """Test that all trainer components can be imported."""
    try:
        from neuralops.trainer import (HuggingFaceTrainer, MemoryCallback,
                                       ResultsManager, TimeCallback,
                                       get_task_metrics)
        assert HuggingFaceTrainer is not None
        assert ResultsManager is not None
        assert get_task_metrics is not None
        assert MemoryCallback is not None
        assert TimeCallback is not None
    except ImportError as e:
        pytest.fail(f"Failed to import trainer components: {e}")

Test that all trainer components can be imported.

def test_trainer_methods_imports(self)
Expand source code
def test_trainer_methods_imports(self):
    """Test that trainer methods can be imported."""
    try:
        from neuralops.trainer.methods import available_methods, get_method
        assert callable(get_method)
        assert callable(available_methods)
    except ImportError as e:
        pytest.fail(f"Failed to import trainer methods: {e}")

Test that trainer methods can be imported.