Skip to content

Commit

Permalink
Adjust doctest formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
rwnobrega committed Nov 6, 2024
1 parent 3a99ad0 commit f1e5aed
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/komm/_algebra/RationalPolynomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def coefficients(self, width=None):
>>> 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)
>>> poly.coefficients(width=5) #doctest: +NORMALIZE_WHITESPACE
>>> poly.coefficients(width=5) # doctest: +NORMALIZE_WHITESPACE
array([Fraction(0, 1), Fraction(1, 3), Fraction(2, 3), Fraction(0, 1), Fraction(0, 1)], dtype=object)
"""
if width is None:
Expand Down
2 changes: 1 addition & 1 deletion src/komm/_error_control_block/ReedMullerCode.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ReedMullerCode(BlockCode):
(32, 6, 26)
>>> code.minimum_distance
16
>>> code.generator_matrix #doctest: +NORMALIZE_WHITESPACE
>>> code.generator_matrix # doctest: +NORMALIZE_WHITESPACE
array([[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],
[0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1],
Expand Down
4 changes: 2 additions & 2 deletions src/komm/_modulation/PSKModulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ def __init__(self, order, amplitude=1.0, phase_offset=0.0, labeling="reflected")
Examples:
>>> psk = komm.PSKModulation(4, phase_offset=np.pi/4.0)
>>> psk.constellation #doctest: +NORMALIZE_WHITESPACE
>>> psk.constellation # doctest: +NORMALIZE_WHITESPACE
array([ 0.70710678+0.70710678j, -0.70710678+0.70710678j, -0.70710678-0.70710678j, 0.70710678-0.70710678j])
>>> psk.labeling
array([[0, 0],
[1, 0],
[1, 1],
[0, 1]])
>>> psk.modulate([0, 0, 1, 1, 0, 0, 1, 0, 1, 0]) #doctest: +NORMALIZE_WHITESPACE
>>> psk.modulate([0, 0, 1, 1, 0, 0, 1, 0, 1, 0]) # doctest: +NORMALIZE_WHITESPACE
array([ 0.70710678+0.70710678j, -0.70710678-0.70710678j, 0.70710678+0.70710678j, -0.70710678+0.70710678j, -0.70710678+0.70710678j])
"""
self._amplitude = float(amplitude)
Expand Down
8 changes: 4 additions & 4 deletions src/komm/_modulation/QAModulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ def __init__(
</figure>
>>> qam = komm.QAModulation(16)
>>> qam.constellation #doctest: +NORMALIZE_WHITESPACE
>>> qam.constellation # doctest: +NORMALIZE_WHITESPACE
array([-3.-3.j, -1.-3.j, 1.-3.j, 3.-3.j,
-3.-1.j, -1.-1.j, 1.-1.j, 3.-1.j,
-3.+1.j, -1.+1.j, 1.+1.j, 3.+1.j,
-3.+3.j, -1.+3.j, 1.+3.j, 3.+3.j])
>>> qam.labeling #doctest: +NORMALIZE_WHITESPACE
>>> qam.labeling # doctest: +NORMALIZE_WHITESPACE
array([[0, 0, 0, 0], [1, 0, 0, 0], [1, 1, 0, 0], [0, 1, 0, 0],
[0, 0, 1, 0], [1, 0, 1, 0], [1, 1, 1, 0], [0, 1, 1, 0],
[0, 0, 1, 1], [1, 0, 1, 1], [1, 1, 1, 1], [0, 1, 1, 1],
Expand All @@ -71,10 +71,10 @@ def __init__(
</figure>
>>> qam = komm.QAModulation(orders=(4, 2), base_amplitudes=(1.0, 2.0))
>>> qam.constellation #doctest: +NORMALIZE_WHITESPACE
>>> qam.constellation # doctest: +NORMALIZE_WHITESPACE
array([-3.-2.j, -1.-2.j, 1.-2.j, 3.-2.j,
-3.+2.j, -1.+2.j, 1.+2.j, 3.+2.j])
>>> qam.labeling #doctest: +NORMALIZE_WHITESPACE
>>> qam.labeling # doctest: +NORMALIZE_WHITESPACE
array([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0],
[0, 0, 1], [1, 0, 1], [1, 1, 1], [0, 1, 1]])
>>> qam.modulate([0, 0, 1, 1, 0, 0, 1, 0, 1])
Expand Down
2 changes: 1 addition & 1 deletion src/komm/_quantization/UniformQuantizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, num_levels, input_peak=1.0, choice="mid-riser"):
array([-0.75, -0.5 , -0.25, 0. , 0.25, 0.5 , 0.75])
>>> x = np.linspace(-0.5, 0.5, num=11)
>>> y = quantizer(x)
>>> np.vstack([x, y]) #doctest: +NORMALIZE_WHITESPACE
>>> np.vstack([x, y]) # doctest: +NORMALIZE_WHITESPACE
array([[-0.5 , -0.4 , -0.3 , -0.2 , -0.1 , 0. , 0.1 , 0.2 , 0.3 , 0.4 , 0.5 ],
[-0.375, -0.375, -0.375, -0.125, -0.125, 0.125, 0.125, 0.125, 0.375, 0.375, 0.625]])
Expand Down
4 changes: 2 additions & 2 deletions src/komm/_sequences/LFSRSequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def __init__(self, feedback_polynomial, start_state_polynomial=0b1):
Examples:
>>> lfsr = komm.LFSRSequence(feedback_polynomial=0b100101)
>>> lfsr.bit_sequence #doctest: +NORMALIZE_WHITESPACE
>>> lfsr.bit_sequence # doctest: +NORMALIZE_WHITESPACE
array([0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1])
>>> lfsr.cyclic_autocorrelation() #doctest: +NORMALIZE_WHITESPACE
>>> lfsr.cyclic_autocorrelation() # doctest: +NORMALIZE_WHITESPACE
array([31, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1])
See also the class method [`maximum_length_sequence`](./#maximum_length_sequence) for a more convenient way to construct a maximum-length sequence.
Expand Down
2 changes: 1 addition & 1 deletion src/komm/_sequences/ZadoffChuSequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, length, root_index=1):
Examples:
>>> zadoff_chu = ZadoffChuSequence(5, root_index=1)
>>> zadoff_chu.sequence.round(6) #doctest: +NORMALIZE_WHITESPACE
>>> zadoff_chu.sequence.round(6) # doctest: +NORMALIZE_WHITESPACE
array([ 1. +0.j , 0.309017-0.951057j, -0.809017+0.587785j, 0.309017-0.951057j, 1. +0.j ])
>>> zadoff_chu.cyclic_autocorrelation(normalized=True).round(6)
array([ 1.+0.j, -0.-0.j, -0.-0.j, 0.+0.j, -0.+0.j])
Expand Down

0 comments on commit f1e5aed

Please sign in to comment.