当前位置: 首页>>代码示例>>Python>>正文


Python display.IFrame方法代码示例

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


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

示例1: get

# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import IFrame [as 别名]
def get(self, idx, path=None):
        x = None
        for i in self.fs.find({'filename': idx}):
            x = i.read()
            fmt = i.fmt
        if x is None:
            raise ValueError(f'There is no id in db: {idx}')
        with open((path or '') + idx + '.' + fmt, 'wb') as f:
            f.write(x)
        print(f'Your file saved at {(path or "") + idx + "." + fmt}')
        if fmt == 'png':
            img = mpimg.imread((path or '') + idx + '.' + fmt)
            plt.figure(figsize=[15, 8])
            plt.imshow(img)
            plt.show()
            plt.close()
        elif fmt == 'html':
            html = x.decode()
            width = int(html.split('var width = ')[1].split(',')[0])
            height = int(html.split('height = ')[1].split(';')[0])
            display(IFrame((path or '') + idx + '.' + fmt, width=width + 200, height=height + 200))
        elif fmt == 'json':
            with open((path or '') + idx + '.' + fmt) as f:
                x = json.load(f)
            return x 
开发者ID:retentioneering,项目名称:retentioneering-tools,代码行数:27,代码来源:cloud_logger.py

示例2: notebook_correlations

# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import IFrame [as 别名]
def notebook_correlations(self, col1, col2, width="100%", height=475):
        """
        Helper function to build an `ipython:IPython.display.IFrame` pointing at the correlations popup

        :param col1: column on left side of correlation
        :type col1: str
        :param col2: column on right side of correlation
        :type col2: str
        :param width: width of the ipython cell
        :type width: str or int, optional
        :param height: height of the ipython cell
        :type height: str or int, optional
        :return: :class:`ipython:IPython.display.IFrame`
        """
        self.notebook(
            "/dtale/popup/correlations/",
            params=dict(col1=col1, col2=col2),
            width=width,
            height=height,
        ) 
开发者ID:man-group,项目名称:dtale,代码行数:22,代码来源:views.py

示例3: show_tree_filter

# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import IFrame [as 别名]
def show_tree_filter(event_col, width=500, height=500, **kwargs):
    """
    Shows tree selector for events filtering and aggregation, based on values in ``event_col`` column. It uses `_` for event names splitting, so ideally the event name structure in the dataset should include underscores and have a hierarchical, e.g. ``[section]_[page]_[action]``. In this case event names are separated into levels, so that all the events with the same ``[section]`` will be placed under the same tree node, etc.
    There two kind of checkboxes in tree selector: large blue and small white. The former are used to include or exclude event from original dataset. The latter are used for event aggregation: toggle on a checkbox against an event name level, e.g. a specific ``[section]_[page]``, to aggregate all the underlying events, all the ``[actions]`` in this example, to this level.
    Tree filter has a download button in the end of event list, which downloads a JSON config file, which you then need to use to filter and aggregate events with ``use_tree_filter()`` function.

    Parameters
    --------
    event_col: str
        Column with event names.
    width: int, optional
        Width of IFrame in pixels.
    height: int, optional
        Height of IFrame in pixels.

    Returns
    --------
    Renders events tree selector

    Return type
    --------
    IFrame
    """

    splitted_names = pd.Series(event_col.unique()).str.split('_', expand=True)
    res = _create_node(0, splitted_names, [], '')
    res = __TEMPLATE__.format(tree_data=json.dumps(res))
    with open('./filter.html', 'w') as f:
        f.write(res)
    display(IFrame('./filter.html', width=width, height=height)) 
开发者ID:retentioneering,项目名称:retentioneering-tools,代码行数:32,代码来源:tree_selector.py

示例4: __str__

# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import IFrame [as 别名]
def __str__(self):
        """
        Will try to create an :class:`ipython:IPython.display.IFrame` if being invoked from within ipython notebook
        otherwise simply returns the output of running :meth:`pandas:pandas.DataFrame.__str__` on the data associated
        with this instance

        """
        if in_ipython_frontend():
            self.notebook()
            return ""
        return self.data.__str__() 
开发者ID:man-group,项目名称:dtale,代码行数:13,代码来源:views.py

示例5: __repr__

# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import IFrame [as 别名]
def __repr__(self):
        """
        Will try to create an :class:`ipython:IPython.display.IFrame` if being invoked from within ipython notebook
        otherwise simply returns the output of running :meth:`pandas:pandas.DataFrame.__repr__` on the data for
        this instance

        """
        if in_ipython_frontend():
            self.notebook()
            if self._notebook_handle is not None:
                return ""
        return self.main_url() 
开发者ID:man-group,项目名称:dtale,代码行数:14,代码来源:views.py

示例6: _build_iframe

# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import IFrame [as 别名]
def _build_iframe(
        self, route="/dtale/iframe/", params=None, width="100%", height=475
    ):
        """
        Helper function to build an :class:`ipython:IPython.display.IFrame` if that module exists within
        your environment

        :param route: the :class:`flask:flask.Flask` route to hit on D-Tale
        :type route: str, optional
        :param params: properties & values passed as query parameters to the route
        :type params: dict, optional
        :param width: width of the ipython cell
        :type width: str or int, optional
        :param height: height of the ipython cell
        :type height: str or int, optional
        :return: :class:`ipython:IPython.display.IFrame`
        """
        try:
            from IPython.display import IFrame
        except ImportError:
            logger.info("in order to use this function, please install IPython")
            return None
        iframe_url = "{}{}{}".format(self._url, route, self._data_id)
        if params is not None:
            if isinstance(params, string_types):  # has this already been encoded?
                iframe_url = "{}?{}".format(iframe_url, params)
            else:
                iframe_url = "{}?{}".format(iframe_url, url_encode_func()(params))
        return IFrame(iframe_url, width=width, height=height) 
开发者ID:man-group,项目名称:dtale,代码行数:31,代码来源:views.py

示例7: notebook

# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import IFrame [as 别名]
def notebook(self, route="/dtale/iframe/", params=None, width="100%", height=475):
        """
        Helper function which checks to see if :mod:`flask:flask.Flask` process is up and running and then tries to
        build an :class:`ipython:IPython.display.IFrame` and run :meth:`ipython:IPython.display.display` on it so
        it will be displayed in the ipython notebook which invoked it.

        A reference to the :class:`ipython:IPython.display.DisplayHandle` is stored in _notebook_handle for
        updating if you are running ipython>=5.0

        :param route: the :class:`flask:flask.Flask` route to hit on D-Tale
        :type route: str, optional
        :param params: properties & values passed as query parameters to the route
        :type params: dict, optional
        :param width: width of the ipython cell
        :type width: str or int, optional
        :param height: height of the ipython cell
        :type height: str or int, optional
        """
        try:
            from IPython.display import display
        except ImportError:
            logger.info("in order to use this function, please install IPython")
            return self.data.__repr__()

        retries = 0
        while not self.is_up() and retries < 10:
            time.sleep(0.01)
            retries += 1

        self._notebook_handle = display(
            self._build_iframe(route=route, params=params, width=width, height=height),
            display_id=True,
        )
        if self._notebook_handle is None:
            self._notebook_handle = True 
开发者ID:man-group,项目名称:dtale,代码行数:37,代码来源:views.py

示例8: plot_and_save

# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import IFrame [as 别名]
def plot_and_save(self,
                      data,
                      chart_type,
                      options=None,
                      w=800,
                      h=420,
                      filename='chart',
                      overwrite=True):
        """Save the rendered html to a file and return an IFrame to display the plot in the notebook."""
        self.save(data, chart_type, options, filename, w, h, overwrite)
        return IFrame(filename + '.html', w, h) 
开发者ID:niloch,项目名称:iplotter,代码行数:13,代码来源:chartjs_plotter.py

示例9: plot_and_save

# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import IFrame [as 别名]
def plot_and_save(self,
                      data,
                      chart_type,
                      chart_package='corechart',
                      options=None,
                      w=800,
                      h=420,
                      filename='chart',
                      overwrite=True):
        """Save the rendered html to a file and return an IFrame to display the plot in the notebook."""
        self.save(data, chart_type, chart_package, options, filename,
                  overwrite)
        return IFrame(filename + '.html', w, h) 
开发者ID:niloch,项目名称:iplotter,代码行数:15,代码来源:google_plotter.py

示例10: plot_and_save

# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import IFrame [as 别名]
def plot_and_save(self,
                      data,
                      chart_type,
                      options=None,
                      w=800,
                      h=420,
                      filename='chart',
                      overwrite=True):
        """Save the rendered html to a file and return an IFrame to display the plot in the notebook."""
        self.save(data, chart_type, options, filename, overwrite)
        return IFrame(filename + '.html', w, h) 
开发者ID:niloch,项目名称:iplotter,代码行数:13,代码来源:chartist_plotter.py

示例11: plot_and_save

# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import IFrame [as 别名]
def plot_and_save(self,
                      data,
                      w=800,
                      h=420,
                      filename='chart',
                      overwrite=True):
        """Save the rendered html to a file and returns an IFrame to display the plot in the notebook."""
        self.save(data, filename, overwrite)
        return IFrame(filename + '.html', w, h) 
开发者ID:niloch,项目名称:iplotter,代码行数:11,代码来源:c3_plotter.py

示例12: plot_and_save

# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import IFrame [as 别名]
def plot_and_save(self,
                      data,
                      layout=None,
                      w=800,
                      h=420,
                      filename='chart',
                      overwrite=True):
        """Save the rendered html to a file and return an IFrame to display the plot in the notebook."""
        self.save(data, layout, filename, overwrite)
        return IFrame(filename + '.html', w, h) 
开发者ID:niloch,项目名称:iplotter,代码行数:12,代码来源:plotly_plotter.py

示例13: showInNetron

# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import IFrame [as 别名]
def showInNetron(model_filename):
    netron.start(model_filename, port=8081, host="0.0.0.0")
    return IFrame(src="http://0.0.0.0:8081/", width="100%", height=400) 
开发者ID:Xilinx,项目名称:finn,代码行数:5,代码来源:visualization.py

示例14: save_fig

# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import IFrame [as 别名]
def save_fig(name, root_dir=None, notebook_mode=True, default_overwrite=False, extension='pdf', **savefig_kwargs):
    if root_dir is None: root_dir = os.getcwd()
    directory = check_or_create_dir(join_paths(root_dir, FOLDER_NAMINGS['PLOTS_DIR']),
                                    notebook_mode=notebook_mode)

    filename = join_paths(directory, '%s.%s' % (name, extension))  # directory + '/%s.pdf' % name
    if not default_overwrite and os.path.isfile(filename):
        # if IPython is not None:
        #     IPython.display.display(tuple(IFrame(filename, width=800, height=600)))  # FIXME not working!
        overwrite = input('A file named %s already exists. Overwrite (Leave string empty for NO!)?' % filename)
        if not overwrite:
            print('No changes done.')
            return
    plt.savefig(filename, **savefig_kwargs)
    # print('file saved') 
开发者ID:lucfra,项目名称:RFHO,代码行数:17,代码来源:save_and_load.py

示例15: plot_points

# 需要导入模块: from IPython import display [as 别名]
# 或者: from IPython.display import IFrame [as 别名]
def plot_points(xyz,
                colors=None,
                size=0.1,
                axis=False,
                title=None,
                html_out=None):
    positions = xyz.reshape(-1).tolist()
    mkdir_p('vis')
    if html_out is None:
        html_out = os.path.join('vis', 'pts{:s}.html'.format(uuid4()))
    if title is None:
        title = "PointCloud"
    camera_position = xyz.max(0) + abs(xyz.max(0))

    look = xyz.mean(0)

    if colors is None:
        colors = [1, 0.5, 0] * len(positions)

    elif len(colors.shape) > 1:
        colors = colors.reshape(-1).tolist()

    if axis:
        axis_size = xyz.ptp() * 1.5
    else:
        axis_size = 0

    with open(html_out, "w") as html:
        html.write(
            TEMPLATE_POINTS.format(
                title=title,
                camera_x=camera_position[0],
                camera_y=camera_position[1],
                camera_z=camera_position[2],
                look_x=look[0],
                look_y=look[1],
                look_z=look[2],
                positions=positions,
                colors=colors,
                points_size=size,
                axis_size=axis_size))

    return IFrame(html_out, width=1024, height=768) 
开发者ID:akar43,项目名称:lsm,代码行数:45,代码来源:vis_utils.py


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