コード例 #1
0
def ipython():
    ''' A PyTest fixture that will automatically skip a test if IPython is
    not installed.

    '''
    ipython = import_optional('IPython')
    if ipython is None:
        pytest.skip('IPython is not installed')
    return ipython
コード例 #2
0
ファイル: pandas.py プロジェクト: zebulon2/bokeh
def pd() -> ModuleType | None: # XXX: should be pandas | None, but not supported
    ''' A PyTest fixture that will automatically skip a test if Pandas is
    not installed.

    '''
    pandas = import_optional('pandas')
    if pandas is None:
        pytest.skip('pandas is not installed')
    return pandas
コード例 #3
0
ファイル: pandas.py プロジェクト: digitalsatori/Bokeh
def pd():
    ''' A PyTest fixture that will automatically skip a test if Pandas is
    not installed.

    '''
    pandas = import_optional('pandas')
    if pandas is None:
        pytest.skip('pandas is not installed')
    return pandas
コード例 #4
0
ファイル: pandas.py プロジェクト: zmj2008/bokeh
def pd():
    ''' A PyTest fixture that will automatically skip a test if Pandas is
    not installed.

    '''
    pandas = import_optional('pandas')
    if pandas is None:
        pytest.skip('pandas is not installed')
    return pandas
コード例 #5
0
def nx(
) -> ModuleType | None:  # XXX: should be networkx | None, but not supported
    ''' A PyTest fixture that will automatically skip a test if networkx is
    not installed.

    '''
    nx = import_optional('networkx')
    if nx is None:
        pytest.skip('networkx is not installed')
    return nx
コード例 #6
0
ファイル: ipython.py プロジェクト: SteffyPerilla/hyperblog
def ipython(
) -> ModuleType | None:  # XXX: should be IPython | None, but not supported
    ''' A PyTest fixture that will automatically skip a test if IPython is
    not installed.

    '''
    ipython = import_optional('IPython')
    if ipython is None:
        pytest.skip('IPython is not installed')
    return ipython
コード例 #7
0
ファイル: utils.py プロジェクト: danielmoralesp/python-basics
import base64

import numpy as np

import warnings

import matplotlib
from matplotlib.colors import colorConverter
from matplotlib.path import Path
from matplotlib.markers import MarkerStyle
from matplotlib.transforms import Affine2D
from matplotlib import ticker

# NOTE: bokeh mod
from bokeh.util.dependencies import import_optional
pd = import_optional('pandas')


def color_to_hex(color):
    """Convert matplotlib color code to hex color code"""
    if color is None or colorConverter.to_rgba(color)[3] == 0:
        return 'none'
    else:
        rgb = colorConverter.to_rgb(color)
        return '#{0:02X}{1:02X}{2:02X}'.format(*(int(255 * c) for c in rgb))


def _many_to_one(input_dict):
    """Convert a many-to-one mapping to a one-to-one mapping"""
    return dict((key, val) for keys, val in input_dict.items() for key in keys)
コード例 #8
0
def _version(modname: str, attr: str) -> Optional[Any]:
    mod = import_optional(modname)
    if mod:
        return getattr(mod, attr)
    else:  # explicit None return for mypy typing
        return None
コード例 #9
0
def test_optional_fail():
    assert dep.import_optional('bleepbloop') is None
コード例 #10
0
ファイル: utils.py プロジェクト: 0-T-0/bokeh
import base64

import numpy as np

import warnings

import matplotlib
from matplotlib.colors import colorConverter
from matplotlib.path import Path
from matplotlib.markers import MarkerStyle
from matplotlib.transforms import Affine2D
from matplotlib import ticker

# NOTE: bokeh mod
from bokeh.util.dependencies import import_optional
pd = import_optional('pandas')

def color_to_hex(color):
    """Convert matplotlib color code to hex color code"""
    if color is None or colorConverter.to_rgba(color)[3] == 0:
        return 'none'
    else:
        rgb = colorConverter.to_rgb(color)
        return '#{0:02X}{1:02X}{2:02X}'.format(*(int(255 * c) for c in rgb))


def _many_to_one(input_dict):
    """Convert a many-to-one mapping to a one-to-one mapping"""
    return dict((key, val)
                for keys, val in input_dict.items()
                for key in keys)
コード例 #11
0
 def test_success(self):
     assert dep.import_optional('sys') is not None
コード例 #12
0
 def test_fail(self) -> None:
     assert dep.import_optional('bleepbloop') is None
コード例 #13
0
 def test_success(self) -> None:
     assert dep.import_optional('sys') is not None
コード例 #14
0
try:
    from urllib.request import urlopen
except ImportError:  # python 2
    from urllib import urlopen

from io import BytesIO
from six import string_types

import param

from bokeh.util.dependencies import import_optional
from pyviz_comms import JupyterComm

from .base import PaneBase

vtk = import_optional('vtk')

arrayTypesMapping = '  bBhHiIlLfdL'  # last one is idtype

_js_mapping = {
    'b': 'Int8Array',
    'B': 'Uint8Array',
    'h': 'Int16Array',
    'H': 'Int16Array',
    'i': 'Int32Array',
    'I': 'Uint32Array',
    'l': 'Int32Array',
    'L': 'Uint32Array',
    'f': 'Float32Array',
    'd': 'Float64Array'
}
コード例 #15
0
ファイル: info.py プロジェクト: digitalsatori/Bokeh
def _version(modname, attr):
    mod = import_optional(modname)
    if mod:
        return getattr(mod, attr)
コード例 #16
0
ファイル: info.py プロジェクト: SteffyPerilla/hyperblog
def _version(module_name: str, attr: str) -> str | None:
    module = import_optional(module_name)
    return getattr(module, attr) if module else None
コード例 #17
0
def test_optional_success():
    assert dep.import_optional('sys') is not None
コード例 #18
0
def _version(modname, attr):
    mod = import_optional(modname)
    if mod:
        return getattr(mod, attr)
コード例 #19
0
 def test_fail(self):
     assert dep.import_optional('bleepbloop') is None