Skip to content

Commit 2fb19e1

Browse files
author
Jacek Kreft
committedOct 12, 2018
Cosmetic updates
1 parent bdd2e2c commit 2fb19e1

File tree

5 files changed

+42
-36
lines changed

5 files changed

+42
-36
lines changed
 

‎.gitignore

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
1+
# Compiled python modules.
12
*.pyc
2-
*.swp
3+
4+
# Setuptools distribution folder.
5+
/dist/
6+
7+
# Python egg metadata, regenerated from source files by setuptools.
8+
/*.egg-info
9+
10+
# pytest temp dirs
11+
.pytest_cache
12+
__pycache__
13+
.eggs

‎PIM_Calculator/pimQt.py

+14-28
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
23
from __future__ import print_function
34
from __future__ import unicode_literals
45
import sys
@@ -23,7 +24,7 @@
2324
raise
2425

2526

26-
VERSION="0.2.5"
27+
VERSION="0.1.5"
2728

2829

2930
#TODO: add slots and signals
@@ -33,8 +34,6 @@ class PIMCanvas(FigureCanvas):
3334
def __init__(self, parent=None, width=6, height=4, dpi=100):
3435
fig = Figure(figsize=(width, height), dpi=dpi)
3536
self.axes = fig.add_subplot(111)
36-
# self.fig, self.axes = plt.subplots()
37-
3837
self.compute_initial_figure()
3938

4039
FigureCanvas.__init__(self, fig)
@@ -48,27 +47,13 @@ def __init__(self, parent=None, width=6, height=4, dpi=100):
4847
def compute_initial_figure(self):
4948
plt.style.use('bmh')
5049

51-
def plot_beta_hist(ax, a, b):
52-
from numpy.random import beta
53-
ax.hist(beta(a, b, size=10000), histtype="stepfilled",
54-
bins=25, alpha=0.8, density=True)
55-
56-
ax = self.axes
57-
# fig, ax = plt.subplots()
58-
plot_beta_hist(ax, 10, 10)
59-
plot_beta_hist(ax, 4, 12)
60-
plot_beta_hist(ax, 50, 12)
61-
plot_beta_hist(ax, 6, 55)
62-
ax.set_title("'bmh' style sheet")
63-
# plt.show()
64-
6550
def update_figure(self, data, plot_name=""):
6651
self.axes.cla()
6752
self.axes.set_title(plot_name)
6853
self.axes.set_ylabel("Power Normalized")
6954
self.axes.set_xlabel("Frequency [MHz]")
7055

71-
# Shapes:
56+
# Shapes:
7257
shape_im = np.array([0.2, 0.4, 0.50, 0.55, 0.58, 0.6,
7358
0.6, 0.6, 0.6,
7459
0.6, 0.58, 0.55, 0.50, 0.4, 0.2])
@@ -87,13 +72,13 @@ def update_figure(self, data, plot_name=""):
8772

8873
# make pseudo PIM shape with edges lower than middle
8974
y = np.outer(shape_im, np.ones(len(x))).ravel()
90-
y = y[::len(y)/len(x)]
75+
y = y[::int(len(y)/len(x))]
9176
x2 = np.linspace(x.min(), x.max(), num=124)
9277
y = spline(x, y, x2)
9378

9479
self.axes.plot(x2, y,
95-
label="IM Cf={0}".format(x_cf), alpha=0.60,
96-
lw="3")
80+
label="IM Cf={0}".format(x_cf), alpha=0.60,
81+
lw="3")
9782

9883
rx_cf = rx[0] + (rx[1] - rx[0]) / 2
9984
if rx_cf not in rx_present:
@@ -102,13 +87,13 @@ def update_figure(self, data, plot_name=""):
10287

10388
# make pseudo PIM shape with edges lower than middle
10489
y = np.outer(shape_crr, np.ones(len(rx))).ravel()
105-
y = y[::len(y)/len(rx)]
90+
y = y[::int(len(y)/len(rx))]
10691
rx2 = np.linspace(rx.min(), rx.max(), num=124)
10792
y = spline(rx, y, rx2, order=2)
10893

10994
self.axes.plot(rx2, y,
110-
label="RX Cf={0}".format(rx_cf), alpha=0.8,
111-
lw="3")
95+
label="RX Cf={0}".format(rx_cf), alpha=0.8,
96+
lw="3")
11297
rx_present.append(rx_cf)
11398
self.axes.legend()
11499
self.draw()
@@ -122,13 +107,13 @@ def update_figure(self, data, plot_name=""):
122107
x = np.linspace(pim[0], pim[1], num=15, endpoint=True)
123108
x_cf = pim[0] + (pim[1] - pim[0]) / 2
124109
y = np.outer(shape_im, np.ones(len(x))).ravel()
125-
y = y[::len(y)/len(x)]
110+
y = y[::int(len(y)/len(x))]
126111
x2 = np.linspace(x.min(), x.max(), num=124)
127112
y = spline(x, y, x2)
128113

129114
self.axes.plot(x2, y,
130-
label="IM Cf={0}".format(x_cf), alpha=0.60,
131-
lw="3")
115+
label="IM Cf={0}".format(x_cf), alpha=0.60,
116+
lw="3")
132117
"""self.axes.bar(x, y,
133118
label="Cf={0}".format(x[0]+(x[-1]-x[0])/2),
134119
alpha=0.60,
@@ -151,7 +136,7 @@ def __init__(self, widgets, *args, **kwargs):
151136

152137
scroll = QtWidgets.QScrollArea(self)
153138
scroll.setWidgetResizable(True)
154-
scroll.setGeometry(100,100,100,100)
139+
scroll.setGeometry(100, 100, 100, 100)
155140
self.content = QtWidgets.QWidget()
156141
scroll.setWidget(self.content)
157142
lay = QtWidgets.QVBoxLayout(self.content)
@@ -384,6 +369,7 @@ def main():
384369

385370
# Allow the taking of command line arguements
386371
app = QtWidgets.QApplication(sys.argv)
372+
app.setStyleSheet("QMessageBox { messagebox-text-interaction-flags: 5; }")
387373

388374
main = MainWindow()
389375
# Ensure the execution stops correctly

‎PIM_Calculator/pim_calc.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
3+
from __future__ import print_function
34
import logging
45
import pprint
56
import numpy as np

‎PIM_Calculator/tests/test_pimQt.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def main_window(mocker, qtbot, xvfb):
1414

1515
class TestpimQt(object):
1616
def test_MainWindow_init(self, qtbot, main_window, xvfb):
17+
qtbot.addWidget(main_window)
1718
main_window.initUI.assert_called_once_with()
1819

1920
def test_MainWindow_initUI(self, qtbot, mocker, xvfb):
@@ -22,7 +23,7 @@ def test_MainWindow_initUI(self, qtbot, mocker, xvfb):
2223

2324
assert len(window.labels) == 6
2425
assert len(window.fields) == 4
25-
26+
2627
# check boxes
2728
assert len(window.chk_box) == 3
2829
assert window.chk_box[0].isChecked() is False
@@ -32,12 +33,13 @@ def test_MainWindow_initUI(self, qtbot, mocker, xvfb):
3233
assert window.file_menu is not None
3334

3435
def test_MainWindow_closeEvent(self, qtbot, main_window, mocker, xvfb):
36+
qtbot.addWidget(main_window)
3537
file_quit = mocker.patch.object(main_window, "fileQuit")
3638
main_window.closeEvent("XX")
3739
file_quit.assert_called_once_with()
38-
print("AA")
3940

4041
def test_MainWindow_fileQuit(self, qtbot, main_window, mocker, xvfb):
42+
qtbot.addWidget(main_window)
4143
exit = mocker.patch.object(main_window, "close")
4244
wind1_mock = mocker.Mock()
4345
wind2_mock = mocker.Mock()
@@ -48,7 +50,7 @@ def test_MainWindow_fileQuit(self, qtbot, main_window, mocker, xvfb):
4850
mocker.patch.object(wind1_mock, "close")
4951
mocker.patch.object(wind2_mock, "close")
5052
main_window.fileQuit()
51-
53+
5254
for wind in main_window.windows:
5355
wind.close.assert_called_once_with()
5456
exit.assert_called_once_with()

‎setup.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from setuptools import setup, find_packages
22

33
setup(name='PIM_Calculator',
4-
version='0.2.5',
4+
version='0.1.5',
55
description='Passive Intermodulation Calculator for RF antennas',
66
url='http://github.com/panjacek/PIM_Calculator',
77
author='Jacek Kreft',
@@ -11,9 +11,12 @@
1111
'bin/PIM_Calculator',
1212
'bin/PIM_GUI_Calculator'
1313
],
14-
setup_requires=['pytest'],
15-
tests_require=['pytest', 'pytest-mock', 'pytest-cov', 'pytest-qt', 'pytest-xvfb'],
16-
entry_points = {
14+
python_requires='>=2.7',
15+
tests_require=[
16+
'pytest', 'pytest-mock', 'pytest-cov',
17+
'pytest-qt', 'pytest-xvfb', 'scipy', 'matplotlib>=2.0'
18+
],
19+
entry_points={
1720
'console_scripts': [
1821
'PIM_Calculator=PIM_Calculator.pim_calc:main',
1922
'PIM_GUI_Calculator=PIM_Calculator.pimQt:main [GUI]'
@@ -27,4 +30,7 @@
2730
'PySide2', 'scipy>=1.0', 'matplotlib>=2.0'
2831
]
2932
},
33+
classifiers=[
34+
'Operating System :: OS Independent'
35+
],
3036
zip_safe=False)

0 commit comments

Comments
 (0)
Please sign in to comment.