-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
printversion #698
printversion #698
Conversation
There are more options. You can get the html-table as plain text with How many columns are used can be set with Additional packages can be provided via |
Codecov Report
@@ Coverage Diff @@
## master #698 +/- ##
==========================================
+ Coverage 72.88% 72.99% +0.11%
==========================================
Files 110 111 +1
Lines 16667 16787 +120
==========================================
+ Hits 12147 12254 +107
- Misses 4520 4533 +13
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really cool! This will be really helpful for reproducibility.
__all__ = ['versions', 'versions_html', 'versions_text'] | ||
|
||
|
||
def versions(mode='print', add_pckg=None, ncol=4): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if changing the default here depending on if you are in IPython or not?
def versions(mode='html' if IPython else 'print', add_pckg=None, ncol=4):
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you mean mode='HTML'
, which returns the rendered table (mode='html'
returns the actual html-code).
You can, but I think is better not to. You would have to make sure you are in an Jupyter Notebook, because otherwise you could also be in an IPython console, and the mode='HTML'
cannot render.
Also, what speaks for having mode='print'
is that this looks OK in a notebook too, it would just print it as in the console. So this is the only mode that always works nicely. If there is a nice and easy trick though to ensure if you are in a Jupyter notebook then it could be a good idea, indeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually wanted to do this by default, return HTML
if in Notebook, and not otherwise. But I could not figure out a good, foolproof way of distinguishing if you are in an Jupyter Notebook, in an IPython console, or in a Qt console. If you know a good way let me know!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, yeah it doesn't seem to be trivial to check if you are in a notebook or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had another look at this, and I could not find a good way. You could distinguish between an IPython Console and a Jupyter Notebook, but not between a Qt Console and a Jupyter Notebook. But the Qt Console cannot render the HTML
mode either. So I think sticking with mode='print'
as default is the safest option in whatever environment someone is using SimPEG
.
…ils directory on travis, add version to the notebook-styled examples
use travis wait in the docs build
Printversion revisions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @prisae! I will wait until the recent round of tests finishes and we can bring this in 🎉
SimPEG/Utils/printinfo.py
Outdated
(Jupyter notebook, IPython console, Python console, QT console), either as | ||
html-table (notebook) or as plain text (anywhere). | ||
|
||
This script is an adapted version of ``empymod.printversions``, which itself |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you like to include a like to the empymod docs here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, as I put links as well for ipynbtools.py
and watermar.py
. I'll add https://empymod.github.io
.
__all__ = ['versions', 'versions_html', 'versions_text'] | ||
|
||
|
||
def versions(mode='print', add_pckg=None, ncol=4): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, yeah it doesn't seem to be trivial to check if you are in a notebook or not
>>> versions('plain', pytest) # Provide additional package | ||
>>> versions('HTML', [pytest, dateutil], ncol=5) # HTML | ||
|
||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all of the docs!!
As I had done for `ipynbtools.py` and `watermark.py`.
I first go at
versions
. Fixes #697 .Please have a look, feedback welcome!