How to use the orange3.Orange.canvas.utils.check_type function in Orange3

To help you get started, we’ve selected a few Orange3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BioDepot / BioDepot-workflow-builder / orange3 / Orange / canvas / scheme / scheme.py View on Github external
def add_node(self, node):
        """
        Add a node to the scheme. An error is raised if the node is
        already in the scheme.

        Parameters
        ----------
        node : :class:`.SchemeNode`
            Node instance to add to the scheme.

        """
        check_arg(node not in self.__nodes, "Node already in scheme.")
        check_type(node, SchemeNode)

        self.__nodes.append(node)
        log.info("Added node %r to scheme %r." % (node.title, self.title))
        self.node_added.emit(node)
github BioDepot / BioDepot-workflow-builder / orange3 / Orange / canvas / scheme / annotations.py View on Github external
def set_color(self, color):
        """
        Set the fill color for the arrow as a string (`#RGB`, `#RRGGBB`,
        `#RRRGGGBBB`, `#RRRRGGGGBBBB` format or one of SVG color keyword
        names).

        """
        check_type(color, str)
        color = str(color)
        if self.__color != color:
            self.__color = color
            self.color_changed.emit(color)
github BioDepot / BioDepot-workflow-builder / orange3 / Orange / canvas / scheme / annotations.py View on Github external
def set_font(self, font):
        """
        Set the annotation's default font as a dictionary of font properties
        (at the moment only family and size are used).

            >>> annotation.set_font({"family": "Helvetica", "size": 16})

        """
        check_type(font, dict)
        font = dict(font)
        if self.__font != font:
            self.__font = font
            self.font_changed.emit(font)
github BioDepot / BioDepot-workflow-builder / orange3 / Orange / canvas / scheme / scheme.py View on Github external
def add_annotation(self, annotation):
        """
        Add an annotation (:class:`BaseSchemeAnnotation` subclass) instance
        to the scheme.

        """
        check_arg(
            annotation not in self.__annotations,
            "Cannot add the same annotation multiple times.",
        )
        check_type(annotation, BaseSchemeAnnotation)

        self.__annotations.append(annotation)
        self.annotation_added.emit(annotation)
github BioDepot / BioDepot-workflow-builder / orange3 / Orange / canvas / scheme / scheme.py View on Github external
def compatible_channels(self, link):
        """
        Return `True` if the channels in `link` have compatible types.

        Parameters
        ----------
        link : :class:`.SchemeLink`

        """
        check_type(link, SchemeLink)
        return compatible_channels(link.source_channel, link.sink_channel)
github BioDepot / BioDepot-workflow-builder / orange3 / Orange / canvas / scheme / annotations.py View on Github external
def set_text(self, text):
        """
        Set the annotation text.

        Same as `set_content(text, "text/plain")`
        """
        check_type(text, str)
        text = str(text)
        self.set_content(text, "text/plain")
github BioDepot / BioDepot-workflow-builder / orange3 / Orange / canvas / scheme / scheme.py View on Github external
Check if the `link` can be added to the scheme and raise an
        appropriate exception.

        Can raise:
            - :class:`TypeError` if `link` is not an instance of
              :class:`.SchemeLink`
            - :class:`.SchemeCycleError` if the `link` would introduce a cycle
            - :class:`.IncompatibleChannelTypeError` if the channel types are
              not compatible
            - :class:`.SinkChannelError` if a sink channel has a `Single` flag
              specification and the channel is already connected.
            - :class:`.DuplicatedLinkError` if a `link` duplicates an already
              present link.

        """
        check_type(link, SchemeLink)

        if self.creates_cycle(link):
            raise SchemeCycleError("Cannot create cycles in the scheme")

        if not self.compatible_channels(link):
            raise IncompatibleChannelTypeError(
                "Cannot connect %r to %r."
                % (link.source_channel.type, link.sink_channel.type)
            )

        links = self.find_links(
            source_node=link.source_node,
            source_channel=link.source_channel,
            sink_node=link.sink_node,
            sink_channel=link.sink_channel,
        )
github BioDepot / BioDepot-workflow-builder / orange3 / Orange / canvas / scheme / scheme.py View on Github external
def creates_cycle(self, link):
        """
        Return `True` if `link` would introduce a cycle in the scheme.

        Parameters
        ----------
        link : :class:`.SchemeLink`

        """
        check_type(link, SchemeLink)
        source_node, sink_node = link.source_node, link.sink_node
        upstream = self.upstream_nodes(source_node)
        upstream.add(source_node)
        return sink_node in upstream