Example #1
0
def eval_constant_Minimals(op, context):
    from .eval_space_imp import eval_space  # @Reimport
    space = eval_space(op.space, context)
    elements = space.get_minimal_elements()
    v = FiniteCollection(elements=elements, S=space)
    S = FiniteCollectionsInclusion(space)
    return ValueWithUnits(unit=S, value=v)
Example #2
0
def make_rcompunit(units):
    try:
        s = units.strip()

        mcdp_dev_warning('obsolete?')
        if s.startswith('set of'):
            t = s.split('set of')
            u = make_rcompunit(t[1])
            from mcdp_posets import FiniteCollectionsInclusion
            return FiniteCollectionsInclusion(u)

        mcdp_dev_warning('obsolete?')
        if s == 'any':
            return BottomCompletion(TopCompletion(Any()))

        if s == 'R':
            raise DPSyntaxError(
                'Form R is not recognized anymore. Use "dimensionless".')

            s = 'm/m'

        unit = parse_pint(s)
    except DPSyntaxError:
        raise


#         msg = 'Cannot parse the unit %r.' % units
#         raise_wrapped(DPSemanticError, e, msg, compact=True, exc=sys.exc_info())

    return RcompUnits(unit, s)
Example #3
0
def eval_EmptySet(op, context):
    check_isinstance(op, CDP.EmptySet)
    from .eval_space_imp import eval_space
    space = eval_space(op.space, context)

    P = FiniteCollectionsInclusion(space)
    value = FiniteCollection(set([]), space)
    return ValueWithUnits(unit=P, value=value)
Example #4
0
def eval_constant_collection(op, context):
    ops = get_odd_ops(unwrap_list(op.elements))
    if len(ops) == 0:
        raise DPSemanticError('empty list')
    elements = [eval_constant(_, context) for _ in ops]

    e0 = elements[0]

    u0 = e0.unit

    elements = [_.cast_value(u0) for _ in elements]

    value = FiniteCollection(set(elements), u0)
    unit = FiniteCollectionsInclusion(u0)
    vu = ValueWithUnits(value, unit)
    return vu
Example #5
0
def eval_space_powerset(r, context):
    P = eval_space(r.space, context)
    return FiniteCollectionsInclusion(P)
Example #6
0
 def __init__(self, f):
     from mcdp_posets import FiniteCollectionsInclusion
     dom = FiniteCollectionsInclusion(f.get_domain())
     cod = FiniteCollectionsInclusion(f.get_codomain())
     self.f = f
     Map.__init__(self, dom=dom, cod=cod)