declare_deferred_modules_as_importable
(function from pyomo.common.dependencies)
- pyomo.common.dependencies.declare_deferred_modules_as_importable(globals_dict)[source]
DEPRECATED.
Make all
DeferredImportModulesinglobals_dictimportableThis function will go throughout the specified
globals_dictdictionary and add any instances ofDeferredImportModulethat it finds (and any of their deferred submodules) tosys.modulesso that the modules can be imported through theglobals_dictnamespace.For example,
pyomo/common/dependencies.pydeclares:>>> scipy, scipy_available = attempt_import( ... 'scipy', callback=_finalize_scipy, ... deferred_submodules=['stats', 'sparse', 'spatial', 'integrate']) >>> declare_deferred_modules_as_importable(globals()) WARNING: DEPRECATED: ...
Which enables users to use:
>>> import pyomo.common.dependencies.scipy.sparse as spa
If the deferred import has not yet been triggered, then the
DeferredImportModuleis returned and namedspa. However, if the import has already been triggered, thenspawill either be thescipy.sparsemodule, or aModuleUnavailableinstance.Deprecated since version 6.7.2:
declare_deferred_modules_as_importable()is deprecated. Use thedeclare_modules_as_importablecontext manager.