本文整理汇总了Python中IPython.core.display.display方法的典型用法代码示例。如果您正苦于以下问题:Python display.display方法的具体用法?Python display.display怎么用?Python display.display使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPython.core.display
的用法示例。
在下文中一共展示了display.display方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: display
# 需要导入模块: from IPython.core import display [as 别名]
# 或者: from IPython.core.display import display [as 别名]
def display(self):
"""
Display this switchboard within an iPython notebook.
Calling this function requires that you are in an
iPython environment, and really only makes sense
within a notebook.
Returns
-------
None
"""
if not in_ipython_notebook():
raise ValueError('Only run `display` from inside an IPython Notebook.')
out = self.render("html")
content = "<script>\n" + \
"require(['jquery','jquery-UI'],function($,ui) {" + \
out['js'] + " });</script>" + out['html']
display_ipynb(content)
示例2: display_alert
# 需要导入模块: from IPython.core import display [as 别名]
# 或者: from IPython.core.display import display [as 别名]
def display_alert(
alert: Union[Mapping[str, Any], SecurityAlert], show_entities: bool = False
):
"""
Display a Security Alert.
Parameters
----------
alert : Union[Mapping[str, Any], SecurityAlert]
The alert to display as Mapping (e.g. pd.Series)
or SecurityAlert
show_entities : bool, optional
Whether to display entities (the default is False)
"""
output = format_alert(alert, show_entities)
if not isinstance(output, tuple):
output = [output]
for disp_obj in output:
display(disp_obj)
示例3: display_process_tree
# 需要导入模块: from IPython.core import display [as 别名]
# 或者: from IPython.core.display import display [as 别名]
def display_process_tree(process_tree: pd.DataFrame):
"""
Display process tree data frame. (Deprecated).
Parameters
----------
process_tree : pd.DataFrame
Process tree DataFrame
The display module expects the columns NodeRole and Level to
be populated. NoteRole is one of: 'source', 'parent', 'child'
or 'sibling'. Level indicates the 'hop' distance from the 'source'
node.
"""
build_and_show_process_tree(process_tree)
示例4: display_logon_data
# 需要导入模块: from IPython.core import display [as 别名]
# 或者: from IPython.core.display import display [as 别名]
def display_logon_data(
logon_event: pd.DataFrame, alert: SecurityAlert = None, os_family: str = None
):
"""
Display logon data for one or more events as HTML table.
Parameters
----------
logon_event : pd.DataFrame
Dataframe containing one or more logon events
alert : SecurityAlert, optional
obtain os_family from the security alert
(the default is None)
os_family : str, optional
explicitly specify os_family (Linux or Windows)
(the default is None)
Notes
-----
Currently only Windows Logon events.
"""
display(format_logon(logon_event, alert, os_family))
示例5: show
# 需要导入模块: from IPython.core import display [as 别名]
# 或者: from IPython.core.display import display [as 别名]
def show(close=None):
"""Show all figures as SVG/PNG payloads sent to the IPython clients.
Parameters
----------
close : bool, optional
If true, a ``plt.close('all')`` call is automatically issued after
sending all the figures. If this is set, the figures will entirely
removed from the internal list of figures.
"""
if close is None:
close = InlineBackend.instance().close_figures
try:
for figure_manager in Gcf.get_all_fig_managers():
display(figure_manager.canvas.figure)
finally:
show._to_draw = []
if close:
matplotlib.pyplot.close('all')
# This flag will be reset by draw_if_interactive when called
示例6: print_figure
# 需要导入模块: from IPython.core import display [as 别名]
# 或者: from IPython.core.display import display [as 别名]
def print_figure(fig, fmt='png'):
"""Convert a figure to svg or png for inline display."""
from matplotlib import rcParams
# When there's an empty figure, we shouldn't return anything, otherwise we
# get big blank areas in the qt console.
if not fig.axes and not fig.lines:
return
fc = fig.get_facecolor()
ec = fig.get_edgecolor()
bytes_io = BytesIO()
dpi = rcParams['savefig.dpi']
if fmt == 'retina':
dpi = dpi * 2
fmt = 'png'
fig.canvas.print_figure(bytes_io, format=fmt, bbox_inches='tight',
facecolor=fc, edgecolor=ec, dpi=dpi)
data = bytes_io.getvalue()
return data
示例7: ecc
# 需要导入模块: from IPython.core import display [as 别名]
# 或者: from IPython.core.display import display [as 别名]
def ecc(self, line, cell='', address=target_memory.shell_code):
"""Evaluate a 32-bit C++ expression on the target, and immediately start a console
To ensure we only display output that was generated during the command execution,
the console is sync'ed and unread output is discarded prior to running the command.
"""
d = self.shell.user_ns['d']
ConsoleBuffer(d).discard()
try:
return_value = evalc(d, line + cell, defines=all_defines(), includes=all_includes(), address=address, verbose=True)
except CodeError as e:
raise UsageError(str(e))
if return_value is not None:
display(return_value)
console_mainloop(d)
示例8: class_name
# 需要导入模块: from IPython.core import display [as 别名]
# 或者: from IPython.core.display import display [as 别名]
def class_name(self, class_name, indent=0):
"""Class name
Parameters
----------
class_name : str
Class name
indent : int
Amount of indention used for the line
Default value 0
Returns
-------
str
"""
return '<div class="label label-primary" ' \
'style="margin-bottom:5px;margin-top:5px;display:inline-block;' + self.get_margin(
indent=indent, include_style_attribute=False) + '">' + class_name + '</div>'
示例9: get_jupyter
# 需要导入模块: from IPython.core import display [as 别名]
# 或者: from IPython.core.display import display [as 别名]
def get_jupyter(self):
from IPython.core.display import HTML, Image, display
for b, result in self.result.items():
error = self.result[b]['else'] if 'else' in self.result[b] else None
if error:
display(HTML(error))
else:
# Show table
display(HTML(self.result[b]["Importance"]["table"]))
# Show plots
display(*list([Image(filename=d["figure"]) for d in self.result[b]['Marginals'].values()]))
display(*list([Image(filename=d["figure"]) for d in self.result[b]['Pairwise Marginals'].values()]))
# While working for a prettier solution, this might be an option:
# display(HTML(figure_to_html([d["figure"] for d in self.result[b]['Marginals'].values()] +
# [d["figure"] for d in self.result[b]['Pairwise Marginals'].values()],
# max_in_a_row=3, true_break_between_rows=True)))
示例10: show_values
# 需要导入模块: from IPython.core import display [as 别名]
# 或者: from IPython.core.display import display [as 别名]
def show_values(self, pb=False, gui=False, **kargs):
from .utils import html_table, aa_table
html = True
if 'html' in kargs:
html = kargs['html']
del kargs['html']
if gui:
from pySPM.tools import values_display
Vals = self.get_values(pb, nest=True, **kargs)
values_display.show_values(Vals)
else:
Vals = self.get_values(pb, **kargs)
Table = [["Parameter Name", "Value @start", "Value @end"]]
for x in Vals:
Table.append(tuple([x]+Vals[x]))
if not html:
print(aa_table(Table, header=True))
else:
from IPython.core.display import display, HTML
res = html_table(Table, header=True)
display(HTML(res))
示例11: draw_graph
# 需要导入模块: from IPython.core import display [as 别名]
# 或者: from IPython.core.display import display [as 别名]
def draw_graph(self):
"""Draw pywr schematic graph in a jupyter notebook"""
js = draw_graph_template.render(
graph=self.graph,
width=self.width,
height=self.height,
element="element",
labels=self.labels,
attributes=self.attributes,
css=self.css.replace("\n", "")
)
display(Javascript(data=js))
示例12: save_graph
# 需要导入模块: from IPython.core import display [as 别名]
# 或者: from IPython.core.display import display [as 别名]
def save_graph(self, filename, save_unfixed=False, filetype="json"):
"""Save a copy of the model JSON with update schematic positions.
When run in a jupyter notebook this will trigger a download.
Parameters
----------
filename: str
The name of the file to save the output data to.
save_unfixed: bool
If True, then all node position are saved to output file. If False, only nodes who have had their position
fixed in the d3 graph have their positions saved.
filetype: str
Should be either 'json' to save the model data with updated node positions to a JSON file or 'csv' to save
node positions to a csv file.
"""
if filetype not in ["json", "csv"]:
warnings.warn(f"Output filetype '{filetype}' not recognised. Please use either 'json' or 'csv'</p>",
stacklevel=2)
if self.json is None and filetype == "json":
warnings.warn("Node positions cannot be saved to JSON if PywrSchematic object has been instantiated using "
"a pywr model object. Please use a JSON file path or model dict instead.", stacklevel=2)
else:
display(Javascript(save_graph_template.render(
model_data=json.dumps(self.json),
height=self.height,
width=self.width,
save_unfixed=json.dumps(save_unfixed),
filename=json.dumps(filename),
filetype=json.dumps(filetype)
)))
示例13: display_ipynb
# 需要导入模块: from IPython.core import display [as 别名]
# 或者: from IPython.core.display import display [as 别名]
def display_ipynb(content):
"""Render HTML content to an IPython notebook cell display"""
from IPython.core.display import display, HTML
display(HTML(content))
示例14: _makefactory
# 需要导入模块: from IPython.core import display [as 别名]
# 或者: from IPython.core.display import display [as 别名]
def _makefactory(self, cls, autodisplay): # , printer=_objs.VerbosityPrinter(1)):
# XXX this indirection is so wild -- can we please rewrite directly?
#Manipulate argument list of cls.__init__
argspec = _inspect.getargspec(cls.__init__)
argnames = argspec[0]
assert(argnames[0] == 'self' and argnames[1] == 'ws'), \
"__init__ must begin with (self, ws, ...)"
factoryfn_argnames = argnames[2:] # strip off self & ws args
newargspec = (factoryfn_argnames,) + argspec[1:]
#Define a new factory function with appropriate signature
signature = _inspect.formatargspec(
formatvalue=lambda val: "", *newargspec)
signature = signature[1:-1] # strip off parenthesis from ends of "(signature)"
if autodisplay:
factory_func_def = (
'def factoryfn(%(signature)s):\n'
' ret = cls(self, %(signature)s); ret.display(); return ret' %
{'signature': signature})
else:
factory_func_def = (
'def factoryfn(%(signature)s):\n'
' return cls(self, %(signature)s)' %
{'signature': signature})
#print("FACTORY FN DEF = \n",new_func)
exec_globals = {'cls': cls, 'self': self}
exec(factory_func_def, exec_globals)
factoryfn = exec_globals['factoryfn']
#Copy cls.__init__ info over to factory function
factoryfn.__name__ = cls.__init__.__name__
factoryfn.__doc__ = cls.__init__.__doc__
factoryfn.__module__ = cls.__init__.__module__
factoryfn.__dict__ = cls.__init__.__dict__
factoryfn.__defaults__ = cls.__init__.__defaults__
return factoryfn
示例15: _form_text_js
# 需要导入模块: from IPython.core import display [as 别名]
# 或者: from IPython.core.display import display [as 别名]
def _form_text_js(self, textID, text_html, switchboard_init_js):
content = ""
if switchboard_init_js: content += switchboard_init_js
queue_math_render = bool(text_html and '$' in text_html
and self.options.get('render_math', True))
if text_html is not None:
init_text_js = (
'el = $("#{textid}");\n'
'if(el.hasClass("pygsti-wsoutput-group")) {{\n'
' el.children("div.single_switched_value").each( function(i,el){{\n'
' CollapsibleLists.applyTo( $(el).find("ul").first()[0] );\n'
' }});\n'
'}} else if(el.hasClass("single_switched_value")){{\n'
' CollapsibleLists.applyTo(el[0]);\n'
'}}\n'
'caption = el.closest("figure").children("figcaption:first");\n'
'caption.css("width", Math.round(el.width()*0.9) + "px");\n'
).format(textid=textID)
else:
init_text_js = "" # no per-div init needed
if queue_math_render:
# then there is math text that needs rendering,
# so queue this, *then* trigger plot creation
content += (' plotman.enqueue(function() {{ \n'
' renderMathInElement(document.getElementById("{textID}"), {{ delimiters: [\n'
' {{left: "$$", right: "$$", display: true}},\n'
' {{left: "$", right: "$", display: false}},\n'
' ] }} );\n').format(textID=textID)
content += init_text_js
content += ' }}, "Rendering math in {textID}" );\n'.format(textID=textID) # end enqueue
else:
content += init_text_js
return self._create_onready_handler(content, textID)