-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1844 from DKilkenny/notebooks
Added detection of notebook env, table formatting and in cell HTML output
- Loading branch information
Showing
8 changed files
with
268 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"""Checking for interactive notebook mode.""" | ||
from openmdao.utils.general_utils import simple_warning | ||
|
||
try: | ||
from tabulate import tabulate | ||
except ImportError: | ||
tabulate = None | ||
|
||
|
||
def notebook_mode(): | ||
""" | ||
Check if the environment is interactive and if tabulate is installed. | ||
Returns | ||
------- | ||
bool | ||
True if the environment is an interactive notebook. | ||
""" | ||
ipy = False | ||
try: | ||
from IPython import get_ipython | ||
ipy = get_ipython() is not None | ||
except ImportError: | ||
pass | ||
|
||
if ipy and tabulate is None: | ||
simple_warning("Tabulate is not installed run `pip install openmdao[notebooks]` to " | ||
"install required dependencies. Using ASCII for outputs.") | ||
return ipy | ||
|
||
|
||
notebook = notebook_mode() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.