Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous improvements #437

Merged
merged 34 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e946b3f
[WP] add matplotlib toolbar
Sep 17, 2021
d5a6796
Merge branch 'master' of https://github.com/Eomys/pyleecan into DXF_gui
Sep 17, 2021
607737a
[WP] add matplotlib toolbar
Sep 17, 2021
581a78b
[BC] Solve coil_pitch issue if it is set to zero or None in the Machi…
EmileDvs Sep 17, 2021
5e8512d
Merge branch 'DXF_gui' of https://github.com/EOMYS-Public/pyleecan in…
EmileDvs Sep 17, 2021
6ca7fe1
[CC] remove save button from toolbar
Sep 17, 2021
44edc47
Merge branch 'DXF_gui' of https://github.com/Eomys-public/pyleecan in…
Sep 17, 2021
843b558
[CC] Replace 1 by 0.5 to separate distributed from concentrated windings
EmileDvs Sep 17, 2021
3a1980c
[BC] Update field coercitivity when changing Brm or mur_lin in magnet…
EmileDvs Sep 17, 2021
2b93688
Merge branch 'DXF_gui' of https://github.com/EOMYS-Public/pyleecan in…
EmileDvs Sep 17, 2021
3217451
[CC] Update magnetic tests
EmileDvs Sep 20, 2021
1368fcf
[WP] comparing only input for VarLoad simulations
Sep 20, 2021
add16e3
[BC] fixed typo in method name
Sep 20, 2021
221dc61
[CC] Updating Tests
BonneelP Sep 21, 2021
2b0075e
Merge branch 'master' of https://github.com/Eomys/pyleecan into DXF_gui
BonneelP Sep 21, 2021
c1e0a42
[CC] Updating load test for SRM
BonneelP Sep 21, 2021
4944b4f
[CC] Updating Test
BonneelP Sep 21, 2021
112fd5f
[BC] Adding missing Airgap BC
BonneelP Sep 21, 2021
90d710e
[CC] Correcting typo
BonneelP Sep 21, 2021
596b826
[CC] Correcting Typo
BonneelP Sep 21, 2021
31eaa15
[CC] ui cleanup
BonneelP Sep 21, 2021
cb5bb0e
Merge branch 'DXF_gui' of https://github.com/EOMYS-Public/pyleecan in…
BonneelP Sep 21, 2021
9dfb1ae
[BC] do not select line from click if matplotlib action is active
Sep 21, 2021
53c97db
Merge branch 'DXF_gui' of https://github.com/Eomys-public/pyleecan in…
Sep 21, 2021
5e27d8a
[CO] Extending comp_masses for MachineUD (cf #439)
BonneelP Sep 21, 2021
f820427
[CO] Remove spacer from DXF layout
BonneelP Sep 21, 2021
2261897
[CC] black
Sep 22, 2021
e4ab230
[BC] prevent zoom reset when selecting line
Sep 22, 2021
731f373
Merge branch 'DXF_gui' of https://github.com/Eomys-public/pyleecan in…
Sep 22, 2021
7aca04e
[BC] fix line selection with zoom
Sep 22, 2021
4880c38
[CO] Better handle for save/load machine/material
BonneelP Sep 22, 2021
50a9ea8
[CO] Using machine.get_pole_pair_number for comp_felec
BonneelP Sep 22, 2021
e40a2a7
[CO] Better zoom stability for DXF
BonneelP Sep 23, 2021
d2f3a42
Merge branch 'DXF_gui' of https://github.com/EOMYS-Public/pyleecan in…
BonneelP Sep 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Tests/Data/Load_GUI/SRM_test_load.json
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@
"type_winding_shape": null
},
"is_reverse_wind": false,
"p": null,
"qs": 3,
"p": 5,
"qs": 2,
"type_connection": null
}
},
Expand Down
22 changes: 17 additions & 5 deletions Tests/Functions/test_save_load.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from os import getcwd, remove
from os import getcwd, remove, listdir
from os.path import isfile, join
from unittest.mock import patch # for unittest of input

Expand Down Expand Up @@ -152,11 +152,23 @@ def test_save_load_folder_path():
assert isfile(join(loc_save_path, "M400-50A.json"))
assert isfile(join(loc_save_path, "Toyota_Prius.json"))
assert isfile(join(loc_save_path, "test_save_load_folder_path.json"))
assert len(listdir(loc_save_path)) == 8
test_obj2 = load(loc_save_path)
assert test_obj == test_obj2
assert callable(test_obj.simu.postproc_list[0]._run_func)
assert callable(test_obj.simu.postproc_list[1]._run_func)

# Check that the machine can be updated
test_obj2.simu.machine.stator.L1 = 999
# Check that empty materials are not save in separate file
test_obj2.simu.machine.stator.winding.conductor.ins_mat._set_None()

test_obj2.save(loc_save_path, is_folder=True)
test_obj3 = load(loc_save_path)

assert test_obj2.simu.machine.stator.L1 == test_obj3.simu.machine.stator.L1
assert len(listdir(loc_save_path)) == 8


def test_save_load_just_name():
"""Save in a file and load"""
Expand Down Expand Up @@ -336,7 +348,7 @@ def test_save_load_simu(type_file):


if __name__ == "__main__":
# test_save_load_folder_path()
test_save_load_simu("json")
test_save_load_simu("h5")
test_save_load_simu("pkl")
test_save_load_folder_path()
# test_save_load_simu("json")
# test_save_load_simu("h5")
# test_save_load_simu("pkl")
121 changes: 67 additions & 54 deletions Tests/GUI/DMachineSetup/test_DMachineSetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,30 @@
class TestDMachineSetup(object):
"""Test that the widget DMachineSetup behave like it should"""

@pytest.fixture
def setup(self):
"""Run at the begining of every test to setup the gui"""

@classmethod
def setup_class(cls):
"""Start the app for the test"""
print("\nStart Test TestDMachineSetup")
if not QtWidgets.QApplication.instance():
self.app = QtWidgets.QApplication(sys.argv)
cls.app = QtWidgets.QApplication(sys.argv)
else:
self.app = QtWidgets.QApplication.instance()
cls.app = QtWidgets.QApplication.instance()

def setup_method(self):
"""Run at the begining of every test to setup the gui"""
# MatLib widget
material_dict = load_matlib(matlib_path=matlib_path)
widget = DMachineSetup(
self.widget = DMachineSetup(
material_dict=material_dict, machine_path=join(TEST_DATA_DIR, "Machine")
)

yield {"widget": widget}

self.app.quit()
@classmethod
def teardown_class(cls):
"""Exit the app after the test"""
cls.app.quit()

@pytest.mark.parametrize("test_dict", load_test)
def test_load(self, setup, test_dict):
def test_load(self, test_dict):
"""Check that you can load a machine"""

return_value = (
Expand All @@ -83,65 +86,65 @@ def test_load(self, setup, test_dict):
"PySide2.QtWidgets.QFileDialog.getOpenFileName", return_value=return_value
):
# To trigger the slot
setup["widget"].b_load.clicked.emit()
setup["widget"].nav_step.setCurrentRow(0)
self.widget.b_load.clicked.emit()
self.widget.nav_step.setCurrentRow(0)
# To remember to update when adding a new machine type
assert setup["widget"].w_step.c_type.count() == 8
assert self.widget.w_step.c_type.count() == 8
# Check load MachineType
assert type(setup["widget"].w_step) == SMachineType
assert setup["widget"].w_step.c_type.currentIndex() == test_dict["index"]
assert setup["widget"].w_step.c_type.currentText() == test_dict["type"]
assert type(self.widget.w_step) == SMachineType
assert self.widget.w_step.c_type.currentIndex() == test_dict["index"]
assert self.widget.w_step.c_type.currentText() == test_dict["type"]
if test_dict["p"] is not None:
assert setup["widget"].w_step.si_p.value() == test_dict["p"]
assert self.widget.w_step.si_p.value() == test_dict["p"]
else:
assert setup["widget"].w_step.si_p.isHidden()
assert setup["widget"].w_step.le_name.text() == test_dict["name"]
assert self.widget.w_step.si_p.isHidden()
assert self.widget.w_step.le_name.text() == test_dict["name"]
# Check that the nav_step is correct
assert setup["widget"].nav_step.count() == test_dict["count"]
assert self.widget.nav_step.count() == test_dict["count"]

def test_set_save_machine_type(self, setup):
def test_set_save_machine_type(self):
"""Check that the Widget allow to change the machine type and save"""
# Check that all the machine type are available
assert setup["widget"].w_step.c_type.count() == 8
assert self.widget.w_step.c_type.count() == 8
# DFIM
setup["widget"].w_step.c_type.setCurrentIndex(1)
assert setup["widget"].w_step.c_type.currentText() == "DFIM"
assert type(setup["widget"].machine) == MachineDFIM
save_function(setup["widget"], "test_dfim_save")
self.widget.w_step.c_type.setCurrentIndex(1)
assert self.widget.w_step.c_type.currentText() == "DFIM"
assert type(self.widget.machine) == MachineDFIM
save_function(self.widget, "test_dfim_save")
# SynRM
setup["widget"].w_step.c_type.setCurrentIndex(2)
assert setup["widget"].w_step.c_type.currentText() == "SynRM"
assert type(setup["widget"].machine) == MachineSyRM
save_function(setup["widget"], "test_synrm_save")
self.widget.w_step.c_type.setCurrentIndex(2)
assert self.widget.w_step.c_type.currentText() == "SynRM"
assert type(self.widget.machine) == MachineSyRM
save_function(self.widget, "test_synrm_save")
# SIPMSM
setup["widget"].w_step.c_type.setCurrentIndex(3)
assert setup["widget"].w_step.c_type.currentText() == "SPMSM"
assert type(setup["widget"].machine) == MachineSIPMSM
save_function(setup["widget"], "test_sipmsm_save")
self.widget.w_step.c_type.setCurrentIndex(3)
assert self.widget.w_step.c_type.currentText() == "SPMSM"
assert type(self.widget.machine) == MachineSIPMSM
save_function(self.widget, "test_sipmsm_save")
# IPMSM
setup["widget"].w_step.c_type.setCurrentIndex(4)
assert setup["widget"].w_step.c_type.currentText() == "IPMSM"
assert type(setup["widget"].machine) == MachineIPMSM
save_function(setup["widget"], "test_ipmsm_save")
self.widget.w_step.c_type.setCurrentIndex(4)
assert self.widget.w_step.c_type.currentText() == "IPMSM"
assert type(self.widget.machine) == MachineIPMSM
save_function(self.widget, "test_ipmsm_save")
# WRSM
setup["widget"].w_step.c_type.setCurrentIndex(5)
assert setup["widget"].w_step.c_type.currentText() == "WRSM"
assert type(setup["widget"].machine) == MachineWRSM
save_function(setup["widget"], "test_wrsm_save")
self.widget.w_step.c_type.setCurrentIndex(5)
assert self.widget.w_step.c_type.currentText() == "WRSM"
assert type(self.widget.machine) == MachineWRSM
save_function(self.widget, "test_wrsm_save")
# SRM
setup["widget"].w_step.c_type.setCurrentIndex(6)
assert setup["widget"].w_step.c_type.currentText() == "SRM"
assert type(setup["widget"].machine) == MachineSRM
save_function(setup["widget"], "test_srm_save")
self.widget.w_step.c_type.setCurrentIndex(6)
assert self.widget.w_step.c_type.currentText() == "SRM"
assert type(self.widget.machine) == MachineSRM
save_function(self.widget, "test_srm_save")
# LSPM
setup["widget"].w_step.c_type.setCurrentIndex(7)
assert setup["widget"].w_step.c_type.currentText() == "LSPM"
assert type(setup["widget"].machine) == MachineLSPM
save_function(setup["widget"], "test_lspm_save")
self.widget.w_step.c_type.setCurrentIndex(7)
assert self.widget.w_step.c_type.currentText() == "LSPM"
assert type(self.widget.machine) == MachineLSPM
save_function(self.widget, "test_lspm_save")
# SCIM
setup["widget"].w_step.c_type.setCurrentIndex(0)
assert setup["widget"].w_step.c_type.currentText() == "SCIM"
assert type(setup["widget"].machine) == MachineSCIM
self.widget.w_step.c_type.setCurrentIndex(0)
assert self.widget.w_step.c_type.currentText() == "SCIM"
assert type(self.widget.machine) == MachineSCIM


def save_function(widget, file_name):
Expand All @@ -166,3 +169,13 @@ def save_function(widget, file_name):
# Check that the GUI have been updated
assert type(widget.w_step) == SMachineType
assert widget.w_step.le_name.text() == file_name


if __name__ == "__main__":
a = TestDMachineSetup()
a.setup_class()
a.setup_method()
for test_dict in load_test:
a.test_load(test_dict)
a.test_load(load_test[6])
print("Done")
Loading