Skip to content

Commit 27bbfff

Browse files
committed
Run black formatting again on codebase. (tox -e format) Ignored some formats in view/pybert.py since the comments and view are laid out in a particular way.
1 parent 6e64478 commit 27bbfff

11 files changed

+150
-122
lines changed

pybert/__main__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Main entry into the PyBERT GUI."""
2-
from pybert.pybert import PyBERT
2+
from pybert.pybert import PyBERT
33
from pybert.pybert_view import traits_view
44

55
thePyBERT = PyBERT()

pybert/pybert.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -1021,10 +1021,10 @@ def _get_jitter_info(self):
10211021
)
10221022
info_str += "</TR>\n"
10231023
info_str += '<TR align="right">\n'
1024-
info_str += '<TD align="center">Pj</TD><TD>%6.3f</TD><TD>%6.3f</TD><TD>n/a</TD>\n' % (pj_chnl, pj_tx)
1024+
info_str += '<TD align="center">Pj</TD><TD>%6.3f</TD><TD>%6.3f</TD><TD>n/a</TD>\n' % (pj_chnl, pj_tx,)
10251025
info_str += "</TR>\n"
10261026
info_str += '<TR align="right">\n'
1027-
info_str += '<TD align="center">Rj</TD><TD>%6.3f</TD><TD>%6.3f</TD><TD>n/a</TD>\n' % (rj_chnl, rj_tx)
1027+
info_str += '<TD align="center">Rj</TD><TD>%6.3f</TD><TD>%6.3f</TD><TD>n/a</TD>\n' % (rj_chnl, rj_tx,)
10281028
info_str += "</TR>\n"
10291029
info_str += "</TABLE>\n"
10301030

@@ -1199,7 +1199,7 @@ def _get_sweep_info(self):
11991199

12001200
@cached_property
12011201
def _get_status_str(self):
1202-
status_str = "%-20s | Perf. (Msmpls./min.): %4.1f" % (self.status, self.total_perf * 60.0e-6)
1202+
status_str = "%-20s | Perf. (Msmpls./min.): %4.1f" % (self.status, self.total_perf * 60.0e-6,)
12031203
dly_str = " | ChnlDly (ns): %5.3f" % (self.chnl_dly * 1.0e9)
12041204
err_str = " | BitErrs: %d" % self.bit_errs
12051205
pwr_str = " | TxPwr (W): %4.2f" % self.rel_power
@@ -1397,23 +1397,23 @@ def _rx_dll_file_changed(self, new_value):
13971397
def _ch_type_changed(self, new_value):
13981398
channel = draw_channel(self.height, self.width, self.thickness, self.separation, new_value)
13991399
self.drawdata.set_data("channel", channel)
1400-
1400+
14011401
def _height_changed(self, new_value):
14021402
channel = draw_channel(new_value, self.width, self.thickness, self.separation, self.ch_type)
14031403
self.drawdata.set_data("channel", channel)
1404-
1404+
14051405
def _width_changed(self, new_value):
14061406
channel = draw_channel(self.height, new_value, self.thickness, self.separation, self.ch_type)
14071407
self.drawdata.set_data("channel", channel)
1408-
1408+
14091409
def _thickness_changed(self, new_value):
14101410
channel = draw_channel(self.height, self.width, new_value, self.separation, self.ch_type)
14111411
self.drawdata.set_data("channel", channel)
1412-
1412+
14131413
def _separation_changed(self, new_value):
14141414
channel = draw_channel(self.height, self.width, self.thickness, new_value, self.ch_type)
14151415
self.drawdata.set_data("channel", channel)
1416-
1416+
14171417
# This function has been pulled outside of the standard Traits/UI "depends_on / @cached_property" mechanism,
14181418
# in order to more tightly control when it executes. I wasn't able to get truly lazy evaluation, and
14191419
# this was causing noticeable GUI slowdown.
@@ -1500,9 +1500,7 @@ def calc_chnl_h(self):
15001500

15011501
def log_information(self):
15021502
"""Log the system information."""
1503-
self.log(
1504-
f"System: {platform.system()} {platform.release()} Version: {platform.version()}"
1505-
)
1503+
self.log(f"System: {platform.system()} {platform.release()} Version: {platform.version()}")
15061504
self.log(f"Python Version: {platform.python_version()}")
15071505
self.log(f"PyBERT Version: {VERSION}")
15081506

pybert/pybert_cfg.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def __init__(self, the_PyBERT):
6767
self.tx_taps = tx_taps
6868
self.tx_tap_tuners = []
6969
for tap in the_PyBERT.tx_tap_tuners:
70-
self.tx_tap_tuners.append((tap.enabled, tap.value))
70+
self.tx_tap_tuners.append((tap.enabled, tap.value))
7171
self.tx_use_ami = the_PyBERT.tx_use_ami
7272
self.tx_use_getwave = the_PyBERT.tx_use_getwave
7373
self.tx_ami_file = the_PyBERT.tx_ami_file

pybert/pybert_cntrl.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,10 @@ def my_run_simulation(self, initial_run=False, update_plots=True):
354354
ctle_out_h = convolve(ctle_h, tx_out_h)[: len(chnl_h)]
355355
else: # Init() only.
356356
ctle_out_h_padded = pad(
357-
ctle_out_h, (nspb, len(rx_in) - nspb - len(ctle_out_h)), "linear_ramp", end_values=(0.0, 0.0)
357+
ctle_out_h, (nspb, len(rx_in) - nspb - len(ctle_out_h)), "linear_ramp", end_values=(0.0, 0.0),
358358
)
359359
tx_out_h_padded = pad(
360-
tx_out_h, (nspb, len(rx_in) - nspb - len(tx_out_h)), "linear_ramp", end_values=(0.0, 0.0)
360+
tx_out_h, (nspb, len(rx_in) - nspb - len(tx_out_h)), "linear_ramp", end_values=(0.0, 0.0),
361361
)
362362
ctle_H = fft(ctle_out_h_padded) / fft(tx_out_h_padded)
363363
ctle_h = real(ifft(ctle_H)[: len(chnl_h)])
@@ -724,11 +724,11 @@ def update_results(self):
724724
self.plotdata.set_data("tap_weight_index", list(range(len(tap_weight))))
725725
if self._old_n_taps != n_taps:
726726
new_plot = Plot(
727-
self.plotdata, auto_colors=["red", "orange", "yellow", "green", "blue", "purple"], padding_left=75
727+
self.plotdata, auto_colors=["red", "orange", "yellow", "green", "blue", "purple"], padding_left=75,
728728
)
729729
for i in range(self.n_taps):
730730
new_plot.plot(
731-
("tap_weight_index", "tap%d_weights" % (i + 1)), type="line", color="auto", name="tap%d" % (i + 1)
731+
("tap_weight_index", "tap%d_weights" % (i + 1)), type="line", color="auto", name="tap%d" % (i + 1),
732732
)
733733
new_plot.title = "DFE Adaptation"
734734
new_plot.tools.append(PanTool(new_plot, constrain=True, constrain_key=None, constrain_direction="x"))
@@ -845,7 +845,7 @@ def update_results(self):
845845
bathtub_chnl.reverse()
846846
bathtub_chnl = array(bathtub_chnl + list(cumsum(jitter_ext_chnl[: half_len + 1])))
847847
bathtub_chnl = where(
848-
bathtub_chnl < MIN_BATHTUB_VAL, 0.1 * MIN_BATHTUB_VAL * ones(len(bathtub_chnl)), bathtub_chnl
848+
bathtub_chnl < MIN_BATHTUB_VAL, 0.1 * MIN_BATHTUB_VAL * ones(len(bathtub_chnl)), bathtub_chnl,
849849
) # To avoid Chaco log scale plot wierdness.
850850
self.plotdata.set_data("bathtub_chnl", log10(bathtub_chnl))
851851
# - Tx
@@ -861,7 +861,7 @@ def update_results(self):
861861
bathtub_ctle.reverse()
862862
bathtub_ctle = array(bathtub_ctle + list(cumsum(jitter_ext_ctle[: half_len + 1])))
863863
bathtub_ctle = where(
864-
bathtub_ctle < MIN_BATHTUB_VAL, 0.1 * MIN_BATHTUB_VAL * ones(len(bathtub_ctle)), bathtub_ctle
864+
bathtub_ctle < MIN_BATHTUB_VAL, 0.1 * MIN_BATHTUB_VAL * ones(len(bathtub_ctle)), bathtub_ctle,
865865
) # To avoid Chaco log scale plot wierdness.
866866
self.plotdata.set_data("bathtub_ctle", log10(bathtub_ctle))
867867
# - DFE

pybert/pybert_plot.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from chaco.api import ColorMapper, GridPlotContainer, Plot
1111
from chaco.tools.api import PanTool, ZoomTool
1212

13-
from numpy import (linspace)
13+
from numpy import linspace
1414

1515
from pybert.pybert_cntrl import update_eyes
1616

@@ -27,9 +27,11 @@ def make_plots(self, n_dfe_taps):
2727
plot2.index_axis.title = "Time (ns)"
2828
plot2.value_axis.title = "UI (ps)"
2929

30-
plot9 = Plot(plotdata, auto_colors=["red", "orange", "yellow", "green", "blue", "purple"], padding_left=75)
30+
plot9 = Plot(plotdata, auto_colors=["red", "orange", "yellow", "green", "blue", "purple"], padding_left=75,)
3131
for i in range(n_dfe_taps):
32-
plot9.plot(("tap_weight_index", "tap%d_weights" % (i + 1)), type="line", color="auto", name="tap%d" % (i + 1))
32+
plot9.plot(
33+
("tap_weight_index", "tap%d_weights" % (i + 1)), type="line", color="auto", name="tap%d" % (i + 1),
34+
)
3335
plot9.title = "DFE Adaptation"
3436
plot9.tools.append(PanTool(plot9, constrain=True, constrain_key=None, constrain_direction="x"))
3537
zoom9 = ZoomTool(plot9, tool_mode="range", axis="index", always_on=False)
@@ -212,7 +214,9 @@ def make_plots(self, n_dfe_taps):
212214
# - Frequency Responses tab
213215
plot_H_chnl = Plot(plotdata, padding_left=75)
214216
plot_H_chnl.plot(("f_GHz", "chnl_H"), type="line", color="blue", name="Original Impulse", index_scale="log")
215-
plot_H_chnl.plot(("f_GHz", "chnl_trimmed_H"), type="line", color="red", name="Trimmed Impulse", index_scale="log")
217+
plot_H_chnl.plot(
218+
("f_GHz", "chnl_trimmed_H"), type="line", color="red", name="Trimmed Impulse", index_scale="log",
219+
)
216220
plot_H_chnl.title = "Channel"
217221
plot_H_chnl.index_axis.title = "Frequency (GHz)"
218222
plot_H_chnl.y_axis.title = "Frequency Response (dB)"

pybert/pybert_util.py

+19-14
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def moving_average(a, n=3):
6666

6767

6868
def find_crossing_times(
69-
t, x, min_delay: float = 0.0, rising_first: bool = True, min_init_dev: float = 0.1, thresh: float = 0.0
69+
t, x, min_delay: float = 0.0, rising_first: bool = True, min_init_dev: float = 0.1, thresh: float = 0.0,
7070
):
7171
"""
7272
Finds the threshold crossing times of the input signal.
@@ -150,7 +150,9 @@ def find_crossing_times(
150150
return array(xings[i:])
151151

152152

153-
def find_crossings(t, x, amplitude, min_delay: float = 0.0, rising_first: bool = True, min_init_dev=0.1, mod_type=0):
153+
def find_crossings(
154+
t, x, amplitude, min_delay: float = 0.0, rising_first: bool = True, min_init_dev=0.1, mod_type=0,
155+
):
154156
"""
155157
Finds the crossing times in a signal, according to the modulation type.
156158
@@ -549,7 +551,7 @@ def calc_gamma_RLGC(R, L, G, C, ws):
549551
w[0] = 1.0e-12
550552

551553
gamma = sqrt((1j * w * L0 + R) * (1j * w * C + G)) # propagation constant (nepers/m)
552-
Zc = sqrt((1j * w * L0 + R) / (1j * w * C + G)) # characteristic impedance (Ohms)
554+
Zc = sqrt((1j * w * L0 + R) / (1j * w * C + G)) # characteristic impedance (Ohms)
553555

554556
return (gamma, Zc)
555557

@@ -642,7 +644,7 @@ def calc_eye(ui, samps_per_ui, height, ys, y_max, clock_times=None):
642644
interp_fac = (start_time - start_ix * tsamp) // tsamp
643645
i = 0
644646
for (samp1, samp2) in zip(
645-
ys[start_ix : start_ix + 2 * samps_per_ui], ys[start_ix + 1 : start_ix + 1 + 2 * samps_per_ui]
647+
ys[start_ix : start_ix + 2 * samps_per_ui], ys[start_ix + 1 : start_ix + 1 + 2 * samps_per_ui],
646648
):
647649
y = samp1 + (samp2 - samp1) * interp_fac
648650
img_array[int(y * y_scale + 0.5) + y_offset, i] += 1
@@ -659,6 +661,7 @@ def calc_eye(ui, samps_per_ui, height, ys, y_max, clock_times=None):
659661

660662
return img_array
661663

664+
662665
def draw_channel(height, width, thickness, separation, ch_type, arraySize=[25, 100]):
663666
"""
664667
Draws the channel cross section.
@@ -682,26 +685,26 @@ def draw_channel(height, width, thickness, separation, ch_type, arraySize=[25, 1
682685
xMid = int(xMax // 2)
683686
yMid = int(yMax // 2)
684687
yOff = int(yMax // 10 + hScale * height)
685-
if ch_type == 'microstrip_se' or ch_type == 'stripline_se': # single-ended configuration
686-
xOff1 = xMid - int(hScale * (width/2))
688+
if ch_type == "microstrip_se" or ch_type == "stripline_se": # single-ended configuration
689+
xOff1 = xMid - int(hScale * (width / 2))
687690
xOff2 = None
688-
else : # differential configuration
689-
xOff1 = xMid - int(hScale * (separation/2 + width))
690-
xOff2 = xMid + int(hScale * separation/2)
691+
else: # differential configuration
692+
xOff1 = xMid - int(hScale * (separation / 2 + width))
693+
xOff2 = xMid + int(hScale * separation / 2)
691694
# Generate the cross-section drawing.
692695
# - Fill w/ dielectric color.
693696
img_array = 10 * ones(arraySize)
694697
# - Draw the reference plane.
695698
for y in range(yMax // 10):
696699
for x in range(xMax):
697-
img_array[y,x] = 0
700+
img_array[y, x] = 0
698701
# - Draw air, or second plane, depending on configuration.
699-
if ch_type == 'microstrip_se' or ch_type == 'microstrip_diff': # microstrip configuration
702+
if ch_type == "microstrip_se" or ch_type == "microstrip_diff": # microstrip configuration
700703
for y in range(yOff, yMax):
701704
for x in range(xMax):
702705
img_array[y, x] = 255 # air (white)
703-
else : # stripline configuration
704-
for y in range(yOff + int(hScale*(thickness + height)), yMax):
706+
else: # stripline configuration
707+
for y in range(yOff + int(hScale * (thickness + height)), yMax):
705708
for x in range(xMax):
706709
img_array[y, x] = 0 # metal (black)
707710
# - Draw trace(s).
@@ -712,6 +715,7 @@ def draw_channel(height, width, thickness, separation, ch_type, arraySize=[25, 1
712715
img_array[yOff + y, xOff2 + x] = 0
713716
return img_array
714717

718+
715719
def make_ctle(rx_bw, peak_freq, peak_mag, w, mode="Passive", dc_offset=0):
716720
"""
717721
Generate the frequency response of a continuous time linear
@@ -1043,6 +1047,7 @@ def pulse_center(p, nspui):
10431047
clock_pos = int(mean([main_lobe_ixs[0], main_lobe_ixs[-1]]))
10441048
return (clock_pos, thresh)
10451049

1050+
10461051
def submodules(package):
10471052

10481053
# mod_path = package.__file__
@@ -1062,4 +1067,4 @@ def submodules(package):
10621067
# mod = loader.load_module(package.__name__ + "." + name)
10631068
rst[name] = mod
10641069

1065-
return rst
1070+
return rst

pybert/pybert_view.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from enable.component_editor import ComponentEditor
1515
from pyface.api import OK, FileDialog
1616
from pyface.image_resource import ImageResource
17-
from traits.api import (Instance, HasTraits)
17+
from traits.api import Instance, HasTraits
1818
from traitsui.api import (
1919
Action,
2020
CheckListEditor,

pybert/solver.py

+22-19
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,37 @@
1212
1313
Copyright (c) 2019 by David Banas; all rights reserved World wide.
1414
"""
15-
from abc import ABC, abstractmethod
15+
from abc import ABC, abstractmethod
1616
from typing import List, Tuple, Dict
17-
from enum import Enum
17+
from enum import Enum
18+
19+
ChType = Enum("ChType", "microstrip_se microstrip_diff stripline_se stripline_diff")
1820

19-
ChType = Enum('ChType', 'microstrip_se microstrip_diff stripline_se stripline_diff')
2021

2122
class Solver(ABC):
2223
"""Abstract base class providing a consistent interface to channel solver.
2324
"""
25+
2426
def __init__(self):
2527
super().__init__()
26-
28+
2729
@abstractmethod
28-
def solve(self,
29-
ch_type : ChType = "microstrip_se", #: Channel cross-sectional configuration.
30-
diel_const : float = 4.3, #: Dielectric constant of substrate at ``des_freq`` (rel.).
31-
loss_tan : float = 0.02, #: Loss tangent at ``des_freq``.
32-
des_freq : float = 1.0e9, #: Frequency at which ``diel_const`` and ``loss_tan`` are quoted (Hz).
33-
thickness : float = 0.036, #: Trace thickness (mm).
34-
width : float = 0.254, #: Trace width (mm).
35-
height : float = 0.127, #: Trace height above/below ground plane (mm).
36-
separation : float = 0.508, #: Trace separation (mm).
37-
roughness : float = 0.004, #: Trace surface roughness (mm-rms).
38-
fs : [float] = None, #: Angular frequency sample points (Hz).
39-
lic_path : str = "", #: Path to license file.
40-
lic_name : str = "", #: Name of license type (if needed by solver).
41-
prj_name : str = "", #: Name of project (if needed by solver).
42-
) -> tuple(([complex], [complex], [float])):
30+
def solve(
31+
self,
32+
ch_type: ChType = "microstrip_se", #: Channel cross-sectional configuration.
33+
diel_const: float = 4.3, #: Dielectric constant of substrate at ``des_freq`` (rel.).
34+
loss_tan: float = 0.02, #: Loss tangent at ``des_freq``.
35+
des_freq: float = 1.0e9, #: Frequency at which ``diel_const`` and ``loss_tan`` are quoted (Hz).
36+
thickness: float = 0.036, #: Trace thickness (mm).
37+
width: float = 0.254, #: Trace width (mm).
38+
height: float = 0.127, #: Trace height above/below ground plane (mm).
39+
separation: float = 0.508, #: Trace separation (mm).
40+
roughness: float = 0.004, #: Trace surface roughness (mm-rms).
41+
fs: [float] = None, #: Angular frequency sample points (Hz).
42+
lic_path: str = "", #: Path to license file.
43+
lic_name: str = "", #: Name of license type (if needed by solver).
44+
prj_name: str = "", #: Name of project (if needed by solver).
45+
) -> tuple(([complex], [complex], [float])):
4346
"""Solves a particular channel cross-section.
4447
4548
Returns:

pybert/solvers/__init__.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@
1414
1515
Copyright (c) 2019 by David Banas; all rights reserved World wide.
1616
"""
17-
__all__ = ["simbeor",] # Should contain the name of each submodule.
18-
from . import * # Makes each solver package available as: solvers.simbeor, etc.
17+
__all__ = [
18+
"simbeor",
19+
] # Should contain the name of each submodule.
20+
from . import * # Makes each solver package available as: solvers.simbeor, etc.

0 commit comments

Comments
 (0)