當前位置: 首頁>>代碼示例>>Python>>正文


Python ultratb.FormattedTB方法代碼示例

本文整理匯總了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) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:25,代碼來源:embed.py

示例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__) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:6,代碼來源:kernelapp.py

示例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__)) 
開發者ID:uzh-rpg,項目名稱:imips_open,代碼行數:9,代碼來源:train.py

示例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) 
開發者ID:jcyk,項目名稱:gtos,代碼行數:7,代碼來源:exception_hook.py

示例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) 
開發者ID:deep-fry,項目名稱:mayo,代碼行數:13,代碼來源:config.py

示例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) 
開發者ID:mil-tokyo,項目名稱:MCD_DA,代碼行數:6,代碼來源:util.py

示例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) 
開發者ID:mil-tokyo,項目名稱:MCD_DA,代碼行數:5,代碼來源:util.py

示例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 
開發者ID:statgen,項目名稱:pheweb,代碼行數:8,代碼來源:command_line.py

示例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) 
開發者ID:cortex-lab,項目名稱:phy,代碼行數:9,代碼來源:profiling.py

示例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) 
開發者ID:locuslab,項目名稱:qpth,代碼行數:51,代碼來源:test.py


注:本文中的IPython.core.ultratb.FormattedTB方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。