ContentsFoundations to FrontierBezhig

ai-lab/m01_autograd/tests/_impl.py

All lab code. Download this file.

"""Loads the code under test.

By default the tests import YOUR files from m01_autograd/. The AILAB_IMPL
environment variable points them at another folder instead, so a second
implementation can be run against the same tests. You never need to set it.
"""
import importlib
import os
import sys
from pathlib import Path

LAB_DIR = Path(__file__).resolve().parents[1]
IMPL_DIR = Path(os.environ.get("AILAB_IMPL") or LAB_DIR).resolve()
if str(IMPL_DIR) not in sys.path:
    sys.path.insert(0, str(IMPL_DIR))


def load(name):
    """Import engine, gradcheck, nn, or train from the folder under test."""
    return importlib.import_module(name)