"""The core: the equations YOU write, one file per topic, checked by each lab's tests.Every file in this folder starts as docstrings only. Its module docstring namesthe lab steps that fill it in. The rest of the engine (the design loader, thereport, the CAD boundary) calls these functions through `load`, so the reportshows "not written yet" until your code exists, and uses your code once it does.`load` has one extra job. When the environment variable ENGLAB_IMPL names afolder, it imports <name>.py from that folder instead of from here. That switchruns a second implementation against the same tests; you never need it."""from__future__importannotationsimportimportlibimportimportlib.utilimportosimportsysfrompathlibimportPathfromtypesimportModuleType_cache:dict[tuple[str,str],ModuleType]={}defload(name:str)->ModuleType:"""Return the core module `name` (for example "hover"): yours, or ENGLAB_IMPL's."""impl=os.environ.get("ENGLAB_IMPL")ifnotimpl:returnimportlib.import_module(f"hwe.core.{name}")key=(impl,name)ifkeynotin_cache:path=Path(impl).resolve()/f"{name}.py"spec=importlib.util.spec_from_file_location(f"englab_impl_{name}",path)ifspecisNoneorspec.loaderisNone:raiseImportError(f"ENGLAB_IMPL has no {name}.py: {path}")module=importlib.util.module_from_spec(spec)sys.modules[spec.name]=modulespec.loader.exec_module(module)_cache[key]=modulereturn_cache[key]defwritten(func,*args,**kwargs)->bool:"""True if calling func does not raise NotImplementedError (used by the report)."""try:func(*args,**kwargs)exceptNotImplementedError:returnFalseexceptException:returnTruereturnTrue