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


Python operator.is_not方法代码示例

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


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

示例1: test_operator

# 需要导入模块: import operator [as 别名]
# 或者: from operator import is_not [as 别名]
def test_operator(self):
        import operator
        self.assertIs(operator.truth(0), False)
        self.assertIs(operator.truth(1), True)
        with test_support.check_py3k_warnings():
            self.assertIs(operator.isCallable(0), False)
            self.assertIs(operator.isCallable(len), True)
        self.assertIs(operator.isNumberType(None), False)
        self.assertIs(operator.isNumberType(0), True)
        self.assertIs(operator.not_(1), False)
        self.assertIs(operator.not_(0), True)
        self.assertIs(operator.isSequenceType(0), False)
        self.assertIs(operator.isSequenceType([]), True)
        self.assertIs(operator.contains([], 1), False)
        self.assertIs(operator.contains([1], 1), True)
        self.assertIs(operator.isMappingType(1), False)
        self.assertIs(operator.isMappingType({}), True)
        self.assertIs(operator.lt(0, 0), False)
        self.assertIs(operator.lt(0, 1), True)
        self.assertIs(operator.is_(True, True), True)
        self.assertIs(operator.is_(True, False), False)
        self.assertIs(operator.is_not(True, True), False)
        self.assertIs(operator.is_not(True, False), True) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:test_bool.py

示例2: trans_result

# 需要导入模块: import operator [as 别名]
# 或者: from operator import is_not [as 别名]
def trans_result(self, rv, op_name, threshold):
        """
            对结果进行转化,最后结果为 True/False 标识是否命中
        :param bool|None rv: 内置函数返回值
        :param str|unicode op_name: 操作符
        :param object threshold: 阈值
        :return:
        """
        #  若想忽略op码永远通过则设置rv为None
        if rv is None:
            return False

        if op_name in {'is', 'is_not'}:
            threshold = True
        elif self.threshold_trans_func:
            threshold = self.threshold_trans_func(threshold)

        method = self.op_map.get(op_name, None)
        return method(rv, threshold) if method else False 
开发者ID:momosecurity,项目名称:aswan,代码行数:21,代码来源:base.py

示例3: test_operator

# 需要导入模块: import operator [as 别名]
# 或者: from operator import is_not [as 别名]
def test_operator(self):
        import operator
        self.assertIs(operator.truth(0), False)
        self.assertIs(operator.truth(1), True)
        self.assertIs(operator.isCallable(0), False)
        self.assertIs(operator.isCallable(len), True)
        self.assertIs(operator.isNumberType(None), False)
        self.assertIs(operator.isNumberType(0), True)
        self.assertIs(operator.not_(1), False)
        self.assertIs(operator.not_(0), True)
        self.assertIs(operator.isSequenceType(0), False)
        self.assertIs(operator.isSequenceType([]), True)
        self.assertIs(operator.contains([], 1), False)
        self.assertIs(operator.contains([1], 1), True)
        self.assertIs(operator.isMappingType(1), False)
        self.assertIs(operator.isMappingType({}), True)
        self.assertIs(operator.lt(0, 0), False)
        self.assertIs(operator.lt(0, 1), True)
        self.assertIs(operator.is_(True, True), True)
        self.assertIs(operator.is_(True, False), False)
        self.assertIs(operator.is_not(True, True), False)
        self.assertIs(operator.is_not(True, False), True) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:24,代码来源:test_bool.py

示例4: __init__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import is_not [as 别名]
def __init__(self, tokens):
        super().__init__(tokens)
        self.operator_map = {
            "<": operator.lt,
            "<=": operator.le,
            ">": operator.gt,
            ">=": operator.ge,
            "==": operator.eq,
            "!=": operator.ne,
            "in": EvalLogic.in_,
            "not in": EvalLogic.not_in,
            "is": operator.is_,
            "is not": operator.is_not,
            "isdisjoint": lambda a, b: a.isdisjoint(b),
            "and": operator.and_,
            "or": operator.or_,
        } 
开发者ID:scVENUS,项目名称:PeekabooAV,代码行数:19,代码来源:expressions.py

示例5: from_str

# 需要导入模块: import operator [as 别名]
# 或者: from operator import is_not [as 别名]
def from_str(cls, version_str):
        """ Parse version information from a string. """
        matches = Semver.SEMVER_RE.match(version_str)
        if matches:
            args = list(matches.groups())
            if not matches.group(3):
                args.append('0')
            return Semver(*map(int, filter(partial(is_not, None), args)))

        parts = parse(version_str)

        return cls(
            parts['major'],
            parts['minor'],
            parts['patch'],
            parts['prerelease'],
            parts['build']
        ) 
开发者ID:hyperledger,项目名称:aries-staticagent-python,代码行数:20,代码来源:type.py

示例6: iter_compare_dicts

# 需要导入模块: import operator [as 别名]
# 或者: from operator import is_not [as 别名]
def iter_compare_dicts(dict1, dict2, only_common_keys=False, comparison_op=operator.ne):
    """
    A generator for comparation of values in the given two dicts.

    Yields the tuples (key, pair of values positively compared).

    By default, the *difference* of values is evaluated using the usual != op, but can be changed
    by passing other comparison_op (a function of two arguments returning True/False).

    For example: operator.eq for equal values, operator.is_not for not identical objects.

    You can also require comparison only over keys existing in both dicts (only_common_keys=True).
    Otherwise, you will get the pair with the Python built-in Ellipsis placed for dict with
    that key missing. (Be sure to test for Ellipsis using the 'is' operator.)

    >>> d1 = dict(a=1, b=2, c=3)
    >>> d2 = dict(a=1, b=20, d=4)
    >>> dict(iter_compare_dicts(d1, d2, only_common_keys=True))
    {'b': (2, 20)}
    >>> dict(iter_compare_dicts(d1, d2, only_common_keys=True, comparison_op=operator.eq))
    {'a': (1, 1)}
    >>> dict(iter_compare_dicts(d1, d2))
    {'c': (3, Ellipsis), 'b': (2, 20), 'd': (Ellipsis, 4)}
    >>> dict(iter_compare_dicts(d1, d2, comparison_op=operator.eq))
    {'a': (1, 1), 'c': (3, Ellipsis), 'd': (Ellipsis, 4)}
    """
    keyset1, keyset2 = set(dict1), set(dict2)

    for key in (keyset1 & keyset2):
        pair = (dict1[key], dict2[key])
        if reduce(comparison_op, pair):
            yield key, pair

    if not only_common_keys:
        for key in (keyset1 - keyset2):
            yield key, (dict1[key], Ellipsis)
        for key in (keyset2 - keyset1):
            yield key, (Ellipsis, dict2[key]) 
开发者ID:udger,项目名称:udger-python,代码行数:40,代码来源:runtests.py

示例7: test_is_not

# 需要导入模块: import operator [as 别名]
# 或者: from operator import is_not [as 别名]
def test_is_not(self):
        a = b = 'xyzpdq'
        c = a[:3] + b[3:]
        self.assertRaises(TypeError, operator.is_not)
        self.assertFalse(operator.is_not(a, b))
        self.assertTrue(operator.is_not(a,c)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_operator.py

示例8: reduce

# 需要导入模块: import operator [as 别名]
# 或者: from operator import is_not [as 别名]
def reduce(self, func):
        rs = [r.result() for r in self._submit_to_pool(func, do_reduce)]
        rs = [r for r in filter(partial(is_not, None), rs)]
        if len(rs) <= 0:
            return None
        rtn = rs[0]
        for r in rs[1:]:
            rtn = func(rtn, r)
        return rtn 
开发者ID:FederatedAI,项目名称:FATE,代码行数:11,代码来源:eggroll.py

示例9: test_operator

# 需要导入模块: import operator [as 别名]
# 或者: from operator import is_not [as 别名]
def test_operator(self):
        import operator
        self.assertIs(operator.truth(0), False)
        self.assertIs(operator.truth(1), True)
        self.assertIs(operator.not_(1), False)
        self.assertIs(operator.not_(0), True)
        self.assertIs(operator.contains([], 1), False)
        self.assertIs(operator.contains([1], 1), True)
        self.assertIs(operator.lt(0, 0), False)
        self.assertIs(operator.lt(0, 1), True)
        self.assertIs(operator.is_(True, True), True)
        self.assertIs(operator.is_(True, False), False)
        self.assertIs(operator.is_not(True, True), False)
        self.assertIs(operator.is_not(True, False), True) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:16,代码来源:test_bool.py

示例10: execute_agents

# 需要导入模块: import operator [as 别名]
# 或者: from operator import is_not [as 别名]
def execute_agents(self, command: State, agents: List[Agent]) -> List[Union[Action, List[Action]]]:
        with futures.ThreadPoolExecutor(max_workers=self.NUM_WORKERS) as executor:
            done, _ = futures.wait(
                [executor.submit(plugin_instance.execute, command) for plugin_instance in agents],
                timeout=self.MAX_TIME_PLUGIN_EXECUTION)
            if not done:
                return []
            results = map(lambda future: future.result(), done)
            candidate_actions = list(filter(partial(is_not, None), results))
        return candidate_actions


# pylint: disable= invalid-name 
开发者ID:IBM,项目名称:clai,代码行数:15,代码来源:agent_executor.py

示例11: is_not

# 需要导入模块: import operator [as 别名]
# 或者: from operator import is_not [as 别名]
def is_not(x, y):
    """Implementation of the `is not` operator."""
    return not (x is y) 
开发者ID:mila-iqia,项目名称:myia,代码行数:5,代码来源:op_is_not.py

示例12: to_int_arr

# 需要导入模块: import operator [as 别名]
# 或者: from operator import is_not [as 别名]
def to_int_arr(inputs):
    if inputs is not None:
        if isinstance(inputs, six.string_types):
            inputs = re.split(',| ', inputs)
        ints = map(to_int, inputs)
        ret = list(filter(partial(is_not, None), ints))
    else:
        ret = []
    return ret 
开发者ID:emc-openstack,项目名称:storops,代码行数:11,代码来源:converter.py

示例13: test_is_not

# 需要导入模块: import operator [as 别名]
# 或者: from operator import is_not [as 别名]
def test_is_not(self):
        a = b = 'xyzpdq'
        c = a[:3] + b[3:]
        self.failUnlessRaises(TypeError, operator.is_not)
        self.failIf(operator.is_not(a, b))
        self.failUnless(operator.is_not(a,c)) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:8,代码来源:test_operator.py

示例14: compute_npmi

# 需要导入模块: import operator [as 别名]
# 或者: from operator import is_not [as 别名]
def compute_npmi(self, topics, num_words=10):
        """
        Compute global NPMI across topics

        Parameters
        ----------
        topics: ``List[Tuple[str, List[int]]]``
            list of learned topics
        num_words: ``int``
            number of words to compute npmi over
        """
        topics_idx = [[self._ref_vocab_index.get(word)
                       for word in topic[1][:num_words]] for topic in topics]
        rows = []
        cols = []
        res_rows = []
        res_cols = []
        max_seq_len = max([len(topic) for topic in topics_idx])

        for index, topic in enumerate(topics_idx):
            topic = list(filter(partial(is_not, None), topic))
            if len(topic) > 1:
                _rows, _cols = zip(*combinations(topic, 2))
                res_rows.extend([index] * len(_rows))
                res_cols.extend(range(len(_rows)))
                rows.extend(_rows)
                cols.extend(_cols)

        npmi_data = ((np.log10(self.n_docs) + self._npmi_numerator[rows, cols])
                     / (np.log10(self.n_docs) - self._npmi_denominator[rows, cols]))
        npmi_data[npmi_data == 1.0] = 0.0
        npmi_shape = (len(topics), len(list(combinations(range(max_seq_len), 2))))
        npmi = sparse.csr_matrix((npmi_data.tolist()[0], (res_rows, res_cols)), shape=npmi_shape)
        return npmi.mean() 
开发者ID:allenai,项目名称:vampire,代码行数:36,代码来源:vampire.py

示例15: get_records_participated_in_by_user

# 需要导入模块: import operator [as 别名]
# 或者: from operator import is_not [as 别名]
def get_records_participated_in_by_user():
    _current_user_id = int(current_user.get_id())
    as_uploader = SubmissionParticipant.query.filter_by(user_account=_current_user_id, role='uploader').order_by(
        SubmissionParticipant.id.desc()).all()
    as_reviewer = SubmissionParticipant.query.filter_by(user_account=_current_user_id, role='reviewer').order_by(
        SubmissionParticipant.id.desc()).all()

    as_coordinator_query = HEPSubmission.query.filter_by(coordinator=_current_user_id).order_by(
        HEPSubmission.created.desc())

    # special case, since this user ID is the one used for loading all submissions, which is in the 1000s.
    if _current_user_id == 1:
        as_coordinator_query = as_coordinator_query.limit(5)

    as_coordinator = as_coordinator_query.all()

    result = {'uploader': [], 'reviewer': [], 'coordinator': []}
    if as_uploader:
        _uploader = [get_record_contents(x.publication_recid) for x in as_uploader]
        result['uploader'] = filter(partial(is_not, None), _uploader)

    if as_reviewer:
        _uploader = [get_record_contents(x.publication_recid) for x in as_reviewer]
        result['reviewer'] = filter(partial(is_not, None), _uploader)

    if as_coordinator:
        _coordinator = [get_record_contents(x.publication_recid) for x in as_coordinator]
        result['coordinator'] = filter(partial(is_not, None), _coordinator)

    return list(result) 
开发者ID:HEPData,项目名称:hepdata,代码行数:32,代码来源:api.py


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