Clear output python jupiter

Module: display ¶

When this object is returned by an input cell or passed to the display function, it will result in Audio controls being displayed in the frontend (only works in the notebook).

  • Numpy 1d array containing the desired waveform (mono)
  • Numpy 2d array containing waveforms for each channel. Shape=(NCHAN, NSAMPLES). For the standard channel order, see http://msdn.microsoft.com/en-us/library/windows/hardware/dn653308(v=vs.85).aspx
  • List of float or integer representing the waveform (mono)
  • String containing the filename
  • Bytestring containing raw PCM data or
  • URL pointing to a file on the web.

If the array option is used, the waveform will be normalized.

If a filename or url is used, the format support will be browser dependent.

>>> import pytest >>> np = pytest.importorskip("numpy") 

>>> import numpy as np >>> framerate = 44100 >>> t = np.linspace(0,5,framerate*5) >>> data = np.sin(2*np.pi*220*t) + np.sin(2*np.pi*224*t) >>> Audio(data, rate=framerate)

Can also do stereo or more channels

>>> dataleft = np.sin(2*np.pi*220*t) >>> dataright = np.sin(2*np.pi*224*t) >>> Audio([dataleft, dataright], rate=framerate)

>>> Audio("http://www.nch.com.au/acm/8k16bitpcm.wav") >>> Audio(url="http://www.w3schools.com/html/horse.ogg") 
>>> Audio('IPython/lib/tests/test.wav') >>> Audio(filename='IPython/lib/tests/test.wav') 
>>> Audio(b'RAW_WAV_DATA..') >>> Audio(data=b'RAW_WAV_DATA..') 

Audio widget with more more flexibility and options.

__init__ ( data = None , filename = None , url = None , embed = None , rate = None , autoplay = False , normalize = True , * , element_id = None ) ¶

Create a display object given raw data.

When this object is returned by an expression or passed to the display function, it will result in the data being displayed in the frontend. The MIME type of the data should match the subclasses used, so the Png subclass should be used for ‘image/png’ data. If the data is a URL, the data will first be downloaded and then displayed. If

  • data (unicode,strorbytes) – The raw data or a URL or file to load the data from
  • url (unicode) – A URL to download the data from.
  • filename (unicode) – Path to a local file to load the data from.
  • metadata (dict) – Dict of metadata associated to be the object when displayed

Reload the raw data from file or URL.

class IPython.display. Code ( data = None , url = None , filename = None , language = None ) ¶

Display syntax-highlighted source code.

This uses Pygments to highlight the code for HTML and Latex output.

  • data (str) – The code as a string
  • url (str) – A URL to fetch the code from
  • filename (str) – A local filename to load the code from
  • language (str) – The short name of a Pygments lexer to use for highlighting. If not specified, it will guess the lexer based on the filename or the code. Available lexers: http://pygments.org/docs/lexers/

Create a display object given raw data.

When this object is returned by an expression or passed to the display function, it will result in the data being displayed in the frontend. The MIME type of the data should match the subclasses used, so the Png subclass should be used for ‘image/png’ data. If the data is a URL, the data will first be downloaded and then displayed. If

  • data (unicode,strorbytes) – The raw data or a URL or file to load the data from
  • url (unicode) – A URL to download the data from.
  • filename (unicode) – Path to a local file to load the data from.
  • metadata (dict) – Dict of metadata associated to be the object when displayed

A handle on an updatable display

Call .update(obj) to display a new object.

Call .display(obj ) to add a new instance of this display, and update existing instances.

__init__ ( display_id = None ) ¶ display ( obj , ** kwargs ) ¶

Make a new display with my id, updating existing instances.

  • obj – object to display
  • **kwargs – additional keyword arguments passed to display

Update existing displays with my id

  • obj – object to display
  • **kwargs – additional keyword arguments passed to update_display

An object that wraps data to be displayed.

__init__ ( data = None , url = None , filename = None , metadata = None ) ¶

Create a display object given raw data.

When this object is returned by an expression or passed to the display function, it will result in the data being displayed in the frontend. The MIME type of the data should match the subclasses used, so the Png subclass should be used for ‘image/png’ data. If the data is a URL, the data will first be downloaded and then displayed. If

  • data (unicode,strorbytes) – The raw data or a URL or file to load the data from
  • url (unicode) – A URL to download the data from.
  • filename (unicode) – Path to a local file to load the data from.
  • metadata (dict) – Dict of metadata associated to be the object when displayed

Reload the raw data from file or URL.

class IPython.display. FileLink ( path , url_prefix = » , result_html_prefix = » , result_html_suffix = ‘
) ¶

Class for embedding a local file link in an IPython session, based on path

e.g. to embed a link that was generated in the IPython notebook as my/data.txt

local_file = FileLink("my/data.txt") display(local_file) 

or in the HTML notebook, just:

  • path (str) – path to the file or directory that should be formatted
  • url_prefix (str) – prefix to be prepended to all files to form a working link [default: ‘’]
  • result_html_prefix (str) – text to append to beginning to link [default: ‘’]
  • result_html_suffix (str) – text to append at the end of link [default: ‘
    ’]

Class for embedding local file links in an IPython session, based on path

e.g. to embed links to files that were generated in the IPython notebook under my/data , you would do:

local_files = FileLinks("my/data") display(local_files) 

or in the HTML notebook, just:

__init__ ( path , url_prefix = » , included_suffixes = None , result_html_prefix = » , result_html_suffix = ‘
, notebook_display_formatter = None , terminal_display_formatter = None , recursive = True ) ¶

See FileLink for the path , url_prefix , result_html_prefix and result_html_suffix parameters.

Filename suffixes to include when formatting output [default: include all files]

Used to format links for display in the notebook. See discussion of formatter functions below.

Used to format links for display in the terminal. See discussion of formatter functions below.

Formatter functions must be of the form:

f(dirname, fnames, included_suffixes) 

The files in that directory

The file suffixes that should be included in the output (passing None meansto include all suffixes in the output in the built-in formatters)

Whether to recurse into subdirectories. Default is True.

The function should return a list of lines that will be printed in the notebook (if passing notebook_display_formatter) or the terminal (if passing terminal_display_formatter). This function is iterated over for each directory in self.path. Default formatters are in place, can be passed here to support alternative formatting.

class IPython.display. GeoJSON ( * args , ** kwargs ) ¶

GeoJSON expects JSON-able dict

not an already-serialized JSON string.

Scalar types (None, number, string) are not allowed, only dict containers.

Create a GeoJSON display object given raw data.

  • data (dictorlist) – VegaLite data. Not an already-serialized JSON string. Scalar types (None, number, string) are not allowed, only dict or list containers.
  • url_template (string) – Leaflet TileLayer URL template: http://leafletjs.com/reference.html#url-template
  • layer_options (dict) – Leaflet TileLayer options: http://leafletjs.com/reference.html#tilelayer-options
  • url (unicode) – A URL to download the data from.
  • filename (unicode) – Path to a local file to load the data from.
  • metadata (dict) – Specify extra metadata to attach to the json display object.

The following will display an interactive map of Mars with a point of interest on frontend that do support GeoJSON display.

>>> from IPython.display import GeoJSON 

>>> GeoJSON(data= . «type»: «Feature», . «geometry»: . «type»: «Point», . «coordinates»: [81.327, 296.038] . > . >, . url_template=«http://s3-eu-west-1.amazonaws.com/whereonmars.cartodb.net/ / / / .png», . layer_options= . «basemap_id»: «celestia_mars-shaded-16k_global», . «attribution» : «Celestia/praesepe», . «minZoom» : 0, . «maxZoom» : 18, . >)

In the terminal IPython, you will only see the text representation of the GeoJSON object.

class IPython.display. HTML ( data = None , url = None , filename = None , metadata = None ) ¶

__init__ ( data = None , url = None , filename = None , metadata = None ) ¶

Create a display object given raw data.

When this object is returned by an expression or passed to the display function, it will result in the data being displayed in the frontend. The MIME type of the data should match the subclasses used, so the Png subclass should be used for ‘image/png’ data. If the data is a URL, the data will first be downloaded and then displayed. If

  • data (unicode,strorbytes) – The raw data or a URL or file to load the data from
  • url (unicode) – A URL to download the data from.
  • filename (unicode) – Path to a local file to load the data from.
  • metadata (dict) – Dict of metadata associated to be the object when displayed

Generic class to embed an iframe in an IPython notebook

__init__ ( src , width , height , extras : Optional [ Iterable [ str ] ] = None , ** kwargs ) ¶ class IPython.display. Image ( data = None , url = None , filename = None , format = None , embed = None , width = None , height = None , retina = False , unconfined = False , metadata = None , alt = None ) ¶

__init__ ( data = None , url = None , filename = None , format = None , embed = None , width = None , height = None , retina = False , unconfined = False , metadata = None , alt = None ) ¶

Create a PNG/JPEG/GIF image object given raw data.

When this object is returned by an input cell or passed to the display function, it will result in the image being displayed in the frontend.

Parameters

  • data (unicode,strorbytes) – The raw image data or a URL or filename to load the data from. This always results in embedded image data.
  • url (unicode) – A URL to download the data from. If you specify url= , the image data will not be embedded unless you also specify embed=True .
  • filename (unicode) – Path to a local file to load the data from. Images from a file are always embedded.
  • format (unicode) – The format of the image data (png/jpeg/jpg/gif). If a filename or URL is given for format will be inferred from the filename extension.
  • embed (bool) – Should the image data be embedded using a data URI (True) or be loaded using an tag. Set this to True if you want the image to be viewable later with no internet connection in the notebook. Default is True , unless the keyword argument url is set, then default value is False . Note that QtConsole is not able to display images if embed is set to False
  • width (int) – Width in pixels to which to constrain the image in html
  • height (int) – Height in pixels to which to constrain the image in html
  • retina (bool) – Automatically set the width and height to half of the measured width and height. This only works for embedded images because it reads the width/height from image data. For non-embedded images, you can just set the desired display width and height directly.
  • unconfined (bool) – Set unconfined=True to disable max-width confinement of the image.
  • metadata (dict) – Specify extra metadata to attach to the image.
  • alt (unicode) – Alternative text for the image, for use by screen readers.

embedded image data, works in qtconsole and notebook when passed positionally, the first arg can be any of raw image data, a URL, or a filename from which to load image data. The result is always embedding image data for inline images.

>>> Image(‘https://www.google.fr/images/srpr/logo3w.png’)

Источник

Читайте также:  Javascript if не ровно
Оцените статью