當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。