Skip to content

Commit

Permalink
[minor] merged pr for more docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
01110011011101010110010001101111 committed Jan 27, 2024
2 parents 3ac389f + 915491f commit c34a5e8
Show file tree
Hide file tree
Showing 4 changed files with 427 additions and 13 deletions.
1 change: 1 addition & 0 deletions examples/cuquantum/cuquantum_plugin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<<<<<<< HEAD
"""
MIT License
Expand Down
62 changes: 62 additions & 0 deletions torchquantum/algorithm/quantumnas/super_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,30 @@


def get_combs(inset: List, n=None) -> List[List]:
"""Get all combinations of elements from `inset`.
Args:
inset (List): List of elements.
n (int or Iterable, optional): Number of elements to include in each combination.
If `n` is an integer, only combinations of that size will be returned.
If `n` is an iterable, combinations of different sizes specified by `n` will be returned.
If `n` is not provided, all possible combinations with different numbers of elements will be returned.
Defaults to None.
Returns:
List[List]: List of all combinations of elements from `inset`.
Examples:
>>> get_combs([1, 2, 3])
[[1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]]
>>> get_combs([1, 2, 3], n=2)
[[1, 2], [1, 3], [2, 3]]
>>> get_combs([1, 2, 3], n=[1, 2])
[[1], [2], [3], [1, 2], [1, 3], [2, 3]]
"""

all_combs = []
if n is None:
# all possible combinations, with different #elements in a set
Expand All @@ -57,19 +81,57 @@ def get_combs(inset: List, n=None) -> List[List]:


class SuperQuantumModule(tq.QuantumModule):
"""A super module for quantum computations.
Attributes:
n_wires (int): Number of wires in the quantum module.
sample_arch: The sample architecture for the quantum module.
Methods:
set_sample_arch(sample_arch): Sets the sample architecture for the quantum module.
count_sample_params(): Counts the number of sample parameters in the quantum module.
"""

def __init__(self, n_wires):
"""Initializes the SuperQuantumModule.
Args:
n_wires (int): Number of wires in the quantum module.
"""

super().__init__()
self.n_wires = n_wires
self.sample_arch = None

def set_sample_arch(self, sample_arch):
"""Set the sample architecture for the quantum module.
Args:
sample_arch: The sample architecture for the quantum module.
Returns:
None.
"""

self.sample_arch = sample_arch

@property
def arch_space(self):
"""Return the architecture space of the quantum module.
Returns:
None.
"""

return None

def count_sample_params(self):
"""Count the number of sample parameters in the quantum module.
Raises:
NotImplementedError
"""

raise NotImplementedError


Expand Down
Loading

0 comments on commit c34a5e8

Please sign in to comment.