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


Python param.Boolean方法代码示例

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


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

示例1: __init__

# 需要导入模块: import param [as 别名]
# 或者: from param import Boolean [as 别名]
def __init__(self, **params):
        super(NotebookArchive, self).__init__(**params)
        self.nbversion = None
        self.notebook_name = None
        self.export_success = None

        self._auto = False
        self._replacements = {}
        self._notebook_data = None
        self._timestamp = None
        self._tags = {MIME_TYPES[k]:v for k,v in HTML_TAGS.items() if k in MIME_TYPES}

        keywords = ['%s=%s' % (k, v.__class__.__name__)
                    for k, v in self.param.objects().items()]
        self.auto.__func__.__doc__ = 'auto(enabled=Boolean, %s)' % ', '.join(keywords) 
开发者ID:holoviz,项目名称:holoviews,代码行数:17,代码来源:archive.py

示例2: define

# 需要导入模块: import param [as 别名]
# 或者: from param import Boolean [as 别名]
def define(cls, name, **kwargs):
        """
        Utility to quickly and easily declare Stream classes. Designed
        for interactive use such as notebooks and shouldn't replace
        parameterized class definitions in source code that is imported.

        Takes a stream class name and a set of keywords where each
        keyword becomes a parameter. If the value is already a
        parameter, it is simply used otherwise the appropriate parameter
        type is inferred and declared, using the value as the default.

        Supported types: bool, int, float, str, dict, tuple and list
        """
        params = {'name': param.String(default=name)}
        for k, v in kwargs.items():
            kws = dict(default=v, constant=True)
            if isinstance(v, param.Parameter):
                params[k] = v
            elif isinstance(v, bool):
                params[k] = param.Boolean(**kws)
            elif isinstance(v, int):
                params[k] = param.Integer(**kws)
            elif isinstance(v, float):
                params[k] = param.Number(**kws)
            elif isinstance(v, str):
                params[k] = param.String(**kws)
            elif isinstance(v, dict):
                params[k] = param.Dict(**kws)
            elif isinstance(v, tuple):
                params[k] = param.Tuple(**kws)
            elif isinstance(v, list):
                params[k] = param.List(**kws)
            elif isinstance(v, np.ndarray):
                params[k] = param.Array(**kws)
            else:
                params[k] = param.Parameter(**kws)

        # Dynamic class creation using type
        return type(name, (Stream,), params) 
开发者ID:holoviz,项目名称:holoviews,代码行数:41,代码来源:streams.py

示例3: test_custom_types

# 需要导入模块: import param [as 别名]
# 或者: from param import Boolean [as 别名]
def test_custom_types(self):
        self.assertEqual(isinstance(self.TypesTest.param['t'], param.Boolean),True)
        self.assertEqual(isinstance(self.TypesTest.param['u'], param.Integer),True)
        self.assertEqual(isinstance(self.TypesTest.param['v'], param.Number),True)
        self.assertEqual(isinstance(self.TypesTest.param['w'], param.Tuple),True)
        self.assertEqual(isinstance(self.TypesTest.param['x'], param.String),True)
        self.assertEqual(isinstance(self.TypesTest.param['y'], param.List),True)
        self.assertEqual(isinstance(self.TypesTest.param['z'], param.Array),True) 
开发者ID:holoviz,项目名称:holoviews,代码行数:10,代码来源:teststreams.py

示例4: _update_backend

# 需要导入模块: import param [as 别名]
# 或者: from param import Boolean [as 别名]
def _update_backend(cls, backend):

        if cls.__original_docstring__ is None:
            cls.__original_docstring__ = cls.__doc__

        all_keywords = set()
        element_keywords = cls._element_keywords(backend)
        for element, keywords in element_keywords.items():
            with param.logging_level('CRITICAL'):
                all_keywords |= set(keywords)
                setattr(cls, element,
                        cls._create_builder(element, keywords))

        filtered_keywords = [k for k in all_keywords if k not in cls._no_completion]
        sorted_kw_set = sorted(set(filtered_keywords))
        if sys.version_info.major == 2:
            kws = ', '.join('{opt}=None'.format(opt=opt) for opt in sorted_kw_set)
            old_doc = cls.__original_docstring__.replace(
                'params(strict=Boolean, name=String)','')
            cls.__doc__ = '\n    opts({kws})'.format(kws=kws) + old_doc
        else:
            from inspect import Parameter, Signature
            signature = Signature([Parameter('args', Parameter.VAR_POSITIONAL)]
                                  + [Parameter(kw, Parameter.KEYWORD_ONLY)
                                     for kw in sorted_kw_set])
            cls.__init__.__signature__ = signature 
开发者ID:holoviz,项目名称:holoviews,代码行数:28,代码来源:__init__.py

示例5: is_int

# 需要导入模块: import param [as 别名]
# 或者: from param import Boolean [as 别名]
def is_int(obj, int_like=False):
    """
    Checks for int types including the native Python type and NumPy-like objects

    Args:
        obj: Object to check for integer type
        int_like (boolean): Check for float types with integer value

    Returns:
        Boolean indicating whether the supplied value is of integer type.
    """
    real_int = isinstance(obj, int) or getattr(getattr(obj, 'dtype', None), 'kind', 'o') in 'ui'
    if real_int or (int_like and hasattr(obj, 'is_integer') and obj.is_integer()):
        return True
    return False 
开发者ID:holoviz,项目名称:holoviews,代码行数:17,代码来源:util.py

示例6: test_boolean_param

# 需要导入模块: import param [as 别名]
# 或者: from param import Boolean [as 别名]
def test_boolean_param(document, comm):
    class Test(param.Parameterized):
        a = param.Boolean(default=False)

    test = Test()
    test_pane = Pane(test)
    model = test_pane.get_root(document, comm=comm)

    checkbox = model.children[1]
    assert isinstance(checkbox, CheckboxGroup)
    assert checkbox.labels == ['A']
    assert checkbox.active == []
    assert checkbox.disabled == False

    # Check changing param value updates widget
    test.a = True
    assert checkbox.active == [0]

    # Check changing param attribute updates widget
    a_param = test.param['a']
    a_param.constant = True
    assert checkbox.disabled == True

    # Ensure cleanup works
    test_pane._cleanup(model)
    a_param.constant = False
    test.a = False
    assert checkbox.active == [0]
    assert checkbox.disabled == True 
开发者ID:holoviz,项目名称:panel,代码行数:31,代码来源:test_param.py

示例7: test_explicit_params

# 需要导入模块: import param [as 别名]
# 或者: from param import Boolean [as 别名]
def test_explicit_params(document, comm):
    class Test(param.Parameterized):
        a = param.Boolean(default=False)
        b = param.Integer(default=1)

    test = Test()
    test_pane = Pane(test, parameters=['a'])
    model = test_pane.get_root(document, comm=comm)

    assert len(model.children) == 2
    assert isinstance(model.children[1], CheckboxGroup) 
开发者ID:holoviz,项目名称:panel,代码行数:13,代码来源:test_param.py

示例8: test_param_precedence_ordering

# 需要导入模块: import param [as 别名]
# 或者: from param import Boolean [as 别名]
def test_param_precedence_ordering(document, comm):
    class Test(param.Parameterized):
        a = param.Number(default=1.2, bounds=(0, 5), precedence=-1)
        b = param.Boolean(default=True, precedence=1)

    test = Test()
    test_pane = Pane(test)

    # Check changing precedence attribute hides and shows widget
    a_param = test.param['a']
    a_param.precedence = 2
    assert test_pane._widget_box.objects == [test_pane._widgets[w] for w in ('_title', 'b', 'a')]

    a_param.precedence = 1
    assert test_pane._widget_box.objects == [test_pane._widgets[w] for w in ('_title', 'a', 'b')] 
开发者ID:holoviz,项目名称:panel,代码行数:17,代码来源:test_param.py


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