示例#1
0
def located(
    arg1s: Union[_ObjectT, Iterable[_ObjectT]],
    arg2s: Union[_ObjectT, Iterable[_ObjectT]],
    *,
    distance: Distance,
    # We need to do `Direction[Any]` because we can't infer the generic type
    # when a GeonAxis is used as the relative_to_axis.
    # Using Any here let's use isolate the type:ignores to this function.
    direction: Direction[Any],
) -> Tuple[Relation[_ObjectT]]:
    """
    All *arg1s* are located with at the given `Distance` and `Direction`
    with respect to *args2*.

    It is usually better to use more specialized relations derived using
    `make_opposite_dsl_region_relation`, etc.,
    but then can be useful when you need, for example, to refer to particular concrete axes.
    """
    arg1s = _ensure_iterable(arg1s)
    arg2s = _ensure_iterable(arg2s)

    return flatten([
        tuple(
            Relation(IN_REGION, arg1,
                     Region(arg2, distance=distance, direction=direction))
            for arg1 in arg1s for arg2 in arg2s),
        tuple(
            Relation(
                IN_REGION,
                arg2,
                Region(arg1, distance=distance,
                       direction=direction.opposite()),
            ) for arg1 in arg1s for arg2 in arg2s),
    ])
示例#2
0
 def dsl_relation_function(
     arg1s: Union[_ObjectT, Iterable[_ObjectT]],
     arg2s: Union[_ObjectT, Iterable[_ObjectT]],
 ) -> Tuple[Relation[_ObjectT], ...]:
     return tuple(
         Relation(relation_type, arg1, arg2)
         for arg1 in _ensure_iterable(arg1s)
         for arg2 in _ensure_iterable(arg2s))
示例#3
0
 def dsl_relation_function(
     arg1s: Union[_ObjectT, Iterable[_ObjectT]],
     arg2s: Union[_ObjectT, Iterable[_ObjectT]],
     **kw_args,
 ) -> Tuple["Relation[_ObjectT]", ...]:
     return tuple(
         Relation(IN_REGION, arg1, region_factory(arg2, **kw_args))
         for arg1 in _ensure_iterable(arg1s)
         for arg2 in _ensure_iterable(arg2s))
示例#4
0
 def dsl_opposite_function(
     arg1s: Union[_ObjectT, Iterable[_ObjectT]],
     arg2s: Union[_ObjectT, Iterable[_ObjectT]],
 ) -> Tuple[Relation[_ObjectT], ...]:
     arg1s = _ensure_iterable(arg1s)
     arg2s = _ensure_iterable(arg2s)
     return flatten([
         tuple(
             Relation(relation_type, arg1, arg2) for arg1 in arg1s
             for arg2 in arg2s),
         tuple(
             Relation(opposite_type, arg2, arg1) for arg1 in arg1s
             for arg2 in arg2s),
     ])
示例#5
0
 def dsl_relation_function(
     arg1s: Union[_ObjectT, Iterable[_ObjectT]],
     arg2s: Union[_ObjectT, Iterable[_ObjectT]],
     **kw_args,
 ) -> Tuple["Relation[_ObjectT]", ...]:
     arg1s = _ensure_iterable(arg1s)
     arg2s = _ensure_iterable(arg2s)
     return flatten([
         tuple(
             Relation(IN_REGION, arg1, region_factory(arg2, **kw_args))
             for arg1 in arg1s for arg2 in arg2s),
         tuple(
             Relation(IN_REGION, arg2, region_factory(arg1, **kw_args))
             for arg1 in arg1s for arg2 in arg2s),
     ])