• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python equality.optSame函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中typhon.objects.equality.optSame函数的典型用法代码示例。如果您正苦于以下问题:Python optSame函数的具体用法?Python optSame怎么用?Python optSame使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: testRefEqualitySettled

 def testRefEqualitySettled(self):
     with scopedVat(testingVat()):
         first, r = makePromise()
         r.resolve(IntObject(42))
         second, r = makePromise()
         r.resolve(IntObject(42))
         self.assertEqual(optSame(first, second), EQUAL)
开发者ID:dckc,项目名称:typhon,代码行数:7,代码来源:test_equality.py


示例2: testListEqualityRecursion

 def testListEqualityRecursion(self):
     # Yes, this is very hacky.
     first = ConstList([IntObject(42)])
     first.strategy.append(first, [first])
     second = ConstList([IntObject(42)])
     second.strategy.append(second, [second])
     self.assertEqual(optSame(first, second), EQUAL)
开发者ID:markrwilliams,项目名称:typhon,代码行数:7,代码来源:test_equality.py


示例3: eq

 def eq(self, other):
     if not isinstance(other, Proxy):
         return False
     if self.checkSlot() or other.checkSlot():
         raise userError(u"equals comparison of resolved proxy is"
                         u" impossible")
     return optSame(self.handler, other.handler) is EQUAL
开发者ID:monte-language,项目名称:typhon,代码行数:7,代码来源:proxy.py


示例4: testListEqualityRecursion

 def testListEqualityRecursion(self):
     first = wrapList([IntObject(42), NullObject])
     # Hax.
     first.objs.append(first)
     second = wrapList([IntObject(42), NullObject])
     # Hax.
     second.objs.append(second)
     self.assertEqual(optSame(first, second), EQUAL)
开发者ID:dckc,项目名称:typhon,代码行数:8,代码来源:test_equality.py


示例5: startOf

 def startOf(self, needleList, start=0):
     # This is quadratic. It could be better.
     from typhon.objects.equality import EQUAL, optSame
     for index in range(start, self.strategy.size(self)):
         for needleIndex, needle in enumerate(needleList):
             offset = index + needleIndex
             if optSame(self.strategy.fetch(self, offset), needle) is not EQUAL:
                 break
             return index
     return -1
开发者ID:markrwilliams,项目名称:typhon,代码行数:10,代码来源:lists.py


示例6: recv

    def recv(self, atom, args):
        from typhon.nodes import Noun, Method, Obj
        from typhon.objects.equality import optSame, EQUAL
        from typhon.objects.user import Audition

        if atom is _UNCALL_0:
            from typhon.objects.collections.maps import EMPTY_MAP

            return ConstList([subrangeGuardMaker, StrObject(u"get"), ConstList([self.superGuard]), EMPTY_MAP])

        if atom is AUDIT_1:
            audition = args[0]
            if not isinstance(audition, Audition):
                raise userError(u"not invoked with an Audition")
            ast = audition.ast
            if not isinstance(ast, Obj):
                raise userError(u"audition not created with an object expr")
            methods = ast._script._methods
            for m in methods:
                if isinstance(m, Method) and m._verb == u"coerce":
                    mguard = m._g
                    if isinstance(mguard, Noun):
                        rGSG = audition.getGuard(mguard.name)
                        if isinstance(rGSG, FinalSlotGuard):
                            rGSG0 = rGSG.valueGuard
                            if isinstance(rGSG0, SameGuard):
                                resultGuard = rGSG0.value

                                if optSame(resultGuard, self.superGuard) is EQUAL or (
                                    SUPERSETOF_1 in self.superGuard.respondingAtoms()
                                    and self.superGuard.call(u"supersetOf", [resultGuard]) is wrapBool(True)
                                ):
                                    return wrapBool(True)
                                raise userError(
                                    u"%s does not have a result guard implying "
                                    u"%s, but %s" % (audition.fqn, self.superGuard.toQuote(), resultGuard.toQuote())
                                )
                            raise userError(
                                u"%s does not have a determinable "
                                u"result guard, but <& %s> :%s" % (audition.fqn, mguard.name, rGSG.toQuote())
                            )
                    break
            return self
        if atom is PASSES_1:
            return wrapBool(args[0].auditedBy(self))
        if atom is COERCE_2:
            specimen, ej = args[0], args[1]
            if specimen.auditedBy(self):
                return specimen
            c = specimen.call(u"_conformTo", [self])
            if c.auditedBy(self):
                return c
            throw(ej, StrObject(u"%s does not conform to %s" % (specimen.toQuote(), self.toQuote())))

        raise Refused(self, atom, args)
开发者ID:markrwilliams,项目名称:typhon,代码行数:55,代码来源:guards.py


示例7: _startOf

 def _startOf(self, needleCL, start):
     if start < 0:
         raise userError(u"startOf/2: Negative start %d not permitted" %
                 start)
     # This is quadratic. It could be better.
     from typhon.objects.equality import EQUAL, optSame
     for index in range(start, len(self.objs)):
         for needleIndex, needle in enumerate(needleCL):
             offset = index + needleIndex
             if optSame(self.objs[offset], needle) is not EQUAL:
                 break
             return index
     return -1
开发者ID:dckc,项目名称:typhon,代码行数:13,代码来源:lists.py


示例8: auditedBy

    def auditedBy(self, prospect):
        """
        Whether a prospective stamp has been left on this object.
        """

        # The number of different objects that will pass through here is
        # surprisingly low; consider how Python would look if metaclasses were
        # promoted.
        prospect = promote(prospect)

        from typhon.objects.equality import optSame, EQUAL

        # Already audited with an identical stamp?
        for stamp in self.auditorStamps():
            if optSame(prospect, stamp) is EQUAL:
                return True

        # Sorry, but nope.
        return False
开发者ID:washort,项目名称:typhon,代码行数:19,代码来源:root.py


示例9: audit

    def audit(self, audition):
        from typhon.nodes import Noun, Method, Obj
        from typhon.objects.equality import optSame, EQUAL
        from typhon.objects.user import Audition
        if not isinstance(audition, Audition):
            raise userError(u"not invoked with an Audition")
        ast = audition.ast
        if not isinstance(ast, Obj):
            raise userError(u"audition not created with an object expr")
        methods = ast._script._methods
        for m in methods:
            if isinstance(m, Method) and m._verb == u"coerce":
                mguard = m._g
                if isinstance(mguard, Noun):
                    rGSG = audition.getGuard(mguard.name)
                    if isinstance(rGSG, FinalSlotGuard):
                        rGSG0 = rGSG.valueGuard
                        if isinstance(rGSG0, SameGuard):
                            resultGuard = rGSG0.value

                            if (optSame(resultGuard, self.superGuard)
                                is EQUAL or
                                (self.superGuard.call(u"supersetOf",
                                    [resultGuard])
                                 is wrapBool(True))):
                                return True
                            raise userError(
                                u"%s does not have a result guard implying "
                                u"%s, but %s" % (audition.fqn,
                                                 self.superGuard.toQuote(),
                                                 resultGuard.toQuote()))
                        raise userError(u"%s does not have a determinable "
                                        u"result guard, but <& %s> :%s" % (
                                            audition.fqn, mguard.name,
                                            rGSG.toQuote()))
                break
        return False
开发者ID:monte-language,项目名称:typhon,代码行数:37,代码来源:guards.py


示例10: indexOf

 def indexOf(self, needle):
     from typhon.objects.equality import EQUAL, optSame
     for index, specimen in enumerate(self.objs):
         if optSame(needle, specimen) is EQUAL:
             return index
     return -1
开发者ID:dckc,项目名称:typhon,代码行数:6,代码来源:lists.py


示例11: testListEqualityRecursionReflexive

 def testListEqualityRecursionReflexive(self):
     first = ConstList([IntObject(42)])
     first.strategy.append(first, [first])
     self.assertEqual(optSame(first, first), EQUAL)
开发者ID:markrwilliams,项目名称:typhon,代码行数:4,代码来源:test_equality.py


示例12: contains

 def contains(self, needle):
     from typhon.objects.equality import EQUAL, optSame
     for specimen in self.objs:
         if optSame(needle, specimen) is EQUAL:
             return True
     return False
开发者ID:dckc,项目名称:typhon,代码行数:6,代码来源:lists.py


示例13: testListEquality

 def testListEquality(self):
     first = wrapList([IntObject(42)])
     second = wrapList([IntObject(42)])
     self.assertEqual(optSame(first, second), EQUAL)
开发者ID:dckc,项目名称:typhon,代码行数:4,代码来源:test_equality.py


示例14: testListEqualityRecursionReflexive

 def testListEqualityRecursionReflexive(self):
     first = wrapList([IntObject(42), NullObject])
     # Hax.
     first.objs.append(first)
     self.assertEqual(optSame(first, first), EQUAL)
开发者ID:dckc,项目名称:typhon,代码行数:5,代码来源:test_equality.py


示例15: testStrInequality

 def testStrInequality(self):
     first = StrObject(u"false")
     second = StrObject(u"true")
     self.assertEqual(optSame(first, second), INEQUAL)
开发者ID:dckc,项目名称:typhon,代码行数:4,代码来源:test_equality.py


示例16: testDoubleEquality

 def testDoubleEquality(self):
     first = DoubleObject(4.2)
     second = DoubleObject(4.2)
     self.assertEqual(optSame(first, second), EQUAL)
开发者ID:dckc,项目名称:typhon,代码行数:4,代码来源:test_equality.py


示例17: testDoubleEqualityNaN

 def testDoubleEqualityNaN(self):
     first = DoubleObject(float("nan"))
     second = DoubleObject(float("nan"))
     self.assertEqual(optSame(first, second), EQUAL)
开发者ID:dckc,项目名称:typhon,代码行数:4,代码来源:test_equality.py


示例18: keyEq

def keyEq(first, second):
    from typhon.objects.equality import optSame, EQUAL
    first = resolveKey(first)
    second = resolveKey(second)
    return optSame(first, second) is EQUAL
开发者ID:markrwilliams,项目名称:typhon,代码行数:5,代码来源:helpers.py


示例19: testCharEquality

 def testCharEquality(self):
     first = CharObject(u'c')
     second = CharObject(u'c')
     self.assertEqual(optSame(first, second), EQUAL)
开发者ID:dckc,项目名称:typhon,代码行数:4,代码来源:test_equality.py


示例20: testListInequalityLength

 def testListInequalityLength(self):
     first = wrapList([IntObject(42)])
     second = wrapList([IntObject(42), IntObject(5)])
     self.assertEqual(optSame(first, second), INEQUAL)
开发者ID:dckc,项目名称:typhon,代码行数:4,代码来源:test_equality.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python refs.resolution函数代码示例发布时间:2022-05-27
下一篇:
Python data.StrObject类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap