Skip to content

Commit 86273ea

Browse files
jman4162claude
andcommitted
Fix docstring examples for better mkdocstrings rendering
Remove doctest format (>>> and ...) from Example sections to improve rendering in generated API documentation. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c529692 commit 86273ea

4 files changed

Lines changed: 89 additions & 102 deletions

File tree

src/phased_array_systems/models/digital/bandwidth.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ def beam_bandwidth_product(
3535
Total beam-bandwidth product in Hz
3636
3737
Example:
38-
>>> beam_bandwidth_product(4, 100e6)
39-
400000000.0
38+
beam_bandwidth_product(4, 100e6) # Returns 400e6
4039
"""
4140
return n_beams * bandwidth_per_beam_hz
4241

@@ -60,8 +59,7 @@ def max_simultaneous_beams(
6059
Maximum number of simultaneous beams (integer)
6160
6261
Example:
63-
>>> max_simultaneous_beams(1e9, 100e6)
64-
9
62+
max_simultaneous_beams(1e9, 100e6) # Returns 9
6563
"""
6664
effective_bw = processing_bandwidth_hz / overhead_factor
6765
return int(effective_bw / bandwidth_per_beam_hz)
@@ -93,8 +91,8 @@ def digital_beamformer_data_rate(
9391
- per_element_gbps: Rate per element
9492
9593
Example:
96-
>>> result = digital_beamformer_data_rate(256, 1e9, 14)
97-
>>> print(f"Total data rate: {result['with_overhead_gbps']:.1f} Gbps")
94+
result = digital_beamformer_data_rate(256, 1e9, 14)
95+
print(f"Total data rate: {result['with_overhead_gbps']:.1f} Gbps")
9896
"""
9997
raw_rate_bps = n_elements * sample_rate_hz * bits_per_sample * n_channels
10098
raw_rate_gbps = raw_rate_bps / 1e9
@@ -137,8 +135,8 @@ def channelizer_output_rate(
137135
- samples_per_channel_per_sec: Output samples per channel
138136
139137
Example:
140-
>>> result = channelizer_output_rate(1e9, 16)
141-
>>> print(f"Channel BW: {result['channel_bandwidth_hz']/1e6:.1f} MHz")
138+
result = channelizer_output_rate(1e9, 16)
139+
print(f"Channel BW: {result['channel_bandwidth_hz']/1e6:.1f} MHz")
142140
"""
143141
channel_bandwidth_hz = input_bandwidth_hz / n_channels
144142
channel_sample_rate_hz = channel_bandwidth_hz * overlap_factor
@@ -177,8 +175,8 @@ def processing_margin(
177175
- headroom_percent: Remaining capacity
178176
179177
Example:
180-
>>> result = processing_margin(1000, 600)
181-
>>> print(f"Utilization: {result['utilization_percent']:.1f}%")
178+
result = processing_margin(1000, 600)
179+
print(f"Utilization: {result['utilization_percent']:.1f}%")
182180
"""
183181
margin_ratio = available_throughput_gops / required_throughput_gops
184182
margin_db = 10 * math.log10(margin_ratio) if margin_ratio > 0 else float('-inf')
@@ -220,8 +218,8 @@ def beamformer_operations(
220218
- method: 'time_domain' or 'frequency_domain'
221219
222220
Example:
223-
>>> result = beamformer_operations(256, 4, 100e6)
224-
>>> print(f"Required: {result['total_gops']:.1f} GOPS")
221+
result = beamformer_operations(256, 4, 100e6)
222+
print(f"Required: {result['total_gops']:.1f} GOPS")
225223
"""
226224
if fft_size > 0:
227225
# Frequency-domain: FFT + multiply + IFFT

src/phased_array_systems/models/digital/converters.py

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ def enob_to_snr(enob: float) -> float:
3333
SNR in dB
3434
3535
Example:
36-
>>> enob_to_snr(12)
37-
74.0
38-
>>> enob_to_snr(14)
39-
86.04
36+
enob_to_snr(12) # Returns 74.0
37+
enob_to_snr(14) # Returns 86.04
4038
"""
4139
return 6.02 * enob + 1.76
4240

@@ -56,8 +54,7 @@ def snr_to_enob(snr_db: float) -> float:
5654
Effective number of bits
5755
5856
Example:
59-
>>> snr_to_enob(74.0)
60-
12.0
57+
snr_to_enob(74.0) # Returns 12.0
6158
"""
6259
return (snr_db - 1.76) / 6.02
6360

@@ -76,10 +73,8 @@ def enob_to_sfdr(enob: float, margin_db: float = 0.0) -> float:
7673
Estimated SFDR in dB
7774
7875
Example:
79-
>>> enob_to_sfdr(12)
80-
74.0
81-
>>> enob_to_sfdr(12, margin_db=6) # Conservative estimate
82-
68.0
76+
enob_to_sfdr(12) # Returns 74.0
77+
enob_to_sfdr(12, margin_db=6) # Returns 68.0 (conservative)
8378
"""
8479
return enob_to_snr(enob) - margin_db
8580

@@ -119,8 +114,7 @@ def quantization_noise_floor(
119114
Noise floor spectral density in dBm/Hz
120115
121116
Example:
122-
>>> quantization_noise_floor(12, 0, 100e6, 250e6)
123-
-154.0 # Approximate
117+
quantization_noise_floor(12, 0, 100e6, 250e6) # Returns ~-154.0
124118
"""
125119
snr_db = enob_to_snr(enob)
126120
nyquist_bw = sample_rate_hz / 2
@@ -148,8 +142,7 @@ def sample_rate_for_bandwidth(
148142
Required sample rate in Hz
149143
150144
Example:
151-
>>> sample_rate_for_bandwidth(100e6)
152-
250000000.0
145+
sample_rate_for_bandwidth(100e6) # Returns 250e6
153146
"""
154147
return signal_bandwidth_hz * oversampling_ratio
155148

@@ -170,8 +163,7 @@ def max_signal_bandwidth(
170163
Maximum signal bandwidth in Hz
171164
172165
Example:
173-
>>> max_signal_bandwidth(1e9)
174-
400000000.0
166+
max_signal_bandwidth(1e9) # Returns 400e6
175167
"""
176168
return sample_rate_hz / oversampling_ratio
177169

@@ -201,8 +193,8 @@ def adc_dynamic_range(
201193
- dynamic_range_db: Usable dynamic range
202194
203195
Example:
204-
>>> result = adc_dynamic_range(14, noise_figure_db=3, bandwidth_hz=100e6)
205-
>>> print(f"Dynamic range: {result['dynamic_range_db']:.1f} dB")
196+
result = adc_dynamic_range(14, noise_figure_db=3, bandwidth_hz=100e6)
197+
print(f"Dynamic range: {result['dynamic_range_db']:.1f} dB")
206198
"""
207199
snr_db = enob_to_snr(enob)
208200

@@ -255,8 +247,8 @@ def dac_output_power(
255247
- noise_floor_dbm: Quantization noise floor
256248
257249
Example:
258-
>>> result = dac_output_power(14, full_scale_dbm=10, backoff_db=6)
259-
>>> print(f"Operating power: {result['operating_power_dbm']:.1f} dBm")
250+
result = dac_output_power(14, full_scale_dbm=10, backoff_db=6)
251+
print(f"Operating power: {result['operating_power_dbm']:.1f} dBm")
260252
"""
261253
snr_db = enob_to_snr(enob)
262254
sfdr_db = enob_to_sfdr(enob)

src/phased_array_systems/models/digital/scheduling.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ def timeline_utilization(timeline: Timeline) -> dict[str, float]:
117117
- by_function_percent: Dict of function -> percentage
118118
119119
Example:
120-
>>> tl = Timeline(dwells=[...], frame_time_ms=100)
121-
>>> util = timeline_utilization(tl)
122-
>>> print(f"Utilization: {util['total_utilization']*100:.1f}%")
120+
tl = Timeline(dwells=[...], frame_time_ms=100)
121+
util = timeline_utilization(tl)
122+
print(f"Utilization: {util['total_utilization']*100:.1f}%")
123123
"""
124124
total_dwell_ms = timeline.total_dwell_time_ms
125125
idle_time_ms = max(0, timeline.frame_time_ms - total_dwell_ms)
@@ -169,13 +169,13 @@ def max_update_rate(
169169
- scan_time_s: Time for one complete scan
170170
171171
Example:
172-
>>> # Search ±60° az, ±30° el with 3° beam
173-
>>> result = max_update_rate(
174-
... scan_volume_sr=2.0, # ~hemisphere
175-
... beam_solid_angle_sr=0.003, # ~3° beam
176-
... dwell_time_us=100
177-
... )
178-
>>> print(f"Update rate: {result['update_rate_hz']:.2f} Hz")
172+
# Search ±60° az, ±30° el with 3° beam
173+
result = max_update_rate(
174+
scan_volume_sr=2.0, # ~hemisphere
175+
beam_solid_angle_sr=0.003, # ~3° beam
176+
dwell_time_us=100,
177+
)
178+
print(f"Update rate: {result['update_rate_hz']:.2f} Hz")
179179
"""
180180
n_beam_positions = math.ceil(scan_volume_sr / beam_solid_angle_sr)
181181
time_per_position_us = dwell_time_us + overhead_us
@@ -218,14 +218,14 @@ def search_timeline(
218218
Timeline with search dwells
219219
220220
Example:
221-
>>> tl = search_timeline(
222-
... azimuth_range_deg=(-60, 60),
223-
... elevation_range_deg=(0, 30),
224-
... azimuth_step_deg=3.0,
225-
... elevation_step_deg=3.0,
226-
... dwell_time_us=100
227-
... )
228-
>>> print(f"Generated {tl.n_dwells} dwells")
221+
tl = search_timeline(
222+
azimuth_range_deg=(-60, 60),
223+
elevation_range_deg=(0, 30),
224+
azimuth_step_deg=3.0,
225+
elevation_step_deg=3.0,
226+
dwell_time_us=100,
227+
)
228+
print(f"Generated {tl.n_dwells} dwells")
229229
"""
230230
dwells = []
231231

@@ -283,17 +283,17 @@ def interleaved_timeline(
283283
Timeline with interleaved function dwells
284284
285285
Example:
286-
>>> tl = interleaved_timeline(
287-
... functions=[
288-
... {"function": Function.RADAR_SEARCH, "time_percent": 60,
289-
... "dwell_time_us": 100, "dwells_per_burst": 10},
290-
... {"function": Function.RADAR_TRACK, "time_percent": 30,
291-
... "dwell_time_us": 50, "dwells_per_burst": 5},
292-
... {"function": Function.ESM, "time_percent": 10,
293-
... "dwell_time_us": 200, "dwells_per_burst": 2},
294-
... ],
295-
... frame_time_ms=100
296-
... )
286+
tl = interleaved_timeline(
287+
functions=[
288+
{"function": Function.RADAR_SEARCH, "time_percent": 60,
289+
"dwell_time_us": 100, "dwells_per_burst": 10},
290+
{"function": Function.RADAR_TRACK, "time_percent": 30,
291+
"dwell_time_us": 50, "dwells_per_burst": 5},
292+
{"function": Function.ESM, "time_percent": 10,
293+
"dwell_time_us": 200, "dwells_per_burst": 2},
294+
],
295+
frame_time_ms=100,
296+
)
297297
"""
298298
dwells = []
299299

src/phased_array_systems/models/rf/cascade.py

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ def noise_figure_to_temp(nf_db: float, t0: float = T0) -> float:
4343
Equivalent noise temperature in Kelvin
4444
4545
Example:
46-
>>> noise_figure_to_temp(3.0) # 3 dB NF
47-
288.6 # Approximately
46+
noise_figure_to_temp(3.0) # 3 dB NF -> ~288.6 K
4847
"""
4948
f_linear = 10 ** (nf_db / 10)
5049
return t0 * (f_linear - 1)
@@ -63,8 +62,7 @@ def noise_temp_to_figure(te: float, t0: float = T0) -> float:
6362
Noise figure in dB
6463
6564
Example:
66-
>>> noise_temp_to_figure(290)
67-
3.01 # Approximately
65+
noise_temp_to_figure(290) # 290 K -> ~3.01 dB
6866
"""
6967
f_linear = 1 + te / t0
7068
return 10 * math.log10(f_linear)
@@ -93,12 +91,12 @@ def friis_noise_figure(
9391
- stage_contributions_db: NF contribution from each stage
9492
9593
Example:
96-
>>> # LNA (15 dB gain, 2 dB NF) -> Mixer (10 dB loss, 10 dB NF)
97-
>>> result = friis_noise_figure([
98-
... (15, 2), # LNA
99-
... (-10, 10), # Mixer (loss = negative gain)
100-
... ])
101-
>>> print(f"System NF: {result['total_nf_db']:.2f} dB")
94+
# LNA (15 dB gain, 2 dB NF) -> Mixer (10 dB loss, 10 dB NF)
95+
result = friis_noise_figure([
96+
(15, 2), # LNA
97+
(-10, 10), # Mixer (loss = negative gain)
98+
])
99+
print(f"System NF: {result['total_nf_db']:.2f} dB")
102100
"""
103101
if not stages:
104102
return {
@@ -166,11 +164,11 @@ def system_noise_temperature(
166164
- system_nf_db: Effective system noise figure
167165
168166
Example:
169-
>>> result = system_noise_temperature(
170-
... antenna_temp_k=50, # Cold sky
171-
... receiver_nf_db=2.0,
172-
... line_loss_db=0.5
173-
... )
167+
result = system_noise_temperature(
168+
antenna_temp_k=50, # Cold sky
169+
receiver_nf_db=2.0,
170+
line_loss_db=0.5,
171+
)
174172
"""
175173
# Receiver noise temperature
176174
t_rx = noise_figure_to_temp(receiver_nf_db)
@@ -210,8 +208,7 @@ def cascade_gain(gains_db: list[float]) -> float:
210208
Total gain in dB
211209
212210
Example:
213-
>>> cascade_gain([20, -3, 15, -6]) # LNA, filter, amp, cable
214-
26
211+
cascade_gain([20, -3, 15, -6]) # LNA, filter, amp, cable -> 26 dB
215212
"""
216213
return sum(gains_db)
217214

@@ -248,11 +245,11 @@ def cascade_iip3(
248245
- total_gain_db: Cascaded gain
249246
250247
Example:
251-
>>> # LNA (15dB, +5dBm IIP3) -> Mixer (-10dB, +10dBm IIP3)
252-
>>> result = cascade_iip3([
253-
... (15, 5),
254-
... (-10, 10),
255-
... ])
248+
# LNA (15dB, +5dBm IIP3) -> Mixer (-10dB, +10dBm IIP3)
249+
result = cascade_iip3([
250+
(15, 5),
251+
(-10, 10),
252+
])
256253
"""
257254
if not stages:
258255
return {"iip3_dbm": float('inf'), "oip3_dbm": float('inf'), "total_gain_db": 0}
@@ -325,11 +322,11 @@ def sfdr_from_iip3(
325322
- max_signal_dbm: Maximum signal before spurs exceed noise
326323
327324
Example:
328-
>>> result = sfdr_from_iip3(
329-
... iip3_dbm=5,
330-
... noise_floor_dbm_hz=-170,
331-
... bandwidth_hz=1e6
332-
... )
325+
result = sfdr_from_iip3(
326+
iip3_dbm=5,
327+
noise_floor_dbm_hz=-170,
328+
bandwidth_hz=1e6,
329+
)
333330
"""
334331
noise_floor_dbm = noise_floor_dbm_hz + 10 * math.log10(bandwidth_hz)
335332
sfdr_db = (2 / 3) * (iip3_dbm - noise_floor_dbm)
@@ -387,11 +384,11 @@ def mds_from_noise_figure(
387384
- ktb_dbm: Thermal noise power
388385
389386
Example:
390-
>>> result = mds_from_noise_figure(
391-
... noise_figure_db=3,
392-
... bandwidth_hz=1e6,
393-
... snr_required_db=10
394-
... )
387+
result = mds_from_noise_figure(
388+
noise_figure_db=3,
389+
bandwidth_hz=1e6,
390+
snr_required_db=10,
391+
)
395392
"""
396393
# kT in dBm/Hz at T0
397394
kt_dbm_hz = 10 * math.log10(K_B * t0 * 1000) # *1000 for mW
@@ -471,15 +468,15 @@ def cascade_analysis(
471468
- stage_names: Names of each stage
472469
473470
Example:
474-
>>> stages = [
475-
... RFStage("LNA", gain_db=20, noise_figure_db=1.5, iip3_dbm=-5),
476-
... RFStage("Filter", gain_db=-2, noise_figure_db=2, iip3_dbm=30),
477-
... RFStage("Mixer", gain_db=-8, noise_figure_db=8, iip3_dbm=15),
478-
... RFStage("IF Amp", gain_db=30, noise_figure_db=4, iip3_dbm=10),
479-
... ]
480-
>>> result = cascade_analysis(stages, bandwidth_hz=10e6)
481-
>>> print(f"System NF: {result['total_nf_db']:.2f} dB")
482-
>>> print(f"SFDR: {result['sfdr_db']:.1f} dB")
471+
stages = [
472+
RFStage("LNA", gain_db=20, noise_figure_db=1.5, iip3_dbm=-5),
473+
RFStage("Filter", gain_db=-2, noise_figure_db=2, iip3_dbm=30),
474+
RFStage("Mixer", gain_db=-8, noise_figure_db=8, iip3_dbm=15),
475+
RFStage("IF Amp", gain_db=30, noise_figure_db=4, iip3_dbm=10),
476+
]
477+
result = cascade_analysis(stages, bandwidth_hz=10e6)
478+
print(f"System NF: {result['total_nf_db']:.2f} dB")
479+
print(f"SFDR: {result['sfdr_db']:.1f} dB")
483480
"""
484481
if not stages:
485482
return {}

0 commit comments

Comments
 (0)