From f1e5aed17dfedc6041914d1a303b1f29e134417f Mon Sep 17 00:00:00 2001 From: Roberto Nobrega Date: Tue, 5 Nov 2024 21:01:31 -0300 Subject: [PATCH] Adjust doctest formatting --- src/komm/_algebra/RationalPolynomial.py | 2 +- src/komm/_error_control_block/ReedMullerCode.py | 2 +- src/komm/_modulation/PSKModulation.py | 4 ++-- src/komm/_modulation/QAModulation.py | 8 ++++---- src/komm/_quantization/UniformQuantizer.py | 2 +- src/komm/_sequences/LFSRSequence.py | 4 ++-- src/komm/_sequences/ZadoffChuSequence.py | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/komm/_algebra/RationalPolynomial.py b/src/komm/_algebra/RationalPolynomial.py index f9eea86..033ba2c 100644 --- a/src/komm/_algebra/RationalPolynomial.py +++ b/src/komm/_algebra/RationalPolynomial.py @@ -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: diff --git a/src/komm/_error_control_block/ReedMullerCode.py b/src/komm/_error_control_block/ReedMullerCode.py index 944c170..cd48ea6 100644 --- a/src/komm/_error_control_block/ReedMullerCode.py +++ b/src/komm/_error_control_block/ReedMullerCode.py @@ -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], diff --git a/src/komm/_modulation/PSKModulation.py b/src/komm/_modulation/PSKModulation.py index 64b495c..9e120ca 100644 --- a/src/komm/_modulation/PSKModulation.py +++ b/src/komm/_modulation/PSKModulation.py @@ -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) diff --git a/src/komm/_modulation/QAModulation.py b/src/komm/_modulation/QAModulation.py index 05350ff..70ce472 100644 --- a/src/komm/_modulation/QAModulation.py +++ b/src/komm/_modulation/QAModulation.py @@ -51,12 +51,12 @@ def __init__( >>> 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], @@ -71,10 +71,10 @@ def __init__( >>> 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]) diff --git a/src/komm/_quantization/UniformQuantizer.py b/src/komm/_quantization/UniformQuantizer.py index 246a4ad..748831e 100644 --- a/src/komm/_quantization/UniformQuantizer.py +++ b/src/komm/_quantization/UniformQuantizer.py @@ -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]]) diff --git a/src/komm/_sequences/LFSRSequence.py b/src/komm/_sequences/LFSRSequence.py index 970c2b8..fb13fe7 100644 --- a/src/komm/_sequences/LFSRSequence.py +++ b/src/komm/_sequences/LFSRSequence.py @@ -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. diff --git a/src/komm/_sequences/ZadoffChuSequence.py b/src/komm/_sequences/ZadoffChuSequence.py index 9d2c187..8175562 100644 --- a/src/komm/_sequences/ZadoffChuSequence.py +++ b/src/komm/_sequences/ZadoffChuSequence.py @@ -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])