本文整理汇总了Python中IPython.core.magic.Magics方法的典型用法代码示例。如果您正苦于以下问题:Python magic.Magics方法的具体用法?Python magic.Magics怎么用?Python magic.Magics使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPython.core.magic
的用法示例。
在下文中一共展示了magic.Magics方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cell_magic_class
# 需要导入模块: from IPython.core import magic [as 别名]
# 或者: from IPython.core.magic import Magics [as 别名]
def test_cell_magic_class(self):
"Cell magics declared via a class"
@magics_class
class MyMagics(Magics):
@cell_magic
def cellm3(self, line, cell):
return line, cell
_ip.register_magics(MyMagics)
self.check_ident('cellm3')
示例2: test_cell_magic_class2
# 需要导入模块: from IPython.core import magic [as 别名]
# 或者: from IPython.core.magic import Magics [as 别名]
def test_cell_magic_class2(self):
"Cell magics declared via a class, #2"
@magics_class
class MyMagics2(Magics):
@cell_magic('cellm4')
def cellm33(self, line, cell):
return line, cell
_ip.register_magics(MyMagics2)
self.check_ident('cellm4')
# Check that nothing is registered as 'cellm33'
c33 = _ip.find_cell_magic('cellm33')
nt.assert_equal(c33, None)
示例3: __init__
# 需要导入模块: from IPython.core import magic [as 别名]
# 或者: from IPython.core.magic import Magics [as 别名]
def __init__(self, shell, *kw):
magic.Magics.__init__(self, shell, *kw)
# Hex output mode
self.hex_mode = True
formatter = self.shell.display_formatter.formatters['text/plain']
formatter.for_type(int, self.int_formatter)
示例4: op_eq
# 需要导入模块: from IPython.core import magic [as 别名]
# 或者: from IPython.core.magic import Magics [as 别名]
def op_eq(actual: Any, given: Any) -> bool:
return actual == given
# only for function in Magics class
# FIXME: inherit documentation (maybe by functools.wraps)
# TODO: is there same way to get line_magic name instead of manually setting?