-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Goal of the PR Per [this comment](#173 (review)) from @inmzhang and [the discussion/poll that followed](#179) it seems like the active developers in this repository prefer a functional-style rather than an inheritance based style. This means that instead of ```py class Plaquette: pass class EmptyPlaquette(Plaquette): pass class ZInitialisationPlaquette(Plaquette): pass # many more ``` with a `Plaquette` class whose sole purpose is to provide a common interface between plaquette, everyone voted for a functional-style: ```py class Plaquette: pass def empty_plaquette(qubits: PlaquetteQubits) -> Plaquette: pass def z_initialisation_plaquette(qubits: PlaquetteQubits) -> Plaquette: pass # many more ``` with `Plaquette` being the only class used, and sub-classes are replaced by functions that initialise `Plaquette` instances. ## How was it done? This change is mostly (entirely?) cosmetic, as the sub-classes of `Plaquette` were only initialising correctly their `Plaquette` subclasses. This shows quite well in this PR: the changes are quite small and can be summarised in 2 points: - Change the subclass name by the function name. The new functions have exactly the same parameters as their corresponding `Plaquette` subclass, so this change can be done using a "dumb" tool (i.e., just search & replace, no need for code-aware tools). - Change the subclasses to functions: ```py class [CLASSNAME](Plaquette): def __init__(self, [PARAMETERS]): [CODE] super().__init__([SUPER_PARAMETERS]) ``` becomes ```py def [SNAKE_CASE(CLASSNAME)](PARAMETERS) -> Plaquette: CODE return Plaquette([SUPER_PARAMETERS]) ``` with a slight variation for classes that were 2 or more levels under `Plaquette` in the inheritance hierarchy (e.g. `ZRoundedInitialisationPlaquette` -> `ZInitialisationPlaquette` -> `Plaquette`) for which the `super().__init__` call should be replaced with their superclass corresponding function.
- Loading branch information
Showing
13 changed files
with
379 additions
and
377 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.