本文整理汇总了Python中IPython.display.display方法的典型用法代码示例。如果您正苦于以下问题:Python display.display方法的具体用法?Python display.display怎么用?Python display.display使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPython.display
的用法示例。
在下文中一共展示了display.display方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print_board
# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import display [as 别名]
def print_board(self):
"""
Print the board with the help of pandas DataFrame..
Well it sounds stupid.. anyway, it has a nice display, right?
:return:
"""
df_pr = [[None for i in range(self.board_size)] for j in range(self.board_size)]
pd.options.display.max_columns = 10
pd.options.display.max_rows = 1000
pd.options.display.width = 1000
for i in range(self.board_size):
for j in range(self.board_size):
need_to_pass = False
for rune in self.rune_list: # Print the rune if present
if j == rune.x and i == rune.y:
# print(rune, end=' ')
df_pr[i][j] = "Rune"
need_to_pass = True
pass
if not need_to_pass:
if self.board[j][i] is not None and self.board[j][i].dead == False:
df_pr[i][j] = self.board[j][i].__repr__()
else:
df_pr[i][j] = "Nones"
display(pd.DataFrame(df_pr))
示例2: run_next_cells
# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import display [as 别名]
def run_next_cells(n):
if n=='all':
n = 'NaN'
elif n<1:
return
js_code = """
var num = {0};
var run = false;
var current = $(this)[0];
$.each(IPython.notebook.get_cells(), function (idx, cell) {{
if ((cell.output_area === current) && !run) {{
run = true;
}} else if ((cell.cell_type == 'code') && !(num < 1) && run) {{
cell.execute();
num = num - 1;
}}
}});
""".format(n)
display(Javascript(js_code))
示例3: drawMolsByLabel
# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import display [as 别名]
def drawMolsByLabel(topicModel, label, idLabelToMatch=0, baseRad=0.5, molSize=(250,150),\
numRowsShown=3, tableHeader='', maxMols=100):
result = generateMoleculeSVGsbyLabel(topicModel, label, idLabelToMatch=idLabelToMatch,baseRad=baseRad,\
molSize=molSize, maxMols=maxMols)
if len(result) == 1:
print(result)
return
svgs, namesSVGs = result
finalsvgs = []
for svg in svgs:
# make the svg scalable
finalsvgs.append(svg.replace('<svg','<svg preserveAspectRatio="xMinYMin meet" viewBox="0 0 '+str(molSize[0])\
+' '+str(molSize[1])+'"'))
return display(HTML(utilsDrawing.drawSVGsToHTMLGrid(finalsvgs[:maxMols],cssTableName='overviewTab',tableHeader='Molecules of '+str(label),
namesSVGs=namesSVGs[:maxMols], size=molSize, numRowsShown=numRowsShown, numColumns=4)))
# produces a svg grid of the molecules of a certain label and highlights the most probable topic
示例4: drawMolsByTopic
# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import display [as 别名]
def drawMolsByTopic(topicModel, topicIdx, idsLabelToShow=[0], topicProbThreshold = 0.5, baseRad=0.5, molSize=(250,150),\
numRowsShown=3, color=(.0,.0, 1.), maxMols=100):
result = generateMoleculeSVGsbyTopicIdx(topicModel, topicIdx, idsLabelToShow=idsLabelToShow, \
topicProbThreshold = topicProbThreshold, baseRad=baseRad,\
molSize=molSize,color=color, maxMols=maxMols)
if len(result) == 1:
print(result)
return
svgs, namesSVGs = result
finalsvgs = []
for svg in svgs:
# make the svg scalable
finalsvgs.append(svg.replace('<svg','<svg preserveAspectRatio="xMinYMin meet" viewBox="0 0 '+str(molSize[0])\
+' '+str(molSize[1])+'"'))
tableHeader = 'Molecules in topic '+str(topicIdx)+' (sorted by decending probability)'
return display(HTML(utilsDrawing.drawSVGsToHTMLGrid(finalsvgs[:maxMols],cssTableName='overviewTab',tableHeader=tableHeader,\
namesSVGs=namesSVGs[:maxMols], size=molSize, numRowsShown=numRowsShown, numColumns=4)))
# produces a svg grid of the molecules belonging to a certain topic and highlights this topic within the molecules
示例5: _run_action
# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import display [as 别名]
def _run_action(self):
"""Run any action function and display details, if any."""
output_objs = self.alert_action(self.selected_alert)
if output_objs is None:
return
if not isinstance(output_objs, (tuple, list)):
output_objs = [output_objs]
display_objs = bool(self._disp_elems)
for idx, out_obj in enumerate(output_objs):
if not display_objs:
self._disp_elems.append(
display(out_obj, display_id=f"{self._output_id}_{idx}")
)
else:
if idx == len(self._disp_elems):
break
self._disp_elems[idx].update(out_obj)
示例6: _check_config
# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import display [as 别名]
def _check_config() -> Tuple[bool, Optional[Tuple[List[str], List[str]]]]:
config_ok = True
err_warn = None
mp_path = os.environ.get("MSTICPYCONFIG", "./msticpyconfig.yaml")
if not Path(mp_path).exists():
display(HTML(_MISSING_MPCONFIG_ERR))
else:
err_warn = validate_config(config_file=mp_path)
if err_warn and err_warn[0]:
config_ok = False
ws_config = WorkspaceConfig()
if not ws_config.config_loaded:
print("No valid configuration for Azure Sentinel found.")
config_ok = False
return config_ok, err_warn
示例7: _imp_from_package
# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import display [as 别名]
def _imp_from_package(
nm_spc: Dict[str, Any], pkg: str, tgt: str = None, alias: str = None
):
"""Import object or submodule from `pkg`."""
if not tgt:
return _imp_module(nm_spc=nm_spc, module_name=pkg, alias=alias)
try:
# target could be a module
obj = importlib.import_module(f".{tgt}", pkg)
except (ImportError, ModuleNotFoundError):
# if not, it must be an attribute (class, func, etc.)
try:
mod = importlib.import_module(pkg)
except ImportError:
display(HTML(_IMPORT_MODULE_MSSG.format(module=pkg)))
raise
obj = getattr(mod, tgt)
if alias:
nm_spc[alias] = obj
else:
nm_spc[tgt] = obj
if _VERBOSE(): # type: ignore
print(f"{tgt} imported from {pkg} (alias={alias})")
return obj
示例8: visualize_statistics
# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import display [as 别名]
def visualize_statistics(
lhs_statistics: statistics_pb2.DatasetFeatureStatisticsList,
rhs_statistics: Optional[
statistics_pb2.DatasetFeatureStatisticsList] = None,
lhs_name: Text = 'lhs_statistics',
rhs_name: Text = 'rhs_statistics') -> None:
"""Visualize the input statistics using Facets.
Args:
lhs_statistics: A DatasetFeatureStatisticsList protocol buffer.
rhs_statistics: An optional DatasetFeatureStatisticsList protocol buffer to
compare with lhs_statistics.
lhs_name: Name of the lhs_statistics dataset.
rhs_name: Name of the rhs_statistics dataset.
Raises:
TypeError: If the input argument is not of the expected type.
ValueError: If the input statistics protos does not have only one dataset.
"""
html = get_statistics_html(lhs_statistics, rhs_statistics, lhs_name, rhs_name)
display(HTML(html))
示例9: autosave
# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import display [as 别名]
def autosave(self, arg_s):
"""Set the autosave interval in the notebook (in seconds).
The default value is 120, or two minutes.
``%autosave 0`` will disable autosave.
This magic only has an effect when called from the notebook interface.
It has no effect when called in a startup file.
"""
try:
interval = int(arg_s)
except ValueError:
raise UsageError("%%autosave requires an integer, got %r" % arg_s)
# javascript wants milliseconds
milliseconds = 1000 * interval
display(Javascript("IPython.notebook.set_autosave_interval(%i)" % milliseconds),
include=['application/javascript']
)
if interval:
print("Autosaving every %i seconds" % interval)
else:
print("Autosave disabled")
示例10: plot_durations
# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import display [as 别名]
def plot_durations():
plt.figure(2)
plt.clf()
durations_t = torch.tensor(episode_durations, dtype=torch.float)
plt.title('Training...')
plt.xlabel('Episode')
plt.ylabel('Duration')
plt.plot(durations_t.numpy())
# Take 100 episode averages and plot them too
if len(durations_t) >= 100:
means = durations_t.unfold(0, 100, 1).mean(1).view(-1)
means = torch.cat((torch.zeros(99), means))
plt.plot(means.numpy())
plt.pause(0.001)
if is_ipython:
display.clear_output(wait=True)
display.display(plt.gcf())
#%% Training loop
示例11: int_or_float_format_func
# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import display [as 别名]
def int_or_float_format_func(num, prec=3):
"""
Identify whether the number is float or integer. When displaying
integers, use no decimal. For a float, round to the specified
number of decimal places. Return as a string.
Parameters:
-----------
num : float or int
The number to format and display.
prec : int, optional
The number of decimal places to display if x is a float.
Defaults to 3.
Returns:
-------
ans : str
The formatted string representing the given number.
"""
if float.is_integer(num):
ans = '{}'.format(int(num))
else:
ans = float_format_func(num, prec=prec)
return ans
示例12: __init__
# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import display [as 别名]
def __init__(self, project):
self._ref_path = project.path
self.project = project.copy()
self.project._inspect_mode = True
self.parent = None
self.name = None
self.fig, self.ax = None, None
self.w_group = None
self.w_node = None
self.w_file = None
self.w_text = None
self.w_tab = None
self.w_path = None
self.w_type = None
# self.fig, self.ax = plt.subplots()
self.create_widgets()
self.connect_widgets()
self.display()
示例13: check_render_options
# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import display [as 别名]
def check_render_options(**options):
"""
Context manager that will assert that alt.renderers.options are equivalent
to the given options in the IPython.display.display call
"""
import IPython.display
def check_options(obj):
assert alt.renderers.options == options
_display = IPython.display.display
IPython.display.display = check_options
try:
yield
finally:
IPython.display.display = _display
示例14: visit
# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import display [as 别名]
def visit(path, key, value):
if isinstance(value, dict) and "display" in value:
return key, value["display"]
return key not in ["value", "unit"]
示例15: pretty
# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import display [as 别名]
def pretty(self, attrs='class="table"'):
return display(
HTML(j2h.convert(json=remap(self, visit=visit), table_attributes=attrs))
)