from pr #769
commits from @prisae
review from @lheagy
Replace func versions by class Versions
Turns out that there is a way to have html in a notebook and non-html in all the rest without even checking if you are in a notebook or not (thanks @banesullivan; https://github.com/simpeg/discretize/issues/142).
All that is needed is a Versions -class which has the right functions linked to __repr__ and _repr_html_ :
class Versions:
def __init__(self, add_pckg=None, ncol=4):
self.add_pckg = add_pckg
self.ncol = ncol
def __repr__(self):
return versions_text(self.add_pckg)
def _repr_html_(self):
return versions_html(self.add_pckg, self.ncol)
By removing the old functions, respectively integrating the relevant parts into the new class, the whole version printing utility gets a lot simpler (however, it is not backwards compatible).
Before, you had to do
from SimPEG import versions
versions()
in Python, IPython etc, and in Jupyter
from SimPEG import versions
versions('HTML')
Updating your code
Now, you simply do
from SimPEG import Versions
Versions()
EVERYWHERE (note the uppercase V ), and it will automatically print a html table in a notebook, and plain text everywhere else.