Skip to content

Commit

Permalink
Merge pull request #1 from ibell/master
Browse files Browse the repository at this point in the history
Sync with upstream
  • Loading branch information
sebdenis authored Apr 23, 2020
2 parents 6ca14ca + ec032d7 commit 99d758f
Show file tree
Hide file tree
Showing 41 changed files with 3,611 additions and 309 deletions.
20 changes: 6 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,51 +1,43 @@
*.pyc
*.h5
*.pyd
*.so
PDSim/core/_bearings.cpp
PDSim/core/_bearings.html
PDSim/core/_bearings.so
PDSim/core/callbacks.cpp
PDSim/core/callbacks.html
PDSim/core/callbacks.so
PDSim/core/containers.cpp
PDSim/core/containers.h
PDSim/core/containers.html
PDSim/core/containers.so
PDSim/flow/fanno.cpp
PDSim/flow/fanno.html
PDSim/flow/fanno.so
PDSim/flow/flow.cpp
PDSim/flow/flow.html
PDSim/flow/flow.so
PDSim/flow/flow_models.cpp
PDSim/flow/flow_models.h
PDSim/flow/flow_models.html
PDSim/flow/flow_models.so
PDSim/misc/clipper/pyclipper.cpp
PDSim/misc/clipper/pyclipper.html
PDSim/misc/clipper/pyclipper.so
PDSim/misc/datatypes.cpp
PDSim/misc/datatypes.html
PDSim/misc/datatypes.so
PDSim/misc/scipylike.cpp
PDSim/misc/scipylike.html
PDSim/misc/scipylike.so
PDSim/misc/stl_utilities.cpp
PDSim/misc/stl_utilities.html
PDSim/misc/stl_utilities.so
PDSim/recip/_recip.cpp
PDSim/recip/_recip.html
PDSim/recip/_recip.so
PDSim/scroll/_scroll.cpp
PDSim/scroll/_scroll.html
PDSim/scroll/_scroll.so
PDSim/scroll/common_scroll_geo.cpp
PDSim/scroll/common_scroll_geo.html
PDSim/scroll/common_scroll_geo.so
PDSim/scroll/symm_scroll_geo.cpp
PDSim/scroll/symm_scroll_geo.html
PDSim/scroll/symm_scroll_geo.so
doc/_build
doc/PDSim_apidoc
build
dist
PDSim.egg-info

doc/log.txt
doc/notebooks/*.rst
doc/notebooks/**/*.png
17 changes: 12 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: python
dist: bionic # 18.04
python:
- '2.7'
- '3.7'
install:
- git submodule update --init --recursive
- sudo apt-get update
Expand All @@ -14,20 +15,26 @@ install:
- conda update -q conda
- conda info -a
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION numpy matplotlib
h5py cython
h5py cython scipy
- source activate test-environment
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then conda install wxpython; else pip
-vvv install --pre -f https://wxpython.org/Phoenix/snapshot-builds/linux/gtk2/ubuntu-14.04/
--only-binary wxPython wxPython; fi
#- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then conda install wxpython; else pip
# -vvv install --pre -f https://wxpython.org/Phoenix/snapshot-builds/linux/gtk2/ubuntu-14.04/
# --only-binary wxPython wxPython; fi
- pip install -vvv --pre --trusted-host www.coolprop.dreamhosters.com --find-links
http://www.coolprop.dreamhosters.com/binaries/Python/ -U --force-reinstall CoolProp
- python setup.py install
- pip install pyflakes
- conda list
script:
- cd examples
- pyflakes simple_example.py
- python simple_example.py
- pyflakes scroll_compressor.py
- python scroll_compressor.py
- pyflakes piston_expander.py
- python piston_expander.py
- pyflakes recip_compressor.py
- python recip_compressor.py
- cd ..
deploy:
provider: pypi
Expand Down
56 changes: 32 additions & 24 deletions GUI/PDSimGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from wx.adv import SPLASH_CENTRE_ON_SCREEN as wxSPLASH_CENTRE_ON_SCREEN
from wx.adv import SPLASH_TIMEOUT as wxSPLASH_TIMEOUT


#Provided by python
import codecs
try:
Expand Down Expand Up @@ -71,7 +70,7 @@ class ConfigurationManager(object):
def __init__(self):
# Load the config file for the GUI
if os.path.exists(os.path.join(pdsim_home_folder,'gui_config.yaml')):
self.config = yaml.load(open(os.path.join(pdsim_home_folder,'gui_config.yaml'),'r'))
self.config = yaml.load(open(os.path.join(pdsim_home_folder,'gui_config.yaml'),'r'),Loader=yaml.FullLoader)
else:
self.config = {}

Expand Down Expand Up @@ -193,7 +192,7 @@ def __init__(self, parent, configdict,**kwargs):
# Register terms in the GUI database
self.main.register_GUI_objects(annotated_GUI_objects)

self.main.get_GUI_object('outlet_temperature_guess').GUI_location.SetToolTipString('Guess for outlet temperature; if <0, adiabatic efficiency will be used to estimate outlet temperature')
self.main.get_GUI_object('outlet_temperature_guess').GUI_location.SetToolTip('Guess for outlet temperature; if <0, adiabatic efficiency will be used to estimate outlet temperature')

from multiprocessing import cpu_count

Expand Down Expand Up @@ -556,7 +555,7 @@ def __init__(self,Simulations, table_string):

sizer.AddSpacer(10)
self.chkPickled = wx.CheckBox(self,label='HDF5 data files (Warning! Can be quite large)')
self.chkPickled.SetToolTipString('Hint: You can use ViTables (search Google) to open the HDF5 files')
self.chkPickled.SetToolTip('Hint: You can use ViTables (search Google) to open the HDF5 files')
self.chkPickled.SetValue(True)
sizer.Add(self.chkPickled)

Expand Down Expand Up @@ -925,9 +924,12 @@ def register_GUI_objects(self, annotated_GUI_objects):
raise TypeError('You can only register lists of AnnotatedGUIObjects. The bad item is:' + str(o))
if o.key in self.GUI_object_library:
raise KeyError('Your key [{k:s}] is already in the parameter library'.format(k = o.key))
if o.annotation in [oo.annotation for oo in self.GUI_object_library.itervalues()]:
raise KeyError('Your annotation [{a:s}] is already in the parameter library for key [{k:s}]'.format(a = o.annotation, k = o.key))

try:
if o.annotation in [oo.annotation for oo in self.GUI_object_library.itervalues()]:
raise KeyError('Your annotation [{a:s}] is already in the parameter library for key [{k:s}]'.format(a = o.annotation, k = o.key))
except:
if o.annotation in [oo.annotation for oo in self.GUI_object_library.values()]:
raise KeyError('Your annotation [{a:s}] is already in the parameter library for key [{k:s}]'.format(a = o.annotation, k = o.key))
self.GUI_object_library[o.key] = o

def unregister_GUI_objects(self, keys):
Expand Down Expand Up @@ -1334,7 +1336,7 @@ def load_plugins(self, PluginsMenu, config):

# Create a menu item for the plugin
menuItem = wx.MenuItem(PluginsMenu, -1, thing.short_description, "", wx.ITEM_CHECK)
PluginsMenu.AppendItem(menuItem)
PluginsMenu.Append(menuItem)
# Bind the event to activate the plugin
self.Bind(wx.EVT_MENU, plugin.activate, menuItem)

Expand All @@ -1356,16 +1358,22 @@ def load_families(self, FamiliesMenu):
"""
Load any machine families into the GUI that are found in families folder
"""
import glob, pkgutil
import glob, pkgutil,importlib
self.plugins_list = []

def load_all_modules_from_dir(dirname, keep_loaded = True):
mods = []
for importer, package_name, _ in pkgutil.iter_modules([dirname]):
full_package_name = '%s.%s' % (dirname, package_name)
if full_package_name not in sys.modules or keep_loaded:
module = importer.find_module(package_name
).load_module(full_package_name)
# module = importer.find_module(package_name
# ).load_module(full_package_name)
module = importlib.import_module(full_package_name)

# path = dirname
# fullname = package_name
# module_find = importlib.abc.MetaPathFinder.find_module(fullname,path)
# module = module_find.module_for_loader(full_package_name)
mods.append(module)
return mods

Expand All @@ -1381,7 +1389,7 @@ def load_all_modules_from_dir(dirname, keep_loaded = True):
menuItem = wx.MenuItem(FamiliesMenu, -1, family_menu_name, "", wx.ITEM_CHECK)

# Add the menu item
FamiliesMenu.AppendItem(menuItem)
FamiliesMenu.Append(menuItem)

# Attach a pointer to the module for this family
if not hasattr(self,'families_dict'): self.families_dict = {}
Expand Down Expand Up @@ -1409,11 +1417,11 @@ def make_menu_bar(self):
self.menuFileConsole = wx.MenuItem(self.File, -1, "Open a python console", "", wx.ITEM_NORMAL)
self.menuFileQuit = wx.MenuItem(self.File, -1, "Quit\tCtrl+Q", "", wx.ITEM_NORMAL)

self.File.AppendItem(self.menuFileOpen)
self.File.AppendItem(self.menuFileSave)
self.File.AppendItem(self.menuFileFlush)
self.File.AppendItem(self.menuFileConsole)
self.File.AppendItem(self.menuFileQuit)
self.File.Append(self.menuFileOpen)
self.File.Append(self.menuFileSave)
self.File.Append(self.menuFileFlush)
self.File.Append(self.menuFileConsole)
self.File.Append(self.menuFileQuit)

self.MenuBar.Append(self.File, "File")
self.Bind(wx.EVT_MENU,self.OnOpenConsole,self.menuFileConsole)
Expand All @@ -1429,22 +1437,22 @@ def make_menu_bar(self):
#self.load_plugins(self.PluginsMenu)
self.MenuBar.Append(self.PluginsMenu, "Plugins")
self.menuPluginsManage = wx.MenuItem(self.File, -1, "Manage plugin folders...", "", wx.ITEM_NORMAL)
self.PluginsMenu.AppendItem(self.menuPluginsManage)
self.PluginsMenu.Append(self.menuPluginsManage)
self.Bind(wx.EVT_MENU,self.OnManagePluginFolders,self.menuPluginsManage)
self.PluginsMenu.AppendSeparator()

self.Solve = wx.Menu()
self.SolveSolve = wx.MenuItem(self.Solve, -1, "Solve\tF5", "", wx.ITEM_NORMAL)
self.Solve.AppendItem(self.SolveSolve)
self.Solve.Append(self.SolveSolve)
self.MenuBar.Append(self.Solve, "Solve")
self.Bind(wx.EVT_MENU, self.OnStart, self.SolveSolve)

self.Help = wx.Menu()
#self.HelpHelp = wx.MenuItem(self.Help, -1, "Help...\tCtrl+H", "", wx.ITEM_NORMAL)
self.HelpAbout = wx.MenuItem(self.Help, -1, "About", "", wx.ITEM_NORMAL)
self.HelpScreenShot = wx.MenuItem(self.Help, -1, "Take screenshot", "", wx.ITEM_NORMAL)
self.Help.AppendItem(self.HelpAbout)
self.Help.AppendItem(self.HelpScreenShot)
self.Help.Append(self.HelpAbout)
self.Help.Append(self.HelpScreenShot)
self.MenuBar.Append(self.Help, "Help")
self.Bind(wx.EVT_MENU, lambda event: self.OnTakeScreenShot(event = None), self.HelpScreenShot)
self.Bind(wx.EVT_MENU, self.OnAbout, self.HelpAbout)
Expand Down Expand Up @@ -1523,7 +1531,7 @@ def __init__(self,parent,plugin_dirs = [],*args,**kwargs):
sizer.Add(wx.StaticText(self, label='Directories to be searched for plugins'))

self.List = wx.ListBox(self)
self.List.AppendItems(plugin_dirs)
self.List.Append(plugin_dirs)
self.List.SetMinSize((500,100))
sizer.Add(self.List)

Expand Down Expand Up @@ -1838,8 +1846,8 @@ def __init__(self, parent=None):
wxSplashScreen.__init__(self, aBitmap, splashStyle,
splashDuration, parent)
self.Bind(wx.EVT_CLOSE, self.OnExit)

wx.Yield()
wx.GetApp().Yield()

def OnExit(self, evt):
self.Hide()
Expand Down
7 changes: 3 additions & 4 deletions GUI/default_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@

def get_defaults(family):
if family == 'scroll':
return yaml.load(scroll_yaml)
return yaml.load(scroll_yaml,Loader=yaml.FullLoader)
elif family == 'recip':
return yaml.load(recip_yaml)
return yaml.load(recip_yaml,Loader=yaml.FullLoader)
else:
raise ValueError('Your machine family [{f:s}] was not found'.format(f=family))

if __name__=='__main__':
print(get_defaults('recip'))

2 changes: 1 addition & 1 deletion GUI/families/recip_compressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def get_config_chunks(self):
return chunks

recip_yaml = (
"""
r"""
family : Recip Compressor
GeometryPanel:
Expand Down
4 changes: 2 additions & 2 deletions GUI/families/scroll.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def get_config_chunks(self):
return chunks

scroll_yaml=(
"""
r"""
family : Scroll Compressor
GeometryPanel:
Expand Down Expand Up @@ -291,7 +291,7 @@ def get_config_chunks(self):

# This block was removed from the default configuration so that injection is not
# enabled by default. It can be replaced to enable injection by default
"""
r"""
Plugin:ScrollInjectionPlugin:
- Length : 1.1
ID : 0.01
Expand Down
Loading

0 comments on commit 99d758f

Please sign in to comment.