python的display显示_Python display.display方法代码示例

本文整理汇总了Python中IPython.display.display方法的典型用法代码示例。如果您正苦于以下问题:Python display.display方法的具体用法?Python display.display怎么用?Python display.display使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块IPython.display的用法示例。

在下文中一共展示了display.display方法的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: print_board

​点赞 6

# 需要导入模块: 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))

开发者ID:haryoa,项目名称:evo-pawness,代码行数:27,

示例2: run_next_cells

​点赞 6

# 需要导入模块: 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))

开发者ID:ioam,项目名称:paramnb,代码行数:23,

示例3: drawMolsByLabel

​点赞 6

# 需要导入模块: 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('

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

开发者ID:rdkit,项目名称:CheTo,代码行数:22,

示例4: drawMolsByTopic

​点赞 6

# 需要导入模块: 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('

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

开发者ID:rdkit,项目名称:CheTo,代码行数:24,

示例5: _run_action

​点赞 6

# 需要导入模块: 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)

开发者ID:microsoft,项目名称:msticpy,代码行数:19,

示例6: _check_config

​点赞 6

# 需要导入模块: 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

开发者ID:microsoft,项目名称:msticpy,代码行数:18,

示例7: _imp_from_package

​点赞 6

# 需要导入模块: 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

开发者ID:microsoft,项目名称:msticpy,代码行数:26,

示例8: visualize_statistics

​点赞 6

# 需要导入模块: 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))

开发者ID:tensorflow,项目名称:data-validation,代码行数:23,

示例9: autosave

​点赞 6

# 需要导入模块: 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")

开发者ID:ktraunmueller,项目名称:Computable,代码行数:26,

示例10: plot_durations

​点赞 6

# 需要导入模块: 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

开发者ID:gutouyu,项目名称:ML_CIA,代码行数:22,

示例11: int_or_float_format_func

​点赞 6

# 需要导入模块: 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

开发者ID:EducationalTestingService,项目名称:rsmtool,代码行数:27,

示例12: __init__

​点赞 6

# 需要导入模块: 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()

开发者ID:pyiron,项目名称:pyiron,代码行数:21,

示例13: check_render_options

​点赞 6

# 需要导入模块: 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

开发者ID:altair-viz,项目名称:altair,代码行数:18,

示例14: visit

​点赞 5

# 需要导入模块: 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"]

开发者ID:materialsproject,项目名称:MPContribs,代码行数:6,

示例15: pretty

​点赞 5

# 需要导入模块: 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))

)

开发者ID:materialsproject,项目名称:MPContribs,代码行数:6,

示例16: get_project

​点赞 5

# 需要导入模块: from IPython import display [as 别名]

# 或者: from IPython.display import display [as 别名]

def get_project(self, project):

"""Convenience function to get full project entry and display as HTML table"""

return Dict(self.projects.get_entry(pk=project, _fields=["_all"]).result())

开发者ID:materialsproject,项目名称:MPContribs,代码行数:5,

示例17: get_contribution

​点赞 5

# 需要导入模块: from IPython import display [as 别名]

# 或者: from IPython.display import display [as 别名]

def get_contribution(self, cid):

"""Convenience function to get full contribution entry and display as HTML table"""

return Dict(self.contributions.get_entry(pk=cid, _fields=["_all"]).result())

开发者ID:materialsproject,项目名称:MPContribs,代码行数:5,

示例18: _show_attention

​点赞 5

# 需要导入模块: from IPython import display [as 别名]

# 或者: from IPython.display import display [as 别名]

def _show_attention(att_json):

display.display(display.HTML(vis_html))

display.display(display.Javascript('window.attention = %s' % att_json))

display.display(display.Javascript(vis_js))

开发者ID:akzaidi,项目名称:fine-lm,代码行数:6,

示例19: render

​点赞 5

# 需要导入模块: from IPython import display [as 别名]

# 或者: from IPython.display import display [as 别名]

def render(self, episode: int = None, max_episodes: int = None,

step: int = None, max_steps: int = None,

price_history: pd.DataFrame = None, net_worth: pd.Series = None,

performance: pd.DataFrame = None, trades: 'OrderedDict' = None

):

if price_history is None:

raise ValueError("render() is missing required positional argument 'price_history'.")

if net_worth is None:

raise ValueError("render() is missing required positional argument 'net_worth'.")

if performance is None:

raise ValueError("render() is missing required positional argument 'performance'.")

if trades is None:

raise ValueError("render() is missing required positional argument 'trades'.")

if not self.fig:

self._create_figure(performance.keys())

if self._show_chart: # ensure chart visibility through notebook cell reruns

display(self.fig)

self._show_chart = False

self.fig.layout.title = self._create_log_entry(episode, max_episodes, step, max_steps)

self._price_chart.update(dict(

open=price_history['open'],

high=price_history['high'],

low=price_history['low'],

close=price_history['close']

))

self.fig.layout.annotations += self._create_trade_annotations(trades, price_history)

self._volume_chart.update({'y': price_history['volume']})

for trace in self.fig.select_traces(row=3):

trace.update({'y': performance[trace.name]})

self._net_worth_chart.update({'y': net_worth})

开发者ID:tensortrade-org,项目名称:tensortrade,代码行数:41,

示例20: precision

​点赞 5

# 需要导入模块: from IPython import display [as 别名]

# 或者: from IPython.display import display [as 别名]

def precision(self):

return self._precision or pd.get_option('display.precision') - 1

开发者ID:quantopian,项目名称:qgrid,代码行数:4,

示例21: set_defaults

​点赞 5

# 需要导入模块: from IPython import display [as 别名]

# 或者: from IPython.display import display [as 别名]

def set_defaults(show_toolbar=None,

precision=None,

grid_options=None,

column_options=None):

"""

Set the default qgrid options. The options that you can set here are the

same ones that you can pass into ``QgridWidget`` constructor, with the

exception of the ``df`` option, for which a default value wouldn't be

particularly useful (since the purpose of qgrid is to display a DataFrame).

See the documentation for ``QgridWidget`` for more information.

Notes

-----

This function will be useful to you if you find yourself

setting the same options every time you create a QgridWidget. Calling

this ``set_defaults`` function once sets the options for the lifetime of

the kernel, so you won't have to include the same options every time you

instantiate a ``QgridWidget``.

See Also

--------

QgridWidget :

The widget whose default behavior is changed by ``set_defaults``.

"""

defaults.set_defaults(show_toolbar=show_toolbar,

precision=precision,

grid_options=grid_options,

column_options=column_options)

开发者ID:quantopian,项目名称:qgrid,代码行数:31,

示例22: _display_as_qgrid

​点赞 5

# 需要导入模块: from IPython import display [as 别名]

# 或者: from IPython.display import display [as 别名]

def _display_as_qgrid(data):

display(show_grid(data))

开发者ID:quantopian,项目名称:qgrid,代码行数:4,

示例23: enable

​点赞 5

# 需要导入模块: from IPython import display [as 别名]

# 或者: from IPython.display import display [as 别名]

def enable(dataframe=True, series=True):

"""

Automatically use qgrid to display all DataFrames and/or Series

instances in the notebook.

Parameters

----------

dataframe : bool

Whether to automatically use qgrid to display DataFrames instances.

series : bool

Whether to automatically use qgrid to display Series instances.

"""

try:

from IPython.core.getipython import get_ipython

except ImportError:

raise ImportError('This feature requires IPython 1.0+')

ip = get_ipython()

ip_formatter = ip.display_formatter.ipython_display_formatter

if dataframe:

ip_formatter.for_type(pd.DataFrame, _display_as_qgrid)

else:

ip_formatter.type_printers.pop(pd.DataFrame, None)

if series:

ip_formatter.for_type(pd.Series, _display_as_qgrid)

else:

ip_formatter.type_printers.pop(pd.Series)

开发者ID:quantopian,项目名称:qgrid,代码行数:31,

示例24: disable

​点赞 5

# 需要导入模块: from IPython import display [as 别名]

# 或者: from IPython.display import display [as 别名]

def disable():

"""

Stop using qgrid to display DataFrames and Series instances in the

notebook. This has the same effect as calling ``enable`` with both

kwargs set to ``False`` (and in fact, that's what this function does

internally).

"""

enable(dataframe=False, series=False)

开发者ID:quantopian,项目名称:qgrid,代码行数:10,

示例25: UpdateFromPIL

​点赞 5

# 需要导入模块: from IPython import display [as 别名]

# 或者: from IPython.display import display [as 别名]

def UpdateFromPIL(self, new_img):

from io import BytesIO

from IPython import display

display.clear_output(wait=True)

image = BytesIO()

new_img.save(image, format='png')

display.display(display.Image(image.getvalue()))

开发者ID:google,项目名称:ffn,代码行数:9,

示例26: __del__

​点赞 5

# 需要导入模块: from IPython import display [as 别名]

# 或者: from IPython.display import display [as 别名]

def __del__(self):

cmd = {"cmd": "delete", "idx": self.idx}

if (baseObj.glow is not None and sender is not None):

sender([cmd])

else:

self.appendcmd(cmd)

# Jupyter does not immediately transmit data to the browser from a thread,

# which made for an awkward thread in early versions of Jupyter VPython, and

# even caused display mistakes due to losing portions of data sent to the browser

# from within a thread.

# Now there is no threading in Jupyter VPython. Data is sent to the

# browser from the trigger() function, which is called by a

# canvas_update event sent to Python from the browser (glowcomm.js), currently

# every 17 milliseconds. When trigger() is called, it immediately signals

# the browser to set a timeout of 17 ms to send another signal to Python.

# Note that a typical VPython program starts out by creating objects (constructors) and

# specifying their attributes. The 17 ms signal from the browser is adequate to ensure

# prompt data transmissions to the browser.

# The situation with non-notebook use is similar, but the http server is threaded,

# in order to serve glowcomm.html, jpg texture files, and font files, and the

# websocket is also threaded.

# In both the notebook and non-notebook cases output is buffered in baseObj.updates

# and sent as a block to the browser at render times.

开发者ID:vpython,项目名称:vpython-jupyter,代码行数:29,

示例27: keysdown

​点赞 5

# 需要导入模块: from IPython import display [as 别名]

# 或者: from IPython.display import display [as 别名]

def keysdown():

global keysdownlist

keys = []

for k in keysdownlist: # return a copy of keysdownlist

keys.append(k)

return keys

# global variable for type of web browser to display vpython

开发者ID:vpython,项目名称:vpython-jupyter,代码行数:10,

示例28: _update_trait

​点赞 5

# 需要导入模块: from IPython import display [as 别名]

# 或者: from IPython.display import display [as 别名]

def _update_trait(self, p_name, p_value, widget=None):

p_obj = self.parameterized.params(p_name)

widget = self._widgets[p_name] if widget is None else widget

if isinstance(p_value, tuple):

p_value, size = p_value

if isinstance(size, tuple) and len(size) == 2:

if isinstance(widget, ipywidgets.Image):

widget.width = size[0]

widget.height = size[1]

else:

widget.layout.min_width = '%dpx' % size[0]

widget.layout.min_height = '%dpx' % size[1]

if isinstance(widget, Output):

if isinstance(p_obj, HTMLView) and p_value:

p_value = HTML(p_value)

with widget:

# clear_output required for JLab support

# in future handle.update(p_value) should be sufficient

handle = self._display_handles.get(p_name)

if handle:

clear_output(wait=True)

handle.display(p_value)

else:

handle = display(p_value, display_id=p_name+self._id)

self._display_handles[p_name] = handle

else:

widget.value = p_value

开发者ID:ioam,项目名称:paramnb,代码行数:31,

注:本文中的IPython.display.display方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值