Beispiel #1
0
    def test_bare_bones(self):
        left, right = Direction.get_directions(Direction.LEFT)
        assert left, "Direction.get_directions(Direction.LEFT)"
        assert not right, "Direction.get_directions(Direction.LEFT)"

        left, right = Direction.get_directions(Direction.RIGHT)
        assert not left, "Direction.get_directions(R)"
        assert right, "Direction.get_directions(R)"

        assert Direction.get_opposite(Direction.LEFT) == Direction.RIGHT
        assert Direction.get_opposite(Direction.RIGHT) == Direction.LEFT

        assert RouterReflect.check_position_partition_tree(
            Direction.LEFT, None, .2, .7), "isn't it on the left ?"
        assert RouterReflect.check_position_partition_tree(
            Direction.RIGHT, None, .7, .2), "isn't it on the right ?"

        print("#0 : directions tests passed")
        return True
Beispiel #2
0
    def test_bare_bones(self):
        left, right = Direction.get_directions(Direction.LEFT)
        assert left, "Direction.get_directions(Direction.LEFT)"
        assert not right, "Direction.get_directions(Direction.LEFT)"

        left, right = Direction.get_directions(Direction.RIGHT)
        assert not left, "Direction.get_directions(R)"
        assert right, "Direction.get_directions(R)"

        assert Direction.get_opposite(Direction.LEFT) == Direction.RIGHT
        assert Direction.get_opposite(Direction.RIGHT) == Direction.LEFT

        assert RouterReflect.check_position_partition_tree(
            Direction.LEFT,None,.2,.7), "isn't it on the left ?"
        assert RouterReflect.check_position_partition_tree(
            Direction.RIGHT,None,.7,.2), "isn't it on the right ?"

        print("#0 : directions tests passed")
        return True
Beispiel #3
0
    def which_side_space(self, space_part, forking=False):
        """ Indicates to which side of the node belongs the 'space_part'.
            'Left' means one of the internal nodes would have to be followed
            to the left instead so that the desired part is reached.
        """
        nb_here = 0
        here, left, right = False, False, False
        for inode in self.__internal_nodes:

            if(not space_part.exists(inode.dimension)):
                if (not forking):
                    raise CPEMissingDimension(
                        "Mandatory dimension %s isn't defined in %s"%
                        (repr(inode.dimension),repr(space_part)), inode.dimension)
                else:
                    # no clue, a split is required.
                    # - here? is still undefined: further inodes could invalidate it.
                    # - left? or right? will be set depending on our own direction
                    #   on the offending inode.
                    (l,r) = Direction.get_directions(Direction.get_opposite(inode.direction))
                    left |=l ; right |=r
                    nb_here+=1
            else:
                try:
                    m_range = space_part.get_component(inode.dimension)

                    if(inode.is_here(m_range)):
                        nb_here += 1
                        left |= inode.is_more_on_the_left(m_range)
                        right |= inode.is_more_on_the_right(m_range)
                        
                    else:
                        # The range is managed by the opposite side. @test1171706
                        # 0_0 opposite_side = Direction.get_opposite(inode.dimension.direction)
                        opposite_side = Direction.get_opposite(inode.direction)
                        left |= (opposite_side == Direction.LEFT)
                        right |= (opposite_side == Direction.RIGHT)
                        break
                    # you need all the dimensions to say 'it's here' so that it's actually here.
                except:
                    raise ValueError("Component %s of %s is of unknown type: %s"%(
                        repr(inode.dimension),repr(space_part),repr(m_range)))
        here |= (nb_here == len(self.__internal_nodes))
        assert True == left | here | right, "The request coudn't be oriented."

        return [left, here, right]