• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yoursunny / mqns / 30315099891

27 Jul 2026 11:34PM UTC coverage: 85.792% (+0.008%) from 85.784%
30315099891

push

github

yoursunny
proactive: RoutingPath(m_v="auto")

53 of 57 new or added lines in 6 files covered. (92.98%)

85 existing lines in 22 files now uncovered.

6014 of 7010 relevant lines covered (85.79%)

0.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.37
/mqns/entity/node/qnode.py
1
#    Multiverse Quantum Network Simulator: a simulator for comparative
2
#    evaluation of quantum routing strategies
3
#    Copyright (C) [2025] Amar Abane
4
#
5
#    This program is free software: you can redistribute it and/or modify
6
#    it under the terms of the GNU General Public License as published by
7
#    the Free Software Foundation, either version 3 of the License, or
8
#    (at your option) any later version.
9
#
10
#    This program is distributed in the hope that it will be useful,
11
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
#    GNU General Public License for more details.
14
#
15
#    You should have received a copy of the GNU General Public License
16
#    along with this program.  If not, see <https://www.gnu.org/licenses/>.
17

18
from typing import TYPE_CHECKING, override
1✔
19

20
from mqns.entity.node.app import Application
1✔
21
from mqns.entity.node.node import Node
1✔
22

23
if TYPE_CHECKING:
24
    from mqns.entity.memory import QuantumMemory
25
    from mqns.entity.operator import QuantumOperator
26
    from mqns.entity.qchannel import QuantumChannel
27

28

29
class QNode(Node):
1✔
30
    """QNode is a quantum node in the quantum network. Inherits Node and add quantum elements."""
31

32
    def __init__(self, name: str, *, apps: list[Application] | None = None):
1✔
33
        """
34
        Args:
35
            name: node name
36
            apps: applications on the node.
37
        """
38
        super().__init__(name, apps=apps)
1✔
39
        self.qchannels: list["QuantumChannel"] = []
1✔
40
        """Quantum channels connected to this node."""
1✔
41
        self._qchannel_by_dst = dict[Node, "QuantumChannel"]()
1✔
42
        self._memory: "QuantumMemory|None" = None
1✔
43
        self.operators: list["QuantumOperator"] = []
1✔
44

45
    @override
1✔
46
    def _node_install(self) -> None:
1✔
47
        self._install_channels(self.qchannels, self._qchannel_by_dst)
1✔
48

49
        if self._memory:
1✔
50
            self._memory.install(self.simulator)
1✔
51
        for operator in self.operators:
1✔
52
            operator.install(self.simulator)
1✔
53

54
    @property
1✔
55
    def memory(self) -> "QuantumMemory":
1✔
56
        """
57
        Retrieve associated QuantumMemory.
58

59
        Raises:
60
            LookupError: Memory does not exist.
61
        """
62
        if self._memory is None:
1✔
UNCOV
63
            raise LookupError(f"node {self} does not have memory")
×
64
        return self._memory
1✔
65

66
    @memory.setter
1✔
67
    def memory(self, value: "QuantumMemory"):
1✔
68
        """
69
        Assign QuantumMemory to this node.
70
        This setter is available prior to calling .install().
71
        """
72
        self.ensure_not_installed()
1✔
73
        value.node = self
1✔
74
        self._memory = value
1✔
75

76
    def add_operator(self, operator: "QuantumOperator"):
1✔
77
        """Add a quantum operator in this node
78

79
        Args:
80
            operator: the quantum operator
81

82
        This function is available prior to calling .install().
83
        """
84
        self.ensure_not_installed()
1✔
85
        operator.set_own(self)
1✔
86
        self.operators.append(operator)
1✔
87

88
    def add_qchannel(self, qchannel: "QuantumChannel"):
1✔
89
        """
90
        Add a quantum channel in this QNode.
91
        This function is available prior to calling .install().
92
        """
93
        self._add_channel(qchannel, self.qchannels)
1✔
94

95
    def get_qchannel(self, dst: "QNode") -> "QuantumChannel":
1✔
96
        """
97
        Retrieve the quantum channel that connects to ``dst``.
98

99
        Raises:
100
            LookupError: channel does not exist
101
        """
102
        return self._get_channel(dst, self._qchannel_by_dst)
1✔
103

104
    def __repr__(self) -> str:
1✔
105
        return f"<qnode {self.name}>"
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc