本文整理匯總了Python中IPython.__version__方法的典型用法代碼示例。如果您正苦於以下問題:Python IPython.__version__方法的具體用法?Python IPython.__version__怎麽用?Python IPython.__version__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IPython
的用法示例。
在下文中一共展示了IPython.__version__方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: init_inspector
# 需要導入模塊: import IPython [as 別名]
# 或者: from IPython import __version__ [as 別名]
def init_inspector(self):
super(RekallShell, self).init_inspector()
# This is a hack but seems the only way to make get_ipython() work
# properly.
InteractiveShell._instance = self
ipython_version = IPython.__version__
# IPython 5 (4 should work too) is the one we standardize on right
# now. This means we support earlier ones but turn off the bells and
# whistles.
if "4.0.0" <= ipython_version < "7.0.0":
self.inspector = RekallObjectInspector()
else:
self.user_ns.session.logging.warn(
"Warning: IPython version %s not fully supported. "
"We recommend installing IPython version 5.",
ipython_version)
示例2: generatePrompt
# 需要導入模塊: import IPython [as 別名]
# 或者: from IPython import __version__ [as 別名]
def generatePrompt(self, is_continuation):
'''
Generate prompt depending on is_continuation value
@param is_continuation
@type is_continuation: boolean
@return: The prompt string representation
@rtype: string
'''
# Backwards compatibility with ipyton-0.11
#
ver = IPython.__version__
if '0.11' in ver:
prompt = self.IP.hooks.generate_prompt(is_continuation)
else:
if is_continuation:
prompt = self.IP.prompt_manager.render('in2')
else:
prompt = self.IP.prompt_manager.render('in')
return prompt
示例3: generatePrompt
# 需要導入模塊: import IPython [as 別名]
# 或者: from IPython import __version__ [as 別名]
def generatePrompt(self, is_continuation):
"""!
Generate prompt depending on is_continuation value
@param is_continuation
@return: The prompt string representation
"""
# Backwards compatibility with ipyton-0.11
#
ver = IPython.__version__
if '0.11' in ver:
prompt = self.IP.hooks.generate_prompt(is_continuation)
else:
if is_continuation:
prompt = self.IP.prompt_manager.render('in2')
else:
prompt = self.IP.prompt_manager.render('in')
return prompt
示例4: get_ipython_dir
# 需要導入模塊: import IPython [as 別名]
# 或者: from IPython import __version__ [as 別名]
def get_ipython_dir(profile=None):
"""Returns the base directory of the IPython server
:param profile: The name of the IPython profile
:type profile: str
"""
if not check_ipython():
raise ImportError("Cannot Find IPython Environment")
import IPython
# IPython 4.0+ changes the position of files in the profile
# directory
if V(IPython.__version__) >= V('4.0.0'):
from jupyter_core.paths import jupyter_data_dir
return os.path.join(
jupyter_data_dir(),
IPYTHON_V4_BASE.strip("/"))
else:
if not profile:
profile = get_profile_name()
return os.path.join(
IPython.utils.path.locate_profile(
profile),
IPYTHON_V3_BASE.strip("/"))
示例5: write_index
# 需要導入模塊: import IPython [as 別名]
# 或者: from IPython import __version__ [as 別名]
def write_index():
"""This is to write the docs for the index automatically."""
here = os.path.dirname(__file__)
filename = os.path.join(here, '_generated', 'version_text.txt')
try:
os.makedirs(os.path.dirname(filename))
except FileExistsError:
pass
text = text_version if '+' not in oggm.__version__ else text_dev
with open(filename, 'w') as f:
f.write(text)
示例6: add_web_base
# 需要導入模塊: import IPython [as 別名]
# 或者: from IPython import __version__ [as 別名]
def add_web_base(path):
"""Add the base of the IPython dependency URLs
:param path: The path to be augmented with the
webserver base
:type path: str
"""
import IPython
if V(IPython.__version__) >= V('4.0.0'):
return os.path.join(IPYTHON_V4_BASE, path)
else:
return os.path.join(IPYTHON_V3_BASE, path)
示例7: _setup_ipython_formatter
# 需要導入模塊: import IPython [as 別名]
# 或者: from IPython import __version__ [as 別名]
def _setup_ipython_formatter(ip):
''' Set up the ipython formatter to display HTML formatted output inline'''
from IPython import __version__ as IPython_version
from .highcharts.highcharts import Highchart
from .highmaps.highmaps import Highmap
from .highstock.highstock import Highstock
if IPython_version >= '0.11':
html_formatter = ip.display_formatter.formatters['text/html']
for chart_type in [Highchart, Highmap, Highstock]:
html_formatter.for_type(chart_type, _print_html)
示例8: shell
# 需要導入模塊: import IPython [as 別名]
# 或者: from IPython import __version__ [as 別名]
def shell(ipython_args):
"""Runs a shell in the app context.
Runs an interactive Python shell in the context of a given
Flask application. The application will populate the default
namespace of this shell according to it's configuration.
This is useful for executing small snippets of management code
without having to manually configuring the application.
"""
import IPython
from IPython.terminal.ipapp import load_default_config
from traitlets.config.loader import Config
from flask.globals import _app_ctx_stack
app = _app_ctx_stack.top.app
if 'IPYTHON_CONFIG' in app.config:
config = Config(app.config['IPYTHON_CONFIG'])
else:
config = load_default_config()
config.TerminalInteractiveShell.banner1 = '''Python %s on %s
IPython: %s
App: %s [%s]
Instance: %s''' % (sys.version,
sys.platform,
IPython.__version__,
app.import_name,
app.env,
app.instance_path)
IPython.start_ipython(
argv=ipython_args,
user_ns=app.make_shell_context(),
config=config,
)
示例9: write_result
# 需要導入模塊: import IPython [as 別名]
# 或者: from IPython import __version__ [as 別名]
def write_result(self, buf):
indent = 0
id_section = ""
frame = self.frame
_classes = ['dataframe'] # Default class.
use_mathjax = get_option("display.html.use_mathjax")
if not use_mathjax:
_classes.append('tex2jax_ignore')
if self.classes is not None:
if isinstance(self.classes, str):
self.classes = self.classes.split()
if not isinstance(self.classes, (list, tuple)):
raise AssertionError('classes must be list or tuple, not {typ}'
.format(typ=type(self.classes)))
_classes.extend(self.classes)
if self.notebook:
div_style = ''
try:
import IPython
if IPython.__version__ < LooseVersion('3.0.0'):
div_style = ' style="max-width:1500px;overflow:auto;"'
except (ImportError, AttributeError):
pass
self.write('<div{style}>'.format(style=div_style))
self.write_style()
if self.table_id is not None:
id_section = ' id="{table_id}"'.format(table_id=self.table_id)
self.write('<table border="{border}" class="{cls}"{id_section}>'
.format(border=self.border, cls=' '.join(_classes),
id_section=id_section), indent)
indent += self.indent_delta
indent = self._write_header(indent)
indent = self._write_body(indent)
self.write('</table>', indent)
if self.should_show_dimensions:
by = chr(215) if compat.PY3 else unichr(215) # ×
self.write(u('<p>{rows} rows {by} {cols} columns</p>')
.format(rows=len(frame),
by=by,
cols=len(frame.columns)))
if self.notebook:
self.write('</div>')
buffer_put_lines(buf, self.elements)
示例10: test_bigquery_magic_with_bqstorage_from_argument
# 需要導入模塊: import IPython [as 別名]
# 或者: from IPython import __version__ [as 別名]
def test_bigquery_magic_with_bqstorage_from_argument(monkeypatch):
ip = IPython.get_ipython()
ip.extension_manager.load_extension("google.cloud.bigquery")
mock_credentials = mock.create_autospec(
google.auth.credentials.Credentials, instance=True
)
# Set up the context with monkeypatch so that it's reset for subsequent
# tests.
monkeypatch.setattr(magics.context, "credentials", mock_credentials)
# Mock out the BigQuery Storage API.
bqstorage_mock = mock.create_autospec(bigquery_storage_v1.BigQueryReadClient)
bqstorage_instance_mock = mock.create_autospec(
bigquery_storage_v1.BigQueryReadClient, instance=True
)
bqstorage_instance_mock.transport = mock.Mock()
bqstorage_mock.return_value = bqstorage_instance_mock
bqstorage_client_patch = mock.patch(
"google.cloud.bigquery_storage_v1.BigQueryReadClient", bqstorage_mock
)
sql = "SELECT 17 AS num"
result = pandas.DataFrame([17], columns=["num"])
run_query_patch = mock.patch(
"google.cloud.bigquery.magics._run_query", autospec=True
)
query_job_mock = mock.create_autospec(
google.cloud.bigquery.job.QueryJob, instance=True
)
query_job_mock.to_dataframe.return_value = result
with run_query_patch as run_query_mock, bqstorage_client_patch, warnings.catch_warnings(
record=True
) as warned:
run_query_mock.return_value = query_job_mock
return_value = ip.run_cell_magic("bigquery", "--use_bqstorage_api", sql)
# Deprecation warning should have been issued.
def warning_match(warning):
message = str(warning).lower()
return "deprecated" in message and "use_bqstorage_api" in message
expected_warnings = list(filter(warning_match, warned))
assert len(expected_warnings) == 1
assert len(bqstorage_mock.call_args_list) == 1
kwargs = bqstorage_mock.call_args_list[0].kwargs
assert kwargs.get("credentials") is mock_credentials
client_info = kwargs.get("client_info")
assert client_info is not None
assert client_info.user_agent == "ipython-" + IPython.__version__
query_job_mock.to_dataframe.assert_called_once_with(
bqstorage_client=bqstorage_instance_mock
)
assert isinstance(return_value, pandas.DataFrame)
示例11: write_result
# 需要導入模塊: import IPython [as 別名]
# 或者: from IPython import __version__ [as 別名]
def write_result(self, buf):
indent = 0
frame = self.frame
_classes = ['dataframe'] # Default class.
if self.classes is not None:
if isinstance(self.classes, str):
self.classes = self.classes.split()
if not isinstance(self.classes, (list, tuple)):
raise AssertionError('classes must be list or tuple, not {typ}'
.format(typ=type(self.classes)))
_classes.extend(self.classes)
if self.notebook:
div_style = ''
try:
import IPython
if IPython.__version__ < LooseVersion('3.0.0'):
div_style = ' style="max-width:1500px;overflow:auto;"'
except (ImportError, AttributeError):
pass
self.write('<div{style}>'.format(style=div_style))
self.write_style()
self.write('<table border="{border}" class="{cls}">'
.format(border=self.border, cls=' '.join(_classes)), indent)
indent += self.indent_delta
indent = self._write_header(indent)
indent = self._write_body(indent)
self.write('</table>', indent)
if self.should_show_dimensions:
by = chr(215) if compat.PY3 else unichr(215) # ×
self.write(u('<p>{rows} rows {by} {cols} columns</p>')
.format(rows=len(frame),
by=by,
cols=len(frame.columns)))
if self.notebook:
self.write('</div>')
_put_lines(buf, self.elements)
示例12: system
# 需要導入模塊: import IPython [as 別名]
# 或者: from IPython import __version__ [as 別名]
def system():
"""
**SUMMARY**
Output of this function includes various informations related to system and library.
Main purpose:
- While submiting a bug, report the output of this function
- Checking the current version and later upgrading the library based on the output
**RETURNS**
None
**EXAMPLE**
>>> import SimpleCV
>>> SimpleCV.system()
"""
try :
import platform
print "System : ", platform.system()
print "OS version : ", platform.version()
print "Python version :", platform.python_version()
try :
from cv2 import __version__
print "Open CV version : " + __version__
except ImportError :
print "Open CV2 version : " + "2.1"
if (PIL_ENABLED) :
print "PIL version : ", pil.VERSION
else :
print "PIL module not installed"
if (ORANGE_ENABLED) :
print "Orange Version : " + orange.version
else :
print "Orange module not installed"
try :
import pygame as pg
print "PyGame Version : " + pg.__version__
except ImportError:
print "PyGame module not installed"
try :
import pickle
print "Pickle Version : " + pickle.__version__
except :
print "Pickle module not installed"
except ImportError :
print "You need to install Platform to use this function"
print "to install you can use:"
print "easy_install platform"
return