def print_source(obj): source = format_source(obj) if is_jupyter(): from IPython.display import display, Code display(source) else: print(source)
def source_repr(obj): source = format_source(obj) if is_jupyter(): display(source) return '' else: return source
def source_repr(obj): source = format_source(obj) if is_jupyter(): from IPython.display import display, Code display(source) return '' else: return source
def __init__(self, grid, bounding_box=([0, 0], [1, 1]), codim=2, backend=None, block=False): assert grid.reference_element in (triangle, square) assert grid.dim == 2 assert codim in (0, 2) backend = backend or ('jupyter' if is_jupyter() else None) self.__auto_init(locals())
def format_source(obj): source = getsource(obj) if is_jupyter(): from IPython.display import display, Code return Code(source, language='python') else: try: from pygments import highlight from pygments.lexers import PythonLexer from pygments.formatters import Terminal256Formatter return highlight(source, PythonLexer(), Terminal256Formatter()) except ImportError: return source
def print_source(obj): source = format_source(obj) if is_jupyter(): display(source) else: print(source)
def __init__(self, grid, codim=1, block=False, backend=None): assert isinstance(grid, OnedGrid) assert codim in (0, 1) backend = backend or ('jupyter' if is_jupyter() else None) self.__auto_init(locals())