Skip to content

Commit

Permalink
Fixes Griffe issue with Google-style sections
Browse files Browse the repository at this point in the history
  • Loading branch information
rwnobrega committed Nov 1, 2024
1 parent b496901 commit f675489
Show file tree
Hide file tree
Showing 60 changed files with 5 additions and 271 deletions.
16 changes: 0 additions & 16 deletions src/komm/_algebra/BinaryPolynomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class BinaryPolynomial:
Binary polynomial. A *binary polynomial* is a polynomial whose coefficients are elements in the finite field $\mathbb{F}_2 = \\{ 0, 1 \\}$. This class supports addition, multiplication, division, and exponentiation.
Examples:
>>> poly1 = komm.BinaryPolynomial(0b10100) # X^4 + X^2
>>> poly2 = komm.BinaryPolynomial(0b11010) # X^4 + X^3 + X
>>> poly1 + poly2 # X^3 + X^2 + X
Expand All @@ -28,11 +27,9 @@ def __init__(self, integer):
Default constructor for the class.
Parameters:
integer (int): An integer whose binary digits represent the coefficients of the polynomial—the leftmost bit standing for the highest degree term. For example, the binary polynomial $X^4 + X^3 + X$ is represented by the integer `0b11010` = `0o32` = `26`.
Examples:
>>> komm.BinaryPolynomial(0b11010) # X^4 + X^3 + X
BinaryPolynomial(0b11010)
Expand All @@ -46,11 +43,9 @@ def from_coefficients(cls, coefficients):
Constructs a binary polynomial from its coefficients.
Parameters:
coefficients (Array1D[int]): The coefficients of the binary polynomial—the $i$-th element of the array standing for the coefficient of $X^i$. For example, `[0, 1, 0, 1, 1]` represents the binary polynomial $X^4 + X^3 + X$.
Examples:
>>> komm.BinaryPolynomial.from_coefficients([0, 1, 0, 1, 1]) # X^4 + X^3 + X
BinaryPolynomial(0b11010)
"""
Expand All @@ -62,11 +57,9 @@ def from_exponents(cls, exponents):
Constructs a binary polynomial from its exponents.
Parameters:
exponents (Array1D[int]): The exponents of the nonzero terms of the binary polynomial. For example, `[1, 3, 4]` represents the binary polynomial $X^4 + X^3 + X$.
Examples:
>>> komm.BinaryPolynomial.from_exponents([1, 3, 4]) # X^4 + X^3 + X
BinaryPolynomial(0b11010)
"""
Expand All @@ -78,7 +71,6 @@ def degree(self):
The degree of the polynomial.
Examples:
>>> poly = komm.BinaryPolynomial(0b11010) # X^4 + X^3 + X
>>> poly.degree
4
Expand All @@ -90,15 +82,12 @@ def coefficients(self, width=None):
Returns the coefficients of the binary polynomial.
Parameters:
width (Optional[int]): If this parameter is specified, the output will be filled with zeros on the right so that the its length will be the specified value.
Returns:
coefficients (Array1D[int]): Coefficients of the binary polynomial. The $i$-th element of the array stands for the coefficient of $X^i$.
Examples:
>>> poly = komm.BinaryPolynomial(0b11010) # X^4 + X^3 + X
>>> poly.coefficients()
array([0, 1, 0, 1, 1])
Expand All @@ -112,11 +101,9 @@ def exponents(self):
Returns the exponents of the binary polynomial.
Returns:
exponents (Array1D[int]): Exponents of the nonzero terms of the binary polynomial. The exponents are returned in ascending order.
Examples:
>>> poly = komm.BinaryPolynomial(0b11010) # X^4 + X^3 + X
>>> poly.exponents()
array([1, 3, 4])
Expand Down Expand Up @@ -172,15 +159,12 @@ def evaluate(self, point):
Evaluates the polynomial at a given point. Uses Horner's method.
Parameters:
point (RingElement): Any Python object supporting the operations of addition, subtraction, and multiplication.
Returns:
result (RingElement): The result of evaluating the binary polynomial at `point`. It has the same type as `point`.
Examples:
>>> poly = komm.BinaryPolynomial(0b11010) # X^4 + X^3 + X
>>> poly.evaluate(7) # same as 7**4 + 7**3 + 7
np.int64(2751)
Expand Down
4 changes: 0 additions & 4 deletions src/komm/_algebra/FiniteBifield.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class FiniteBifield:
To construct *elements* of the finite field, call the finite field object. For example, `field(0b1101)` will construct the element whose polynomial representation is $X^3 + X^2 + 1$.
Examples:
>>> field = komm.FiniteBifield(4)
>>> x = field(0b1011)
>>> y = field(0b1100)
Expand All @@ -30,7 +29,6 @@ def __init__(self, degree, modulus=None):
Constructor for the class.
Parameters:
degree (int): Degree $k$ of the finite field. Must be a positive integer.
modulus (Optional[BinaryPolynomial | int]): Modulus (primitive polynomial) $p(X)$ of the field, specified either as a [binary polynomial](/ref/BinaryPolynomial) or as an integer to be converted to the former. Must be an irreducible polynomial. If not specified, the modulus is chosen from the table below <cite>LC04, p.42</cite>.
Expand All @@ -47,7 +45,6 @@ def __init__(self, degree, modulus=None):
| $8$ | `0b100011101` | $16$ | `0b10001000000001011` |
Examples:
>>> field = komm.FiniteBifield(4)
>>> field
FiniteBifield(4)
Expand Down Expand Up @@ -108,7 +105,6 @@ def primitive_element(self):
A primitive element $\alpha$ of the finite field. It satisfies $p(\alpha) = 0$, where $p(X)$ is the modulus (primitive polynomial) of the finite field.
Examples:
>>> field1 = komm.FiniteBifield(3, modulus=0b1011)
>>> alpha1 = field1.primitive_element
>>> [alpha1**i for i in range(7)]
Expand Down
12 changes: 0 additions & 12 deletions src/komm/_algebra/RationalPolynomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class RationalPolynomial:
Rational polynomial. A *rational polynomial* is a polynomial whose coefficients are all rational numbers. This class supports addition, subtraction, multiplication, division, and exponentiation.
Examples:
>>> poly1 = komm.RationalPolynomial(['1/2', '0', '3']) # 1/2 + 3 X^2
>>> poly1
RationalPolynomial(['1/2', '0', '3'])
Expand All @@ -30,11 +29,9 @@ def __init__(self, coefficients):
Constructor for the class.
Parameters:
coefficients (Array1D[int | str | Fraction]): The coefficients of the rational polynomial—the $i$-th element of the array standing for the coefficient of $X^i$. For example, `['1/2', '0', '3']` represents the rational polynomial $1/2 + 3 X^2$.
Examples:
>>> komm.RationalPolynomial(['1/2', '0', '3']) # 1/2 + 3 X^2
RationalPolynomial(['1/2', '0', '3'])
"""
Expand All @@ -54,13 +51,11 @@ def monomial(cls, degree, coefficient=1):
Constructs a monomial. This is an polynomial of the form $cX^d$.
Parameters:
degree (int): The degree $d$ of the monomial.
coefficient (Optional[int]): The coefficient $c$ of the monomial. The default value is $1$.
Examples:
>>> komm.RationalPolynomial.monomial(4, 2) # 2 X^4
RationalPolynomial(['0', '0', '0', '0', '2'])
"""
Expand All @@ -71,15 +66,12 @@ def coefficients(self, width=None):
Returns the coefficients of the polynomial.
Parameters:
width (Optional[int]): If this parameter is specified, the output will be filled with zeros on the right so that the its length will be the specified value.
Returns:
coefficients (Array1D[int]): Coefficients of the polynomial. The $i$-th element of the array stands for the coefficient of $X^i$.
Examples:
>>> poly = komm.RationalPolynomial(['0', '1/3', '2/3']) # (1/3) X + (2/3) X^2
>>> poly.coefficients()
array([Fraction(0, 1), Fraction(1, 3), Fraction(2, 3)], dtype=object)
Expand All @@ -100,7 +92,6 @@ def degree(self):
The degree of the polynomial.
Examples:
>>> poly = komm.RationalPolynomial([1, 0, 3]) # 1 + 3 X^2
>>> poly.degree
2
Expand Down Expand Up @@ -180,15 +171,12 @@ def evaluate(self, point):
Evaluates the polynomial at a given point. Uses Horner's method.
Parameters:
point (RingElement): Any Python object supporting the operations of addition, subtraction, and multiplication.
Returns:
result (RingElement): The result of evaluating the binary polynomial at `point`. It has the same type as `point`.
Examples:
>>> poly = komm.RationalPolynomial([0, 1, 0, -1, 2]) # X - X^3 + 2 X^4
>>> poly.evaluate(7) # same as 7 - 7**3 + 2 * 7**4
Fraction(4466, 1)
Expand Down
3 changes: 0 additions & 3 deletions src/komm/_channels/AWGNChannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ def __init__(self, signal_power, snr=np.inf):
r"""Constructor for the class.
Parameters:
signal_power (float | str): The input signal power $P$. If equal to the string `'measured'`, then every time the channel is invoked the input signal power will be computed from the input itself (i.e., its squared Euclidean norm).
snr (Optional[float]): The channel signal-to-noise ratio $\snr$ (linear, not decibel). The default value is `np.inf`, which corresponds to a noiseless channel.
Examples:
>>> np.random.seed(1)
>>> awgn = komm.AWGNChannel(snr=200.0, signal_power=5.0)
>>> x = [1.0, 3.0, -3.0, -1.0, -1.0, 1.0, 3.0, 1.0, -1.0, 3.0]
Expand Down Expand Up @@ -73,7 +71,6 @@ def capacity(self):
Returns the channel capacity $C$. It is given by $C = \frac{1}{2}\log_2(1 + \snr)$, in bits per dimension.
Examples:
>>> awgn = komm.AWGNChannel(signal_power=1.0, snr=63.0)
>>> awgn.capacity()
np.float64(3.0)
Expand Down
3 changes: 0 additions & 3 deletions src/komm/_channels/BinaryErasureChannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ def __init__(self, erasure_probability=0.0):
Constructor for the class.
Parameters:
erasure_probability (Optional[float]): The channel erasure probability $\epsilon$. Must satisfy $0 \leq \epsilon \leq 1$. Default value is `0.0`, which corresponds to a noiseless channel.
Examples:
>>> np.random.seed(1)
>>> bec = komm.BinaryErasureChannel(0.1)
>>> x = [1, 1, 1, 0, 0, 0, 1, 0, 1, 0]
Expand All @@ -53,7 +51,6 @@ def capacity(self):
Returns the channel capacity $C$. It is given by $C = 1 - \epsilon$. See <cite>CT06, Sec. 7.1.5</cite>.
Examples:
>>> bec = komm.BinaryErasureChannel(0.25)
>>> bec.capacity()
0.75
Expand Down
3 changes: 0 additions & 3 deletions src/komm/_channels/BinarySymmetricChannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ def __init__(self, crossover_probability=0.0):
Constructor for the class.
Parameters:
crossover_probability (Optional[float]): The channel crossover probability $p$. Must satisfy $0 \leq p \leq 1$. The default value is `0.0`, which corresponds to a noiseless channel.
Examples:
>>> np.random.seed(1)
>>> bsc = komm.BinarySymmetricChannel(0.1)
>>> x = [0, 1, 1, 1, 0, 0, 0, 0, 0, 1]
Expand All @@ -54,7 +52,6 @@ def capacity(self):
Returns the channel capacity $C$. It is given by $C = 1 - \mathcal{H}(p)$. See <cite>CT06, Sec. 7.1.4</cite>.
Examples:
>>> bsc = komm.BinarySymmetricChannel(0.25)
>>> bsc.capacity()
np.float64(0.18872187554086717)
Expand Down
8 changes: 0 additions & 8 deletions src/komm/_channels/DiscreteMemorylessChannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ def __init__(self, transition_matrix):
Constructor for the class.
Parameters:
transition_matrix (Array2D[float]): The channel transition probability matrix $p_{Y \mid X}$. The element in row $x \in \mathcal{X}$ and column $y \in \mathcal{Y}$ must be equal to $p_{Y \mid X}(y \mid x)$.
Examples:
>>> np.random.seed(1)
>>> dmc = komm.DiscreteMemorylessChannel([[0.9, 0.05, 0.05], [0.0, 0.5, 0.5]])
>>> x = [0, 1, 0, 1, 1, 1, 0, 0, 0, 1]
Expand Down Expand Up @@ -66,17 +64,14 @@ def mutual_information(self, input_pmf, base=2.0):
where $\mathrm{H}(X)$ is the the entropy of $X$ and $\mathrm{H}(X \mid Y)$ is the conditional entropy of $X$ given $Y$. By default, the base of the logarithm is $2$, in which case the mutual information is measured in bits. See <cite>CT06, Ch. 2</cite>.
Parameters:
input_pmf (Array1D[float]): The probability mass function $p_X$ of the channel input $X$. It must be a valid pmf, that is, all of its values must be non-negative and sum up to $1$.
base (Optional[float | str]): The base of the logarithm to be used. It must be a positive float or the string `'e'`. The default value is `2.0`.
Returns:
mutual_information (float): The mutual information $\mathrm{I}(X ; Y)$ between the input $X$ and the output $Y$.
Examples:
>>> dmc = komm.DiscreteMemorylessChannel([[0.6, 0.3, 0.1], [0.7, 0.1, 0.2], [0.5, 0.05, 0.45]])
>>> dmc.mutual_information([1/3, 1/3, 1/3]) # doctest: +NUMBER
np.float64(0.123811098798)
Expand All @@ -90,15 +85,12 @@ def capacity(self, base=2.0):
Returns the channel capacity $C$. It is given by $C = \max_{p_X} \mathrm{I}(X;Y)$. This method computes the channel capacity via the Arimoto–Blahut algorithm. See <cite>CT06, Sec. 10.8</cite>.
Parameters:
base (Optional[float | str]): The base of the logarithm to be used. It must be a positive float or the string `'e'`. The default value is `2.0`.
Returns:
capacity (float): The channel capacity $C$.
Examples:
>>> dmc = komm.DiscreteMemorylessChannel([[0.6, 0.3, 0.1], [0.7, 0.1, 0.2], [0.5, 0.05, 0.45]])
>>> dmc.capacity() # doctest: +NUMBER
np.float64(0.1616318610)
Expand Down
3 changes: 0 additions & 3 deletions src/komm/_error_control_block/BCHCode.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,14 @@ class BCHCode(CyclicCode):
| $10$ | $1023$ | $3$, $5$, $7$, $9$, $11$, $13$, $15$, $17$, $19$, $21$, $23$, $25$, $27$, $29$, $31$, $33$, $35$, $37$, $39$, $41$, $43$, $45$, $47$, $49$, $51$, $53$, $55$, $57$, $59$, $61$, $63$, $69$, $71$, $73$, $75$, $77$, $79$, $83$, $85$, $87$, $89$, $91$, $93$, $95$, $99$, $101$, $103$, $105$, $107$, $109$, $111$, $115$, $117$, $119$, $121$, $123$, $125$, $127$, $147$, $149$, $151$, $155$, $157$, $159$, $165$, $167$, $171$, $173$, $175$, $179$, $181$, $183$, $187$, $189$, $191$, $205$, $207$, $213$, $215$, $219$, $221$, $223$, $231$, $235$, $237$, $239$, $245$, $247$, $251$, $253$, $255$, $341$, $343$, $347$, $351$, $363$, $367$, $375$, $379$, $383$, $439$, $447$, $479$, $495$, $511$, $1023$ |
Notes:
- For $\delta = 3$ it reduces to the [Hamming code](/ref/HammingCode).
- For $\delta = 2^{\mu} - 1$ it reduces to the [repetition code](/ref/RepetitionCode).
Attributes:
mu (int): The parameter $\mu$ of the BCH code.
delta (int): The Bose distance $\delta$ of the BCH code.
Examples:
>>> code = komm.BCHCode(mu=5, delta=7)
>>> (code.length, code.dimension, code.minimum_distance)
(31, 16, np.int64(7))
Expand Down
Loading

0 comments on commit f675489

Please sign in to comment.