Topology utils#275
Conversation
Fix import Fix syntax
d1303ed to
1da2b4c
Compare
|
@thisac Is this ready to be merged? |
randomir
left a comment
There was a problem hiding this comment.
Did a quick review, it looks good, but I would like to do an in-depth review before me merge this.
The suggestions below are mostly minor, except the use of function objects as default argument values.
| @@ -0,0 +1,20 @@ | |||
| # Copyright 2016 D-Wave Systems Inc. | |||
There was a problem hiding this comment.
| # Copyright 2016 D-Wave Systems Inc. | |
| # Copyright 2026 D-Wave Systems Inc. |
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| # ================================================================================================ |
There was a problem hiding this comment.
| # ================================================================================================ |
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| # ================================================================================================ |
There was a problem hiding this comment.
| # ================================================================================================ |
| return self._edge[index] | ||
|
|
||
| def __eq__(self, other: object) -> bool: | ||
| if not type(self) is type(other): |
There was a problem hiding this comment.
| if not type(self) is type(other): | |
| if type(self) is not type(other): |
|
|
||
| def __eq__(self, other: object) -> bool: | ||
| if not type(self) is type(other): | ||
| return NotImplemented |
There was a problem hiding this comment.
Why not:
| return NotImplemented | |
| return False |
| def neighbors( | ||
| self, | ||
| nbr_kind: EdgeKind | Iterable[EdgeKind] | None = None, | ||
| where: Callable[[Coord], bool] = lambda coord: True, |
There was a problem hiding this comment.
I believe the mutable default argument value gotcha applies to function objects as well.
| associated_edgekind: EdgeKind | ||
|
|
||
|
|
||
| class HasInternalNeighborsMixin(NeighborContributorMixin): |
| Returns: | ||
| TopologyShape: The shape converted to its corresponding quotient shape. | ||
| """ | ||
| @abstractmethod |
There was a problem hiding this comment.
| @abstractmethod | |
| @abstractmethod | |
| source_to_inner = _chimera_coordinates_cache[m_s, | ||
| n_s, t_t].linear_to_chimera | ||
| else: | ||
| raise ValueError(f"Chimera node labeling {labels_s} not recognized") | ||
| raise ValueError( | ||
| f"Chimera node labeling {labels_s} not recognized") | ||
|
|
There was a problem hiding this comment.
Not sure if this was automatically reformatted, or you did it manually, but indentation should be at least locally consistent!
| source_to_inner = _zephyr_coordinates_cache[m_s, | ||
| t].linear_to_zephyr |
There was a problem hiding this comment.
This is arguably less readable to save 4-5 characters in a line.
The added files in
dwave/graphs/topologies/commonprovide blueprint classes for working with different aspects of any D-Wave topology.coord.py: Coordinate systems used for node labels.node_edge.py: Nodes and edges.planeshift.py: Displacement of nodes in the Cartesian plane.shape.py: Shape of a graph.topology.py: Constructing a topology graph whose nodes and edges are equipped with all the specific-topology-relevant functionalities.The added files in
dwave/graphs/topologies/zephyr, i.e.zcoord.py,znode_edge.py,zplaneshift.pyandzshape.py, contain the implementation of the corresponding objects for Zephyr topology. Inzephyr.pythe classZephyrhas been added that is built onTopologyblueprint indwave/graphs/topologies/common/topology.pyThe test suite for these modules is added in
tests.Note: This is an evolution of previous
zephyr_utilsPR tominorminer.