Ejemplo n.º 1
0
    def __init__(self, F, R, unit, value):
        check_isinstance(F, RcompUnits)
        check_isinstance(R, RcompUnits)
        check_isinstance(unit, RcompUnits)

        try:
            check_mult_units_consistency(F, unit, R)
        except AssertionError as e:
            msg = 'Invalid units.'
            raise_wrapped(ValueError, e, msg, F=F, R=R, unit=unit)

        amap = MultValueMap(F=F, R=R, unit=unit, value=value)

        # if value = Top:
        #    f |-> f * Top
        #
        if is_top(unit, value):
            amap_dual = MultValueDPHelper2Map(R, F)
        elif unit.equal(0.0, value):
            amap_dual = ConstantPosetMap(R, F, F.get_top())
        else:
            value2 = 1.0 / value
            unit2 = inverse_of_unit(unit)
            amap_dual = MultValueMap(F=R, R=F, unit=unit2, value=value2)

        WrapAMap.__init__(self, amap, amap_dual)
Ejemplo n.º 2
0
    def __init__(self, F, R, unit, value):
        check_isinstance(F, RcompUnits)
        check_isinstance(R, RcompUnits)
        check_isinstance(unit, RcompUnits)
        
        try:
            check_mult_units_consistency(F, unit, R)
        except AssertionError as e:
            msg = 'Invalid units.'
            raise_wrapped(ValueError, e, msg, F=F, R=R, unit=unit)

        amap = MultValueMap(F=F, R=R, unit=unit, value=value)
        
        # if value = Top:
        #    f |-> f * Top 
        #     
        if is_top(unit, value):
            amap_dual = MultValueDPHelper2Map(R, F)
        elif unit.equal(0.0, value):
            amap_dual = ConstantPosetMap(R, F, F.get_top())
        else:    
            value2 = 1.0 / value
            unit2 = inverse_of_unit(unit)
            amap_dual = MultValueMap(F=R, R=F, unit=unit2, value=value2)
            
        WrapAMap.__init__(self, amap, amap_dual)
Ejemplo n.º 3
0
    def __init__(self, dom, cod, space, value):
        if isinstance(dom, RcompUnits):
            check_isinstance(cod, RcompUnits)
            check_isinstance(space, RcompUnits)
            # cod * space = dom
            check_mult_units_consistency(cod, space, dom)
        else:
            check_isinstance(dom, Rcomp)
            check_isinstance(cod, Rcomp)
            check_isinstance(space, Rcomp)

        space.belongs(value)
        self.value = value
        self.space = space
        # XXX: not sure about the units
        # assert (dom * space = cod)
        Map.__init__(self, dom, cod)
Ejemplo n.º 4
0
 def __init__(self, dom, cod, space, value):
     if isinstance(dom, RcompUnits):
         check_isinstance(cod, RcompUnits)
         check_isinstance(space, RcompUnits)
         # cod * space = dom
         check_mult_units_consistency(cod, space, dom)
     else:
         check_isinstance(dom, Rcomp)
         check_isinstance(cod, Rcomp)
         check_isinstance(space, Rcomp)
          
     space.belongs(value)
     self.value = value
     self.space = space
     # XXX: not sure about the units
     # assert (dom * space = cod)
     Map.__init__(self, dom, cod)
Ejemplo n.º 5
0
    def __init__(self, F, R, unit, value):
        """ r * c >= f """
        if isinstance(F, RcompUnits):
            check_isinstance(R, RcompUnits)
            check_isinstance(unit, RcompUnits)
            try:
                check_mult_units_consistency(R, unit, F)
            except AssertionError as e:
                msg = 'Invalid units.'
                raise_wrapped(AssertionError, e, msg, F=F, R=R, unit=unit)

        else:
            check_isinstance(F, Rcomp)
            check_isinstance(R, Rcomp)
            check_isinstance(unit, Rcomp)

        unit.belongs(value)
        amap = InvMultValueMap(F, R, unit, value)
        amap_dual = InvMultDualValueMap(R, F, unit, value)
        WrapAMap.__init__(self, amap, amap_dual)
Ejemplo n.º 6
0
 def __init__(self, F, R, unit, value):
     """ r * c >= f """ 
     if isinstance(F, RcompUnits):
         check_isinstance(R, RcompUnits)
         check_isinstance(unit, RcompUnits)
         try:
             check_mult_units_consistency(R, unit, F)
         except AssertionError as e:
             msg = 'Invalid units.'
             raise_wrapped(AssertionError, e, msg, F=F,R=R,unit=unit)
             
     else:
         check_isinstance(F, Rcomp)
         check_isinstance(R, Rcomp)
         check_isinstance(unit, Rcomp)
         
     unit.belongs(value)
     amap = InvMultValueMap(F, R, unit, value)
     amap_dual = InvMultDualValueMap(R, F, unit, value)    
     WrapAMap.__init__(self, amap, amap_dual)