Exemple #1
0
 def __init__(self, c_value):
     dom = Rcomp()
     dom.belongs(c_value)
     cod = dom
     Map.__init__(self, dom=dom, cod=cod)
     self.c = c_value
     
     self.top = dom.get_top()
 def generate_dp(self, _):
     return SqrtRDP(Rcomp())
Exemple #3
0
 def __init__(self, value):
     F = R = unit = Rcomp()
     unit.belongs(value)
     amap = InvMultValueMap(F, R, unit, value)
     amap_dual = InvMultDualValueMap(R, F, unit, value)
     WrapAMap.__init__(self, amap, amap_dual)
Exemple #4
0
 def get_promoted(s):
     if isinstance(s, Nat):
         return Rcomp()
     else:
         assert isinstance(s, Rcomp)
         return s
Exemple #5
0
 def __init__(self):
     R = Rcomp()
     self.S = PosetProduct((PosetProduct((R, R)), R))
Exemple #6
0
 def __init__(self, n):
     P = Rcomp()
     dom = PosetProduct((P, ) * n)
     cod = P
     self.n = n
     Map.__init__(self, dom, cod)
Exemple #7
0
def check_lang85():  # TODO: rename
    a = Rcomp()
    b = Rcomp()
    assert a.__eq__(b)
    assert a == b
Exemple #8
0
def InvMultValueRcompDP3top():
    return InvMultValueRcompDP(Rcomp().get_top())
Exemple #9
0
 def __init__(self, c_value):
     dom = Rcomp()
     dom.belongs(c_value)
     cod = dom
     Map.__init__(self, dom=dom, cod=cod)
     self.c_value = c_value
Exemple #10
0
 def __init__(self, c):
     cod = dom = Rcomp()
     dom.belongs(c)
     self.c = c
     Map.__init__(self, dom, cod)
Exemple #11
0
 def __init__(self, n):
     R = Rcomp()
     Fs = (R, ) * n
     amap = ProductNMap(Fs, R)
     self.Fs = Fs
     WrapAMap.__init__(self, amap, None)
Exemple #12
0
def eval_constant_space_custom_value(op, context):
    from .eval_space_imp import eval_space
    assert isinstance(op, CDP.SpaceCustomValue)
    space = eval_space(op.space, context)
    custom_string = op.custom_string
#     print('custom string %r' % (custom_string).__repr__())
    if isinstance(space, FiniteCollectionAsSpace):
        if custom_string == '*':
            if len(space.elements) == 1:
                value = list(space.elements)[0]
                return ValueWithUnits(unit=space, value=value)
            else:
                msg = 'You can use "*" only if the space has one element.'
                raise_desc(DPSemanticError, msg, elements=space.elements)
        try:
            space.belongs(custom_string)
            mcdp_dev_warning('this does not seem to work...')
        except NotBelongs:
            msg = 'The value "%s" is not an element of this poset.' % custom_string
            msg += '\n\nThese are the valid values: ' + ", ".join(map(str, space.elements)) + '.'
            raise_desc(DPSemanticError, msg)

        return ValueWithUnits(unit=space, value=op.custom_string)
    
    if isinstance(space, Nat):
        if isinstance(custom_string, CDP.ValueExpr):
            value = int(custom_string.value) # XXX: warn
            if value != custom_string.value:
                msg = 'Invalid value %s' % value
                raise_desc(DPSemanticError, msg, value=value, value0=custom_string.value)
        elif isinstance(custom_string, str):
            value = int(custom_string)
        else:
            msg = 'Cannot interpret value.'
            raise_desc(DPInternalError, msg, custom_string=custom_string)
        return ValueWithUnits(unit=Nat(), value=value)

    if isinstance(space, Int):
        mcdp_dev_warning('Top?')
        if isinstance(custom_string, CDP.ValueExpr):
            value = int(custom_string.value) # XXX: warn
            if value != custom_string.value:
                msg = 'Invalid value %s' % value
                raise_desc(DPSemanticError, msg, value=value, value0=custom_string.value)
        elif isinstance(custom_string, str):
            value = int(custom_string)
        else:
            msg = 'Cannot interpret value.'
            raise_desc(DPInternalError, msg, custom_string=custom_string)
        
        return ValueWithUnits(unit=Int(), value=value)

    if isinstance(space, Rcomp):
        mcdp_dev_warning('Top?')
        if isinstance(custom_string, CDP.ValueExpr):
            value = float(custom_string.value)
        elif isinstance(custom_string, str):
            value = float(custom_string)
        else:
            msg = 'Cannot interpret value.'
            raise_desc(DPInternalError, msg, custom_string=custom_string)
        return ValueWithUnits(unit=Rcomp(), value=value)
        
    msg = 'Custom parsing not implemented for space.'
    raise_desc(DPInternalError, msg, space=space, custom_string=custom_string)
Exemple #13
0
def eval_constant_RcompConstant(op, context):  # @UnusedVariable
    return ValueWithUnits(unit=Rcomp(), value=op.value)
Exemple #14
0
 def Rcomp_from_Nat(value):
     if is_top(Nat(), value):
         val = Rcomp().get_top()
     else:
         val = float(value)
     return val
Exemple #15
0
def MinusValueRcompDP2():
    U = Rcomp()
    v = U.get_top()
    return MinusValueRcompDP(v)
Exemple #16
0
 def get_arguments_type(self):
     return (OpSpecExactly(Rcomp()), )
Exemple #17
0
def MinusValueRcompDP2():
    U = Rcomp()
    v = U.get_top()
    return MinusValueRcompDP(v)
Exemple #18
0
def check_lang85(): # TODO: rename
    a = Rcomp()
    b = Rcomp()
    assert a.__eq__(b)
    assert a == b