optional
Optional dependencies, and saying clearly what to install when one is missing.
Plotting and mesh handling are a small part of what chmpy does, but they carry
most of its install weight, so they are optional extras rather than hard
requirements. Everything that needs them imports through here, which keeps the
failure a sentence telling you what to install rather than a bare
ModuleNotFoundError raised somewhere deep in a call stack.
have(module)
pyplot(purpose='plotting')
require(module, purpose=None)
Import an optional module, or explain how to install it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
the module to import, e.g. "matplotlib.pyplot" |
required | |
purpose
|
what the caller wanted it for, used in the error message |
None
|
Returns:
| Type | Description |
|---|---|
|
the imported module |
Raises:
| Type | Description |
|---|---|
ImportError
|
with the pip command that would fix it |