本文整理匯總了Python中IPython.core.ultratb.FormattedTB方法的典型用法代碼示例。如果您正苦於以下問題:Python ultratb.FormattedTB方法的具體用法?Python ultratb.FormattedTB怎麽用?Python ultratb.FormattedTB使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IPython.core.ultratb
的用法示例。
在下文中一共展示了ultratb.FormattedTB方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from IPython.core import ultratb [as 別名]
# 或者: from IPython.core.ultratb import FormattedTB [as 別名]
def __init__(self, config=None, ipython_dir=None, user_ns=None,
user_module=None, custom_exceptions=((),None),
usage=None, banner1=None, banner2=None,
display_banner=None, exit_msg=u'', user_global_ns=None):
if user_global_ns is not None:
warnings.warn("user_global_ns has been replaced by user_module. The\
parameter will be ignored.", DeprecationWarning)
super(InteractiveShellEmbed,self).__init__(
config=config, ipython_dir=ipython_dir, user_ns=user_ns,
user_module=user_module, custom_exceptions=custom_exceptions,
usage=usage, banner1=banner1, banner2=banner2,
display_banner=display_banner
)
self.exit_msg = exit_msg
# don't use the ipython crash handler so that user exceptions aren't
# trapped
sys.excepthook = ultratb.FormattedTB(color_scheme=self.colors,
mode=self.xmode,
call_pdb=self.pdb)
示例2: init_crash_handler
# 需要導入模塊: from IPython.core import ultratb [as 別名]
# 或者: from IPython.core.ultratb import FormattedTB [as 別名]
def init_crash_handler(self):
# Install minimal exception handling
sys.excepthook = FormattedTB(mode='Verbose', color_scheme='NoColor',
ostream=sys.__stdout__)
示例3: main
# 需要導入模塊: from IPython.core import ultratb [as 別名]
# 或者: from IPython.core.ultratb import FormattedTB [as 別名]
def main(_):
sys.excepthook = ultratb.FormattedTB(color_scheme='Linux', call_pdb=1)
pr = cProfile.Profile()
pr.enable()
run()
pr.disable()
pr.dump_stats('%s.profile' % os.path.basename(__file__))
示例4: __call__
# 需要導入模塊: from IPython.core import ultratb [as 別名]
# 或者: from IPython.core.ultratb import FormattedTB [as 別名]
def __call__(self, *args, **kwargs):
if self.instance is None:
from IPython.core import ultratb
self.instance = ultratb.FormattedTB(mode="Plain", color_scheme="Linux", call_pdb=1)
return self.instance(*args, **kwargs)
示例5: _excepthook
# 需要導入模塊: from IPython.core import ultratb [as 別名]
# 或者: from IPython.core.ultratb import FormattedTB [as 別名]
def _excepthook(self, etype, evalue, etb):
from IPython.core import ultratb
from mayo.util import import_from_string
ultratb.FormattedTB()(etype, evalue, etb)
for exc in self.get('system.pdb.skip', []):
exc = import_from_string(exc)
if issubclass(etype, exc):
sys.exit(-1)
if self.get('system.pdb.use', True):
import ipdb
ipdb.post_mortem(etb)
示例6: set_debugger_org
# 需要導入模塊: from IPython.core import ultratb [as 別名]
# 或者: from IPython.core.ultratb import FormattedTB [as 別名]
def set_debugger_org():
if not sys.excepthook == sys.__excepthook__:
from IPython.core import ultratb
sys.excepthook = ultratb.FormattedTB(call_pdb=True)
示例7: set_debugger_org_frc
# 需要導入模塊: from IPython.core import ultratb [as 別名]
# 或者: from IPython.core.ultratb import FormattedTB [as 別名]
def set_debugger_org_frc():
from IPython.core import ultratb
sys.excepthook = ultratb.FormattedTB(call_pdb=True)
示例8: enable_ipdb
# 需要導入模塊: from IPython.core import ultratb [as 別名]
# 或者: from IPython.core.ultratb import FormattedTB [as 別名]
def enable_ipdb():
# from <http://ipython.readthedocs.io/en/stable/interactive/reference.html#post-mortem-debugging>
from IPython.core import ultratb
sys.excepthook = ultratb.FormattedTB(mode='Verbose', color_scheme='Linux', call_pdb=1)
# handle environ
示例9: _enable_pdb
# 需要導入模塊: from IPython.core import ultratb [as 別名]
# 或者: from IPython.core.ultratb import FormattedTB [as 別名]
def _enable_pdb(): # pragma: no cover
"""Enable a Qt-aware IPython debugger."""
from IPython.core import ultratb
logger.debug("Enabling debugger.")
from PyQt5.QtCore import pyqtRemoveInputHook
pyqtRemoveInputHook()
sys.excepthook = ultratb.FormattedTB(mode='Verbose', color_scheme='Linux', call_pdb=True)
示例10: test_sparse_forward
# 需要導入模塊: from IPython.core import ultratb [as 別名]
# 或者: from IPython.core.ultratb import FormattedTB [as 別名]
def test_sparse_forward():
torch.manual_seed(0)
nBatch, nx, nineq, neq = 2, 5, 4, 3
def cast(m):
return m.cuda().double()
spTensor = torch.cuda.sparse.DoubleTensor
iTensor = torch.cuda.LongTensor
Qi = iTensor([range(nx), range(nx)])
Qv = cast(torch.ones(nBatch, nx))
Qsz = torch.Size([nx, nx])
Q0 = spTensor(Qi, Qv[0], Qsz)
Gi = iTensor([range(nineq), range(nineq)])
Gv = cast(torch.randn(nBatch, nineq))
Gsz = torch.Size([nineq, nx])
G0 = spTensor(Gi, Gv[0], Gsz)
h = cast(torch.randn(nBatch, nineq))
Ai = iTensor([range(neq), range(neq)])
Av = Gv[:, :neq].clone()
Asz = torch.Size([neq, nx])
A0 = spTensor(Ai, Av[0], Asz)
b = h[:, :neq].clone()
p = cast(torch.randn(nBatch, nx))
from IPython.core import ultratb
sys.excepthook = ultratb.FormattedTB(mode='Verbose',
color_scheme='Linux', call_pdb=1)
xhats0_cp = qpth.qp.QPFunction(solver=qpth.qp.QPSolvers.CVXPY)(
*[Variable(y) for y in
[Q0.to_dense(), p[0], G0.to_dense(), h[0], A0.to_dense(), b[0]]]).data.squeeze()
xhats, nus, lams, slacks = pdipm_spb.forward(Qi, Qv, Qsz, p, Gi, Gv, Gsz, h,
Ai, Av, Asz, b, verbose=-1,
notImprovedLim=3, maxIter=20)
npt.assert_allclose(xhats0_cp.cpu().numpy(),
xhats[0].cpu().numpy(), rtol=RTOL, atol=ATOL)
Qv, p, Gv, h, Av, b = [Variable(x) for x in [Qv, p, Gv, h, Av, b]]
xhats_qpf = qpth.qp.SpQPFunction(Qi, Qsz, Gi, Gsz, Ai, Asz)(
Qv, p, Gv, h, Av, b
).data
npt.assert_allclose(xhats.cpu().numpy(),
xhats_qpf.cpu().numpy(), rtol=RTOL, atol=ATOL)