Changeset b768e92 in sasview
- Timestamp:
- Jun 2, 2016 8:14:35 AM (9 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- ec30905
- Parents:
- 6afc14b (diff), 70305bd2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 5 added
- 8 deleted
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
r02098e3 re04f87b 51 51 /test/sasdataloader/test/test_log.txt 52 52 53 # autogenerated scripts 54 /sasview/installer.iss 55 -
build_tools/conda/bumps/meta.yaml
rb75079b r243fbc0 1 1 package: 2 2 name: bumps 3 version: !!str 0.7.5. 43 version: !!str 0.7.5.9 4 4 5 5 source: 6 fn: bumps-0.7.5. 4.tar.gz7 url: https://pypi.python.org/packages/source/b/bumps/bumps-0.7.5. 4.tar.gz6 fn: bumps-0.7.5.9.tar.gz 7 url: https://pypi.python.org/packages/source/b/bumps/bumps-0.7.5.9.tar.gz 8 8 md5: a47c035fbb18afa5ca53067506a5ff1c 9 9 # patches: -
build_tools/jenkins_linux_build.sh
r9d5427f rbf3ca1e 1 #! /bin/sh 1 export PATH=$PATH:/usr/local/bin/ 2 2 3 # try to find reasonable settings, if not provided in the environment4 3 PYTHON=${PYTHON:-`which python`} 5 4 EASY_INSTALL=${EASY_INSTALL:-`which easy_install`} 6 5 PYLINT=${PYLINT:-`which pylint`} 7 BUILD_TOOLS_DIR=`dirname $0` 8 WORKSPACE=${WORKSPACE:-`readlink -f $BUILD_TOOLS_DIR/..`} 9 # WORKSPACE top level of source 6 7 export PYTHONPATH=$PYTHONPATH:$WORKSPACE/sasview/utils 8 export PYTHONPATH=$PYTHONPATH:$WORKSPACE/sasview/sasview-install 9 10 10 11 11 cd $WORKSPACE 12 13 # SASMODLES 14 cd $WORKSPACE 15 cd sasmodels 16 17 rm -rf build 18 rm -rf dist 19 20 $PYTHON setup.py clean 21 $PYTHON setup.py build 22 23 24 # SASMODLES - BUILD DOCS 25 cd doc 26 make html 27 28 cd $WORKSPACE 29 cd sasmodels 30 $PYTHON setup.py bdist_egg 31 32 33 # SASVIEW 34 cd $WORKSPACE 35 cd sasview 12 36 rm -rf sasview-install 13 mkdir sasview-install 37 mkdir sasview-install 38 rm -rf utils 39 mkdir utils 14 40 rm -rf dist 15 41 rm -rf build 16 42 17 "$EASY_INSTALL" -d "$WORKSPACE/utils" bumps==0.7.5.618 "$EASY_INSTALL" -d "$WORKSPACE/utils" periodictable==1.3.019 43 20 export PYTHONPATH=$WORKSPACE/sasview-install:$WORKSPACE/utils:$PYTHONPATH 44 # INSTALL SASMODELS 45 cd $WORKSPACE 46 cd sasmodels 47 cd dist 48 $EASY_INSTALL -d $WORKSPACE/sasview/utils sasmodels*.egg 21 49 22 $PYTHON check_packages.py23 $PYTHON setup.py bdist_egg24 50 25 cd $WORKSPACE/dist 26 # ln -s sasview*.egg sasview.egg || true 27 $EASY_INSTALL -N -d ../sasview-install sasview*.egg 51 # BUILD SASVIEW 52 cd $WORKSPACE 53 cd sasview 54 $PYTHON setup.py clean 55 $PYTHON setup.py build docs bdist_egg 28 56 57 58 # INSTALL SASVIEW 59 cd $WORKSPACE 60 cd sasview 61 cd dist 62 $EASY_INSTALL -d $WORKSPACE/sasview/sasview-install sasview*.egg 63 64 65 # TEST 66 cd $WORKSPACE 67 cd sasview 68 cd test 69 $PYTHON utest_sasview.py 70 71 ## PYLINT 72 #cd $WORKSPACE 73 #cd sasview 74 #$PYLINT --rcfile "build_tools/pylint.rc" -f parseable sasview-install/sasview*.egg/sas sasview | tee test/sasview.txt 75 76 -
build_tools/jenkins_osx_build.sh
r1780d8b r52b7fd9 1 1 export PATH=$PATH:/usr/local/bin/ 2 3 2 4 3 PYTHON=${PYTHON:-`which python`} … … 8 7 export PYTHONPATH=$PYTHONPATH:$WORKSPACE/sasview/utils 9 8 export PYTHONPATH=$PYTHONPATH:$WORKSPACE/sasview/sasview-install 9 export PYTHONPATH=$PYTHONPATH:/Library/Python/2.7/site-packages 10 10 11 export LC_ALL=en_US.UTF-8 11 12 export LANG=en_US.UTF-8 … … 56 57 cd sasview 57 58 $PYTHON setup.py clean 58 $PYTHON setup.py build 59 $PYTHON setup.py docs 59 $PYTHON setup.py build docs bdist_egg 60 60 61 61 62 # SASVIEW BUILD_egg with new docs62 # INSTALL SASVIEW 63 63 cd $WORKSPACE 64 64 cd sasview 65 python setup.py bdist_egg66 65 cd dist 67 66 $EASY_INSTALL -d $WORKSPACE/sasview/sasview-install sasview*.egg 67 68 68 69 69 # TEST … … 78 78 $PYLINT --rcfile "build_tools/pylint.rc" -f parseable sasview-install/sasview*.egg/sas sasview | tee test/sasview.txt 79 79 80 81 80 # BUILD APP 82 81 cd $WORKSPACE 83 82 cd sasview/sasview 84 pythonsetup_mac.py py2app83 $PYTHON setup_mac.py py2app 85 84 -
build_tools/jenkins_rhel6_build.sh
r9d5427f r243fbc0 28 28 "$EASY_INSTALL" -d "$WORKSPACE/utils" lxml 29 29 "$EASY_INSTALL" -d "$WORKSPACE/utils" pyparsing==1.5.5 30 "$EASY_INSTALL" -d "$WORKSPACE/utils" bumps==0.7.5. 630 "$EASY_INSTALL" -d "$WORKSPACE/utils" bumps==0.7.5.9 31 31 "$EASY_INSTALL" -d "$WORKSPACE/utils" periodictable==1.3.0 32 32 python deps.py -
build_tools/jenkins_win_build.bat
r261e075 rb4994b7 1 set PYTHON=c:\python27\python 2 set EASY_INSTALL=c:\python27\scripts\easy_install.exe 3 set PATH=c:\python27;c:\mingw\bin;%PATH% 4 set PYLINT= C:\Python27\Scripts\pylint 5 set INNO="C:\Program Files (x86)\Inno Setup 5\ISCC.exe" 1 6 2 set PYTHON =C:\Python27\python3 set EASY_INSTALL=c:\python27\scripts\easy_install.exe4 set NEXUSDIR="C:\Program Files (x86)\NeXus Data Format\" 5 set PATH=C:\Python27;C:\Python27\Scripts;C:\mingw\bin;%PATH%6 set PYLINT=c:\python27\scripts\pylint 7 set PYTHONPATH=%PYTHONPATH%;%WORKSPACE%\sasview\utils 8 set PYTHONPATH=%PYTHONPATH%;%WORKSPACE%\sasview\sasview-install 9 10 echo %PYTHONPATH% 11 echo %WORKSPACE% 7 12 8 13 9 cd %WORKSPACE%\sasview 10 %PYTHON% check_packages.py 14 :: MAKE DIR FOR EGGS ################################################## 15 cd %WORKSPACE% 16 cd sasview 17 MD sasview-install 18 MD utils 11 19 12 20 13 cd %WORKSPACE%\sasview 14 python setup.py build -cmingw32 21 :: SASMODELS build #################################################### 22 cd %WORKSPACE% 23 cd sasmodels 24 %PYTHON% setup.py build 15 25 16 26 17 cd %WORKSPACE%\sasview 18 python setup.py docs 27 28 :: SASMODELS doc ###################################################### 29 cd doc 30 make html 19 31 20 32 21 cd %WORKSPACE%\sasview 22 python setup.py bdist_egg --skip-build 33 :: SASMODELS build egg ################################################ 34 cd %WORKSPACE% 35 cd sasmodels 36 %PYTHON% setup.py bdist_egg 23 37 24 38 39 :: SASMODELS install egg ############################################## 40 cd %WORKSPACE% 41 cd sasmodels 42 cd dist 43 echo F | xcopy sasmodels-*.egg sasmodels.egg /Y 44 %EASY_INSTALL% -d %WORKSPACE%\sasview\utils sasmodels.egg 45 46 47 :: NOW BUILD SASVIEW 48 49 :: SASVIEW build egg ################################################ 50 :: Remember to modify C:\Python27\Lib\distutils\distutils.cfg to you compiler 51 cd %WORKSPACE% 52 cd sasview 53 %PYTHON% setup.py build docs bdist_egg 54 55 56 :: SASVIEW utest ###################################################### 25 57 cd %WORKSPACE%\sasview\test 26 58 %PYTHON% utest_sasview.py 27 59 28 60 29 cd %WORKSPACE%\sasview 30 mkdir sasview-install 31 set PYTHONPATH=%WORKSPACE%\sasview\sasview-install;%PYTHONPATH% 61 :: SASVIEW INSTALL EGG ################################################ 62 cd %WORKSPACE% 63 cd sasview 64 cd dist 65 echo F | xcopy sasview-*.egg sasview.egg /Y 66 %EASY_INSTALL% -d %WORKSPACE%\sasview\sasview-install sasview.egg 32 67 33 68 34 cd %WORKSPACE%\sasview 35 cd dist 36 %EASY_INSTALL% -d ..\sasview-install sasview-3.1.2-py2.7-win32.egg 69 :: TINYCC build #################################################### 70 cd %WORKSPACE% 71 cd tinycc 72 %PYTHON% setup.py build 73 xcopy /S build\lib\* %WORKSPACE%\sasview\utils\ 37 74 38 39 cd %WORKSPACE% \sasview\sasview40 python setup_exe.py py2exe 41 python installer_generator.py 42 "C:\Program Files (x86)\Inno Setup 5\ISCC.exe" installer.iss 43 44 75 :: SASVIEW INSTALLER ################################################## 76 cd %WORKSPACE% 77 cd sasview 78 cd sasview 79 %PYTHON% setup_exe.py py2exe 80 %PYTHON% installer_generator.py 81 %INNO% installer.iss 45 82 cd Output 46 83 xcopy setupSasView.exe %WORKSPACE%\sasview\dist 47 84 85 :: SASVIEW PYLINT ##################################################### 48 86 cd %WORKSPACE%\sasview 49 %PYLINT% --rcfile "build_tools/pylint.rc" -f parseable sasview-install/sasview *.egg/sas sasview > test/sasview.txt87 %PYLINT% --rcfile "build_tools/pylint.rc" -f parseable sasview-install/sasview.egg/sas sasview > test/sasview.txt 50 88 51 89 52 cd %WORKSPACE% 90 :: GO BACK ############################################################ 91 cd %WORKSPACE% -
build_tools/requirements.txt
ra985c93 r243fbc0 9 9 PIL==1.1.7 10 10 periodictable==1.3.0 11 bumps==0.7.5. 511 bumps==0.7.5.9 12 12 # numpy==1.6.1 13 13 # scipy==0.10.1 -
check_packages.py
r8e7044c r96e151f 7 7 # Fix for error: hash-collision-3-both-1-and-1/ 8 8 # See http://jaredforsyth.com/blog/2010/apr/28/accessinit-hash-collision-3-both-1-and-1/ 9 import PIL.Image 10 sys.modules['Image'] = PIL.Image 9 try: 10 import PIL.Image 11 except ImportError: 12 pass 13 else: 14 sys.modules['Image'] = PIL.Image 15 11 16 12 17 common_required_package_list = { … … 19 24 'pylint':{'version':None,'import_name':'pylint','test':None}, 20 25 'periodictable':{'version':'1.3.0','import_name':'periodictable','test':'__version__'}, 21 'bumps':{'version':'0.7.5. 7','import_name':'bumps','test':'__version__'},26 'bumps':{'version':'0.7.5.9','import_name':'bumps','test':'__version__'}, 22 27 'numpy':{'version':'1.6.1','import_name':'numpy','test':'__version__'}, 23 28 'scipy':{'version':'0.10.1','import_name':'scipy','test':'__version__'}, -
docs/sphinx-docs/Makefile
rc23de6a r1d5f5c2 118 118 $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 119 119 @echo "Running LaTeX files through pdflatex..." 120 $(MAKE)-C $(BUILDDIR)/latex all-pdf120 "$(MAKE)" -C $(BUILDDIR)/latex all-pdf 121 121 @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 122 122 … … 124 124 $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 125 125 @echo "Running LaTeX files through platex and dvipdfmx..." 126 $(MAKE)-C $(BUILDDIR)/latex all-pdf-ja126 "$(MAKE)" -C $(BUILDDIR)/latex all-pdf-ja 127 127 @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 128 128 -
sasview/README.txt
rfa4ea80 r243fbc0 343 343 - unittest-xml-reporting 1.12.0 (MAC 1.10.0) 344 344 - matplotlib Version Installed: 1.4.3 (MAC 1.1.1) 345 - bumps Version Installed: 0.7.5. 6345 - bumps Version Installed: 0.7.5.9 346 346 - scipy Version Installed: 0.16.0b2 (MAC 0.11.0) 347 347 - periodictable Version Installed: 1.4.1 -
sasview/installer_generator.py
r50008e3 r6a698c0 197 197 msg += """Source: "dist\*";\tDestDir: "{app}";\t""" 198 198 msg += """Flags: ignoreversion recursesubdirs createallsubdirs\n""" 199 msg += """Source: "dist\plugin_models\*";\tDestDir: "{userdesktop}\..\.sasview\plugin_models";\t""" 199 msg += """Source: "dist\plugin_models\*";\tDestDir: "{userdesktop}\..\.sasview\plugin_models";\t""" 200 msg += """Flags: recursesubdirs createallsubdirs\n""" 201 msg += """Source: "dist\compiled_models\*";\tDestDir: "{userdesktop}\..\.sasmodels\compiled_models";\t""" 200 202 msg += """Flags: recursesubdirs createallsubdirs\n""" 201 203 msg += """Source: "dist\config\custom_config.py";\tDestDir: "{userdesktop}\..\.sasview\config";\t""" -
sasview/sasview.py
r558d64e r1be5202 81 81 #Always use private .matplotlib setup to avoid conflicts with other 82 82 #uses of matplotlib 83 #Have to check if .sasview exists first 84 sasdir = os.path.join(os.path.expanduser("~"),'.sasview') 85 if not os.path.exists(sasdir): 86 os.mkdir(sasdir) 83 87 mplconfigdir = os.path.join(os.path.expanduser("~"),'.sasview','.matplotlib') 84 88 if not os.path.exists(mplconfigdir): -
sasview/setup_exe.py
r40fc798 r9528caa 16 16 import os 17 17 import sys 18 import warnings 19 from glob import glob 20 import shutil 21 22 from distutils.util import get_platform 23 from distutils.core import setup 24 from distutils.filelist import findall 25 from distutils.sysconfig import get_python_lib 26 import py2exe 27 28 #from idlelib.PyShell import warning_stream 18 29 19 30 # put the build directory at the front of the path 20 31 if os.path.abspath(os.path.dirname(__file__)) != os.path.abspath(os.getcwd()): 21 32 raise RuntimeError("Must run setup_exe from the sasview directory") 22 from distutils.util import get_platform23 33 root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 24 34 platform = '%s-%s'%(get_platform(), sys.version[:3]) 25 35 build_path = os.path.join(root, 'build', 'lib.'+platform) 36 #build_path = os.path.join(root, 'sasview-install', 'Lib', 'site-packages') 26 37 sys.path.insert(0, build_path) 27 38 28 39 import local_config 40 from installer_generator import generate_installer 41 42 import matplotlib 43 try: 44 import tinycc 45 except ImportError: 46 warnings.warn("TinyCC package is not available and will not be included") 47 tinycc = None 29 48 30 49 if len(sys.argv) == 1: 31 50 sys.argv.append('py2exe') 51 32 52 # When using the SasView build script, we need to be able to pass 33 53 # an extra path to be added to the python path. The extra arguments … … 45 65 sys.exc_value 46 66 47 from distutils.core import setup48 from distutils.filelist import findall49 import matplotlib50 67 51 68 # Solution taken from here: http://www.py2exe.org/index.cgi/win32com.shell … … 79 96 pass 80 97 81 import py2exe82 import shutil83 98 # Remove the build folder 84 99 shutil.rmtree("build", ignore_errors=True) … … 86 101 shutil.rmtree("dist", ignore_errors=True) 87 102 88 if sys.version_info < (2, 6): 89 is_64bits = False 90 origIsSystemDLL = py2exe.build_exe.isSystemDLL 91 def isSystemDLL(pathname): 92 if os.path.basename(pathname).lower() in ("msvcp71.dll", "comctl32.dll"): 93 return 0 94 return origIsSystemDLL(pathname) 95 py2exe.build_exe.isSystemDLL = isSystemDLL 103 is_64bits = sys.maxsize > 2**32 104 arch = "amd64" if is_64bits else "x86" 105 manifest = """ 106 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 107 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 108 <assemblyIdentity 109 version="5.0.0.0" 110 processorArchitecture="%(arch)s" 111 name="SasView" 112 type="win32"> 113 </assemblyIdentity> 114 <description>SasView</description> 115 <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> 116 <security> 117 <requestedPrivileges> 118 <requestedExecutionLevel 119 level="asInvoker" 120 uiAccess="false"> 121 </requestedExecutionLevel> 122 </requestedPrivileges> 123 </security> 124 </trustInfo> 125 <dependency> 126 <dependentAssembly> 127 <assemblyIdentity 128 type="win32" 129 name="Microsoft.VC90.CRT" 130 version="9.0.21022.8" 131 processorArchitecture="%(arch)s" 132 publicKeyToken="1fc8b3b9a1e18e3b"> 133 </assemblyIdentity> 134 </dependentAssembly> 135 </dependency> 136 <dependency> 137 <dependentAssembly> 138 <assemblyIdentity 139 type="win32" 140 name="Microsoft.Windows.Common-Controls" 141 version="6.0.0.0" 142 processorArchitecture="%(arch)s" 143 publicKeyToken="6595b64144ccf1df" 144 language="*"> 145 </assemblyIdentity> 146 </dependentAssembly> 147 </dependency> 148 </assembly> 149 """%{'arch': arch} 150 151 if is_64bits: 152 msvcrtdll = glob(r"C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*") 96 153 else: 97 is_64bits = sys.maxsize > 2**32 98 99 if is_64bits and sys.version_info >= (2, 6): 100 manifest = """ 101 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 102 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" 103 manifestVersion="1.0"> 104 <assemblyIdentity 105 version="0.64.1.0" 106 processorArchitecture="amd64" 107 name="Controls" 108 type="win32" 109 /> 110 <description>SasView</description> 111 <dependency> 112 <dependentAssembly> 113 <assemblyIdentity 114 type="win32" 115 name="Microsoft.Windows.Common-Controls" 116 version="6.0.0.0" 117 processorArchitecture="amd64" 118 publicKeyToken="6595b64144ccf1df" 119 language="*" 120 /> 121 </dependentAssembly> 122 </dependency> 123 </assembly> 124 """ 154 msvcrtdll = glob(r"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*") 155 if msvcrtdll: 156 msvcrtdll_data_files = ("Microsoft.VC90.CRT", msvcrtdll) 125 157 else: 126 manifest_for_python26 = """ 127 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 128 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 129 <assemblyIdentity 130 version="5.0.0.0" 131 processorArchitecture="x86" 132 name="SasView" 133 type="win32"> 134 </assemblyIdentity> 135 <description>SasView</description> 136 <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> 137 <security> 138 <requestedPrivileges> 139 <requestedExecutionLevel 140 level="asInvoker" 141 uiAccess="false"> 142 </requestedExecutionLevel> 143 </requestedPrivileges> 144 </security> 145 </trustInfo> 146 <dependency> 147 <dependentAssembly> 148 <assemblyIdentity 149 type="win32" 150 name="Microsoft.VC90.CRT" 151 version="9.0.21022.8" 152 processorArchitecture="x86" 153 publicKeyToken="1fc8b3b9a1e18e3b"> 154 </assemblyIdentity> 155 </dependentAssembly> 156 </dependency> 157 <dependency> 158 <dependentAssembly> 159 <assemblyIdentity 160 type="win32" 161 name="Microsoft.Windows.Common-Controls" 162 version="6.0.0.0" 163 processorArchitecture="x86" 164 publicKeyToken="6595b64144ccf1df" 165 language="*"> 166 </assemblyIdentity> 167 </dependentAssembly> 168 </dependency> 169 </assembly> 170 """ 171 manifest_for_python25 = """ 172 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 173 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" 174 manifestVersion="1.0"> 175 <assemblyIdentity 176 version="0.64.1.0" 177 processorArchitecture="x86" 178 name="Controls" 179 type="win32" 180 /> 181 <description>SasView</description> 182 <dependency> 183 <dependentAssembly> 184 <assemblyIdentity 185 type="win32" 186 name="Microsoft.Windows.Common-Controls" 187 version="6.0.0.0" 188 processorArchitecture="X86" 189 publicKeyToken="6595b64144ccf1df" 190 language="*" 191 /> 192 </dependentAssembly> 193 </dependency> 194 </assembly> 195 """ 196 197 # Select the appropriate manifest to use. 198 py26MSdll_x86 = None 199 if sys.version_info >= (3, 0) or sys.version_info < (2, 5): 200 print "*** This script only works with Python 2.5, 2.6, or 2.7." 201 sys.exit() 202 elif sys.version_info >= (2, 6): 203 manifest = manifest_for_python26 204 from glob import glob 205 py26MSdll = glob(r"C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*") 206 try: 207 py26MSdll_x86 = glob(r"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*") 208 except: 209 pass 210 elif sys.version_info >= (2, 5): 211 manifest = manifest_for_python25 212 py26MSdll = None 158 msvcrtdll_data_files = None 213 159 214 160 … … 238 184 matplotlibdatadir = matplotlib.get_data_path() 239 185 matplotlibdata = findall(matplotlibdatadir) 186 187 site_loc = get_python_lib() 188 opencl_include_dir = os.path.join(site_loc, "pyopencl", "cl") 189 240 190 data_files = [] 191 192 if tinycc: 193 data_files += tinycc.data_files() 194 241 195 # Copying SLD data 242 196 import periodictable 243 import logging244 197 data_files += periodictable.data_files() 245 198 … … 256 209 data_files += guiframe.data_files() 257 210 258 import sas.models as models 259 data_files += models.data_files() 211 # precompile sas models into the sasview build path; doesn't matter too much 212 # where it is so long as it is a place that will get cleaned up afterwards. 213 import sasmodels.core 214 dll_path = os.path.join(build_path, 'compiled_models') 215 compiled_dlls = sasmodels.core.precompile_dlls(dll_path, dtype='double') 216 217 # include the compiled models as data; coordinate the target path for the 218 # data with installer_generator.py 219 data_files.append(('compiled_models', compiled_dlls)) 220 221 import sasmodels 222 data_files += sasmodels.data_files() 260 223 261 224 for f in matplotlibdata: … … 313 276 data_files.append(("test\\upcoming_formats", [f])) 314 277 278 # Copying opencl include files 279 for f in findall(opencl_include_dir): 280 data_files.append(("includes\\pyopencl",[f])) 315 281 316 282 # See if the documentation has been built, and if so include it. … … 324 290 raise Exception("You must first build the documentation before creating an installer.") 325 291 326 if py26MSdllis not None:292 if msvcrtdll_data_files is not None: 327 293 # install the MSVC 9 runtime dll's into the application folder 328 data_files.append(("Microsoft.VC90.CRT", py26MSdll)) 329 if py26MSdll_x86 is not None: 330 # install the MSVC 9 runtime dll's into the application folder 331 data_files.append(("Microsoft.VC90.CRT", py26MSdll_x86)) 294 data_files.append(msvcrtdll_data_files) 332 295 333 296 # NOTE: … … 338 301 packages = [ 339 302 'matplotlib', 'scipy', 'encodings', 'comtypes', 340 'win32com', 'xhtml2pdf', 'bumps', 303 'win32com', 'xhtml2pdf', 'bumps','sasmodels', 'sas', 341 304 ] 342 305 packages.extend([ … … 356 319 includes = ['site', 'lxml._elementpath', 'lxml.etree'] 357 320 321 if tinycc: 322 packages.append('tinycc') 323 358 324 # Exclude packages that are not needed but are often found on build systems 359 excludes = ['Tkinter', 'PyQt4', '_tkagg', 'sip', 'pytz' ]325 excludes = ['Tkinter', 'PyQt4', '_tkagg', 'sip', 'pytz', 'sympy'] 360 326 361 327 … … 372 338 # accidental links to msys/cygwin binaries; shouldn't be needed 373 339 'cygwin1.dll', 340 # no need to distribute OpenCL.dll - users should have their own copy 341 'OpenCL.dll' 374 342 ] 375 343 … … 385 353 if is_64bits: 386 354 bundle_option = 3 387 import installer_generator as gen 388 gen.generate_installer() 355 generate_installer() 389 356 #initialize category stuff 390 357 #from sas.sasgui.guiframe.CategoryInstaller import CategoryInstaller -
sasview/setup_mac.py
rbd971ec r7c752d0e 20 20 import sys 21 21 import platform 22 #Extending recursion limit 23 sys.setrecursionlimit(10000) 22 24 23 25 from distutils.util import get_platform … … 26 28 build_path = os.path.join(root, 'build','lib.'+platform) 27 29 sys.path.insert(0, build_path) 28 30 print "BUILDING PATH INSIDE", build_path 29 31 ICON = local_config.SetupIconFile_mac 30 32 EXTENSIONS_LIST = [] … … 41 43 import sas.sasgui.perspectives.invariant as invariant 42 44 DATA_FILES += invariant.data_files() 43 import sas .models as models45 import sasmodels as models 44 46 DATA_FILES += models.data_files() 45 47 import sas.sasgui.guiframe as guiframe … … 67 69 # See if the documentation has been built, and if so include it. 68 70 doc_path = os.path.join(build_path, "doc") 71 print doc_path 69 72 if os.path.exists(doc_path): 70 73 for dirpath, dirnames, filenames in os.walk(doc_path): … … 131 134 'packages': ['lxml','numpy', 'scipy', 'pytz', 'encodings', 132 135 'encodings','matplotlib', 'periodictable', 133 'reportlab','sasmodels' 136 'reportlab','sasmodels',"pyopencl" 134 137 ], 135 138 'iconfile': ICON, -
setup.py
rc8843be r3371d81 9 9 from distutils.command.build_ext import build_ext 10 10 from distutils.core import Command 11 from shutil import rmtree12 13 try:14 from numpy.distutils.misc_util import get_numpy_include_dirs15 NUMPY_INC = get_numpy_include_dirs()[0]16 except:17 try:18 import numpy19 NUMPY_INC = os.path.join(os.path.split(numpy.__file__)[0],20 "core","include")21 except:22 msg = "\nNumpy is needed to build SasView. "23 print msg, "Try easy_install numpy.\n %s" % str(sys.exc_value)24 sys.exit(0)25 11 26 12 # Manage version number ###################################### … … 38 24 # except when there is no such file 39 25 # Todo : make this list generic 40 # 26 #plugin_model_list = ['polynominal5.py', 'sph_bessel_jn.py', 41 27 # 'sum_Ap1_1_Ap2.py', 'sum_p1_p2.py', 42 28 # 'testmodel_2.py', 'testmodel.py', … … 59 45 if os.path.isfile(f_path): 60 46 os.remove(f_path) 61 # 62 # 47 #f_path = os.path.join(sas_dir, 'plugin_models') 48 #if os.path.isdir(f_path): 63 49 # for f in os.listdir(f_path): 64 50 # if f in plugin_model_list: … … 204 190 205 191 # sas.sascalc.calculator 206 numpy_incl_path = os.path.join(NUMPY_INC, "numpy")207 192 gen_dir = os.path.join("src", "sas", "sascalc", "calculator", "c_extensions") 208 193 package_dir["sas.sascalc.calculator.core"] = gen_dir … … 215 200 os.path.join(gen_dir, "libfunc.c"), 216 201 os.path.join(gen_dir, "librefl.c"), 217 os.path.join(gen_dir, "winFuncs.c"),218 202 ], 219 include_dirs=[ numpy_incl_path,gen_dir],203 include_dirs=[gen_dir], 220 204 ) 221 205 ) … … 231 215 os.path.join(srcdir, "invertor.c"), 232 216 ], 233 include_dirs=[ numpy_incl_path],217 include_dirs=[], 234 218 ) ) 235 219 … … 249 233 250 234 package_dir["sas.sasgui.perspectives.fitting"] = os.path.join("src", "sas", "sasgui", "perspectives", "fitting") 251 packages.extend(["sas.sasgui.perspectives.fitting"]) 252 package_data['sas.sasgui.perspectives.fitting'] = ['media/*'] 235 package_dir["sas.sasgui.perspectives.fitting.plugin_models"] = os.path.join("src", "sas", "sasgui", "perspectives", "fitting", "plugin_models") 236 packages.extend(["sas.sasgui.perspectives.fitting", "sas.sasgui.perspectives.fitting.plugin_models"]) 237 package_data['sas.sasgui.perspectives.fitting'] = ['media/*', 'plugin_models/*'] 253 238 254 239 packages.extend(["sas.sasgui.perspectives", "sas.sasgui.perspectives.calculator"]) … … 266 251 # package_dir["sas.models"] = os.path.join("src", "sas", "models") 267 252 # packages.append("sas.models") 268 269 IGNORED_FILES = [".svn"]270 if not os.name=='nt':271 IGNORED_FILES.extend(["gamma_win.c","winFuncs.c"])272 253 273 254 EXTENSIONS = [".c", ".cpp"] … … 280 261 if os.path.isfile(os.path.join(dir_path, f)): 281 262 _, ext = os.path.splitext(f) 282 if ext.lower() in EXTENSIONS and f not in IGNORED_FILES:263 if ext.lower() in EXTENSIONS: 283 264 file_list.append(os.path.join(dir_path, f)) 284 265 elif os.path.isdir(os.path.join(dir_path, f)) and \ … … 288 269 if os.path.isfile(os.path.join(sub_dir, new_f)): 289 270 _, ext = os.path.splitext(new_f) 290 if ext.lower() in EXTENSIONS and\ 291 new_f not in IGNORED_FILES: 271 if ext.lower() in EXTENSIONS: 292 272 file_list.append(os.path.join(sub_dir, new_f)) 293 273 … … 296 276 append_file(file_sources, gen_dir) 297 277 278 #Wojtek's hacky way to add doc files while bundling egg 279 #def add_doc_files(directory): 280 # paths = [] 281 # for (path, directories, filenames) in os.walk(directory): 282 # for filename in filenames: 283 # paths.append(os.path.join(path, filename)) 284 # return paths 285 286 #doc_files = add_doc_files('doc') 287 298 288 # SasView 299 289 package_dir["sas.sasview"] = "sasview" 300 package_data['sas.sasview'] = ['images/*', 290 package_data['sas.sasview'] = ['images/*', 301 291 'media/*', 302 292 'test/*.txt', … … 309 299 310 300 required = [ 311 'bumps>=0.7.5. 6', 'periodictable>=1.3.1', 'pyparsing<2.0.0',301 'bumps>=0.7.5.9', 'periodictable>=1.3.1', 'pyparsing<2.0.0', 312 302 313 303 # 'lxml>=2.2.2', … … 323 313 required.extend(['html5lib', 'reportlab']) 324 314 else: 325 required.extend(['pil']) 326 315 # 'pil' is now called 'pillow' 316 required.extend(['pillow']) 317 327 318 # Set up SasView 328 319 setup( -
src/sas/sascalc/calculator/c_extensions/librefl.c
r9e531f2 r4c29e4d 8 8 #include <stdlib.h> 9 9 #if defined(_MSC_VER) 10 # include "winFuncs.h"10 #define NEED_ERF 11 11 #endif 12 13 14 15 #if defined(NEED_ERF) 16 /* erf.c - public domain implementation of error function erf(3m) 17 18 reference - Haruhiko Okumura: C-gengo niyoru saishin algorithm jiten 19 (New Algorithm handbook in C language) (Gijyutsu hyouron 20 sha, Tokyo, 1991) p.227 [in Japanese] */ 21 22 23 #ifdef _WIN32 24 # include <float.h> 25 # if !defined __MINGW32__ || defined __NO_ISOCEXT 26 # ifndef isnan 27 # define isnan(x) _isnan(x) 28 # endif 29 # ifndef isinf 30 # define isinf(x) (!_finite(x) && !_isnan(x)) 31 # endif 32 # ifndef finite 33 # define finite(x) _finite(x) 34 # endif 35 # endif 36 #endif 37 38 static double q_gamma(double, double, double); 39 40 /* Incomplete gamma function 41 1 / Gamma(a) * Int_0^x exp(-t) t^(a-1) dt */ 42 static double p_gamma(double a, double x, double loggamma_a) 43 { 44 int k; 45 double result, term, previous; 46 47 if (x >= 1 + a) return 1 - q_gamma(a, x, loggamma_a); 48 if (x == 0) return 0; 49 result = term = exp(a * log(x) - x - loggamma_a) / a; 50 for (k = 1; k < 1000; k++) { 51 term *= x / (a + k); 52 previous = result; result += term; 53 if (result == previous) return result; 54 } 55 fprintf(stderr, "erf.c:%d:p_gamma() could not converge.", __LINE__); 56 return result; 57 } 58 59 /* Incomplete gamma function 60 1 / Gamma(a) * Int_x^inf exp(-t) t^(a-1) dt */ 61 static double q_gamma(double a, double x, double loggamma_a) 62 { 63 int k; 64 double result, w, temp, previous; 65 double la = 1, lb = 1 + x - a; /* Laguerre polynomial */ 66 67 if (x < 1 + a) return 1 - p_gamma(a, x, loggamma_a); 68 w = exp(a * log(x) - x - loggamma_a); 69 result = w / lb; 70 for (k = 2; k < 1000; k++) { 71 temp = ((k - 1 - a) * (lb - la) + (k + x) * lb) / k; 72 la = lb; lb = temp; 73 w *= (k - 1 - a) / k; 74 temp = w / (la * lb); 75 previous = result; result += temp; 76 if (result == previous) return result; 77 } 78 fprintf(stderr, "erf.c:%d:q_gamma() could not converge.", __LINE__); 79 return result; 80 } 81 82 #define LOG_PI_OVER_2 0.572364942924700087071713675675 /* log_e(PI)/2 */ 83 84 double erf(double x) 85 { 86 if (!finite(x)) { 87 if (isnan(x)) return x; /* erf(NaN) = NaN */ 88 return (x>0 ? 1.0 : -1.0); /* erf(+-inf) = +-1.0 */ 89 } 90 if (x >= 0) return p_gamma(0.5, x * x, LOG_PI_OVER_2); 91 else return - p_gamma(0.5, x * x, LOG_PI_OVER_2); 92 } 93 94 double erfc(double x) 95 { 96 if (!finite(x)) { 97 if (isnan(x)) return x; /* erfc(NaN) = NaN */ 98 return (x>0 ? 0.0 : 2.0); /* erfc(+-inf) = 0.0, 2.0 */ 99 } 100 if (x >= 0) return q_gamma(0.5, x * x, LOG_PI_OVER_2); 101 else return 1 + p_gamma(0.5, x * x, LOG_PI_OVER_2); 102 } 103 #endif // NEED_ERF 12 104 13 105 complex cassign(real, imag) -
src/sas/sascalc/calculator/c_extensions/sld2i.cpp
r9e531f2 rb523c0e 164 164 //Assume that pixel volumes are given in vol_pix in A^3 unit 165 165 // Loop over q-values and multiply apply matrix 166 for( size_t i=0; i<npoints; i++){166 for(int i=0; i<npoints; i++){ 167 167 sumj =0.0; 168 for( size_t j=0; j<n_pix; j++){168 for(int j=0; j<n_pix; j++){ 169 169 //Isotropic: Assumes all slds are real (no magnetic) 170 170 //Also assumes there is no polarization: No dependency on spin … … 183 183 //full calculation 184 184 //pragma omp parallel for 185 for( size_t k=0; k<n_pix; k++){185 for(int k=0; k<n_pix; k++){ 186 186 sld_j = sldn_val[j] * sldn_val[k] * vol_pix[j] * vol_pix[k]; 187 187 qr = (x_val[j]-x_val[k])*(x_val[j]-x_val[k])+ -
src/sas/sascalc/calculator/c_extensions/sld2i.hh
r9e531f2 r4c29e4d 39 39 double s_theta); 40 40 // compute function 41 v irtual void genicomXY(int npoints, double* qx, double* qy, double *I_out);42 v irtual void genicom(int npoints, double* q, double *I_out);41 void genicomXY(int npoints, double* qx, double* qy, double *I_out); 42 void genicom(int npoints, double* q, double *I_out); 43 43 }; 44 44 -
src/sas/sascalc/calculator/c_extensions/sld2i_module.cpp
r9e531f2 rb523c0e 153 153 initsld2i(void) 154 154 { 155 PyObject* m; 156 157 m = Py_InitModule3("sld2i", module_methods, 158 "Sld2i module"); 155 Py_InitModule3("sld2i", module_methods, "Sld2i module"); 159 156 } -
src/sas/sascalc/data_util/calcthread.py
rb699768 r934ce649 119 119 120 120 def __init__(self, completefn=None, updatefn=None, 121 yieldtime=0.01, worktime=0.01): 121 yieldtime=0.01, worktime=0.01, 122 exception_handler=None): 122 123 """Prepare the calculator""" 123 124 self.yieldtime = yieldtime … … 125 126 self.completefn = completefn 126 127 self.updatefn = updatefn 128 self.exception_handler = exception_handler 127 129 self._interrupting = False 128 130 self._running = False … … 199 201 200 202 def update(self, **kwargs): 201 202 203 """Update GUI with the lastest results from the current work unit.""" 203 204 if self.updatefn != None and clock() > self._time_for_update: … … 225 226 """Perform a work unit. The subclass will provide details of 226 227 the arguments.""" 227 raise NotImplemented, "Calculation thread needs compute method" 228 raise NotImplemented("Calculation thread needs compute method") 229 230 def exception(self): 231 """ 232 An exception occurred during computation, so call the exception handler 233 if there is one. If not, then log the exception and continue. 234 """ 235 # If we have an exception handler, let it try to handle the exception. 236 # If it fails fall through to log the failure to handle the exception 237 # (the original exception will be lost). If there is no exception 238 # handler, just log the exception in compute that we are responding to. 239 if self.exception_handler: 240 try: 241 self.exception_handler(*sys.exc_info()) 242 return 243 except Exception: 244 pass 245 import logging 246 logging.error(traceback.format_exc()) 247 #print 'CalcThread exception', 228 248 229 249 def _run(self): … … 250 270 pass 251 271 except: 252 traceback.print_exc() 253 #print 'CalcThread exception', 272 self.exception() 254 273 self._running = False 255 274 -
src/sas/sascalc/dataloader/readers/cansas_reader.py
r45d90b9 raf09f48 221 221 output.append(return_value) 222 222 else: 223 output.append("Invalid XML at: {0}".format(\224 self.find_invalid_xml()) )223 raise RuntimeError, "Invalid XML at: {0}".format(\ 224 self.find_invalid_xml()) 225 225 except: 226 226 # If the file does not match the schema, raise this error -
src/sas/sascalc/pr/c_extensions/Cinvertor.c
rb699768 rb523c0e 115 115 116 116 //self->params.x = data; 117 self->params.npoints = ndata;117 self->params.npoints = (int)ndata; 118 118 return Py_BuildValue("i", self->params.npoints); 119 119 } … … 180 180 181 181 //self->params.y = data; 182 self->params.ny = ndata;182 self->params.ny = (int)ndata; 183 183 return Py_BuildValue("i", self->params.ny); 184 184 } … … 245 245 246 246 //self->params.err = data; 247 self->params.nerr = ndata;247 self->params.nerr = (int)ndata; 248 248 return Py_BuildValue("i", self->params.nerr); 249 249 } … … 523 523 residuals = PyList_New(self->params.npoints); 524 524 525 regterm = reg_term(pars, self->params.d_max, npars, nslice);525 regterm = reg_term(pars, self->params.d_max, (int)npars, nslice); 526 526 527 527 for(i=0; i<self->params.npoints; i++) { 528 diff = self->params.y[i] - iq(pars, self->params.d_max, npars, self->params.x[i]);528 diff = self->params.y[i] - iq(pars, self->params.d_max, (int)npars, self->params.x[i]); 529 529 residual = diff*diff / (self->params.err[i]*self->params.err[i]); 530 530 … … 573 573 residuals = PyList_New(self->params.npoints); 574 574 575 regterm = reg_term(pars, self->params.d_max, npars, nslice);575 regterm = reg_term(pars, self->params.d_max, (int)npars, nslice); 576 576 577 577 578 578 for(i=0; i<self->params.npoints; i++) { 579 diff = self->params.y[i] - pr(pars, self->params.d_max, npars, self->params.x[i]);579 diff = self->params.y[i] - pr(pars, self->params.d_max, (int)npars, self->params.x[i]); 580 580 residual = diff*diff / (self->params.err[i]*self->params.err[i]); 581 581 … … 611 611 OUTVECTOR(data_obj,pars,npars); 612 612 613 iq_value = iq(pars, self->params.d_max, npars, q);613 iq_value = iq(pars, self->params.d_max, (int)npars, q); 614 614 return Py_BuildValue("f", iq_value); 615 615 } … … 636 636 OUTVECTOR(data_obj,pars,npars); 637 637 638 iq_value = iq_smeared(pars, self->params.d_max, npars,638 iq_value = iq_smeared(pars, self->params.d_max, (int)npars, 639 639 self->params.slit_height, self->params.slit_width, 640 640 q, 21); … … 661 661 OUTVECTOR(data_obj,pars,npars); 662 662 663 pr_value = pr(pars, self->params.d_max, npars, r);663 pr_value = pr(pars, self->params.d_max, (int)npars, r); 664 664 return Py_BuildValue("f", pr_value); 665 665 } … … 689 689 690 690 if (err_obj == Py_None) { 691 pr_value = pr(pars, self->params.d_max, npars, r);691 pr_value = pr(pars, self->params.d_max, (int)npars, r); 692 692 pr_err_value = 0.0; 693 693 } else { 694 694 OUTVECTOR(err_obj,pars_err,npars2); 695 pr_err(pars, pars_err, self->params.d_max, npars, r, &pr_value, &pr_err_value);695 pr_err(pars, pars_err, self->params.d_max, (int)npars, r, &pr_value, &pr_err_value); 696 696 } 697 697 return Py_BuildValue("ff", pr_value, pr_err_value); … … 728 728 OUTVECTOR(data_obj,pars,npars); 729 729 730 oscill = reg_term(pars, self->params.d_max, npars, 100);731 norm = int_p2(pars, self->params.d_max, npars, 100);730 oscill = reg_term(pars, self->params.d_max, (int)npars, 100); 731 norm = int_p2(pars, self->params.d_max, (int)npars, 100); 732 732 return Py_BuildValue("f", sqrt(oscill/norm)/acos(-1.0)*self->params.d_max ); 733 733 … … 749 749 OUTVECTOR(data_obj,pars,npars); 750 750 751 count = npeaks(pars, self->params.d_max, npars, 100);751 count = npeaks(pars, self->params.d_max, (int)npars, 100); 752 752 753 753 return Py_BuildValue("i", count ); … … 770 770 OUTVECTOR(data_obj,pars,npars); 771 771 772 fraction = positive_integral(pars, self->params.d_max, npars, 100);772 fraction = positive_integral(pars, self->params.d_max, (int)npars, 100); 773 773 774 774 return Py_BuildValue("f", fraction ); … … 795 795 OUTVECTOR(err_obj,pars_err,npars2); 796 796 797 fraction = positive_errors(pars, pars_err, self->params.d_max, npars, 51);797 fraction = positive_errors(pars, pars_err, self->params.d_max, (int)npars, 51); 798 798 799 799 return Py_BuildValue("f", fraction ); … … 815 815 OUTVECTOR(data_obj,pars,npars); 816 816 817 value = rg(pars, self->params.d_max, npars, 101);817 value = rg(pars, self->params.d_max, (int)npars, 101); 818 818 819 819 return Py_BuildValue("f", value ); … … 835 835 OUTVECTOR(data_obj,pars,npars); 836 836 837 value = 4.0*acos(-1.0)*int_pr(pars, self->params.d_max, npars, 101);837 value = 4.0*acos(-1.0)*int_pr(pars, self->params.d_max, (int)npars, 101); 838 838 839 839 return Py_BuildValue("f", value ); -
src/sas/sasgui/guiframe/local_perspectives/data_loader/data_loader.py
rd85c194 rfaa3ae7 155 155 """ 156 156 data_error = False 157 for error_data in item.errors: 157 if hasattr(item, 'errors'): 158 for error_data in item.errors: 159 data_error = True 160 message += "\tError: {0}\n".format(error_data) 161 else: 162 logging.error("Loader returned an invalid object:\n %s" % str(item)) 158 163 data_error = True 159 message += "\tError: {0}\n".format(error_data)164 160 165 data = self.parent.create_gui_data(item, p_file) 161 166 output[data.id] = data … … 203 208 error_message) 204 209 except: 210 logging.error(sys.exc_value) 205 211 any_error = True 206 212 if any_error or error_message != "": -
src/sas/sasgui/perspectives/calculator/model_editor.py
rcb4ef58 rbb841ef 30 30 from wx.py.editwindow import EditWindow 31 31 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 32 from .pyconsole import show_model_output, check_model 32 33 33 34 … … 45 46 PANEL_WIDTH = 500 46 47 _BOX_WIDTH = 55 47 48 49 def _compile_file(path):50 """51 Compile the file in the path52 """53 try:54 import py_compile55 py_compile.compile(file=path, doraise=True)56 return ''57 except:58 _, value, _ = sys.exc_info()59 return value60 48 61 49 def _delete_file(path): … … 384 372 name2 = label[1] 385 373 self.write_string(fname, name1, name2) 386 self.compile_file(fname) 387 self.parent.update_custom_combo() 374 success = show_model_output(self, fname) 375 if success: 376 self.parent.update_custom_combo() 388 377 msg = self._notes 389 378 info = 'Info' … … 618 607 """ 619 608 path = self.fname 620 _compile_file(path)609 show_model_output(self, path) 621 610 622 611 def delete_file(self, path): … … 954 943 info = 'Info' 955 944 msg = '' 945 result, check_err = '', '' 956 946 # Sort out the errors if occur 957 947 # First check for valid python name then if the name already exists … … 969 959 self.write_file(self.fname, name, description, param_str, 970 960 pd_param_str, func_str) 961 try: 962 result, msg = check_model(self.fname), None 963 except Exception: 964 import traceback 965 result, msg = None, "error building model" 966 check_err = "\n"+traceback.format_exc(limit=2) 967 971 968 # Modified compiling test, as it will fail for sasmodels.sasview_model class 972 969 # Should add a test to check that the class is correctly built … … 1031 1028 color = 'red' 1032 1029 else: 1033 msg = "Successful! " 1030 self._notes = result 1031 msg = "Successful! Please look for %s in Customized Models."%name 1034 1032 msg += " " + self._notes 1035 msg += " Please look for it in the Customized Models."1036 1033 info = 'Info' 1037 1034 color = 'blue' … … 1041 1038 if self.base != None: 1042 1039 from sas.sasgui.guiframe.events import StatusEvent 1043 wx.PostEvent(self.base.parent, StatusEvent(status=msg, info=info)) 1040 wx.PostEvent(self.base.parent, 1041 StatusEvent(status=msg+check_err, info=info)) 1044 1042 self.warning = msg 1045 1043 … … 1333 1331 import copy 1334 1332 1335 import nu ympy1333 import numpy 1336 1334 1337 1335 from sas.sascalc.fit.pluginmodel import Model1DPlugin -
src/sas/sasgui/perspectives/calculator/pyconsole.py
rd85c194 r26d6e045 4 4 import sys 5 5 import os 6 7 import numpy as np 8 6 9 import wx 7 import wx.lib.dialogs 10 from wx.lib.dialogs import ScrolledMessageDialog 8 11 import wx.py.editor as editor 9 import wx.py.frame as frame10 import py_compile11 12 12 13 if sys.platform.count("win32") > 0: … … 18 19 PANEL_HEIGHT = 730 19 20 FONT_VARIANT = 1 20 ID_C OMPILE= wx.NewId()21 ID_CHECK_MODEL = wx.NewId() 21 22 ID_RUN = wx.NewId() 22 23 23 def c ompile_file(path):24 def check_model(path): 24 25 """ 25 C ompile a python file26 Check that the model on the path can run. 26 27 """ 28 # try running the model 29 from sasmodels.core import load_model, call_kernel 30 model = load_model(path) 31 32 q = np.array([0.01, 0.1]) 33 kernel = model.make_kernel([q]) 34 Iq = call_kernel(kernel, {}) 35 36 qx, qy = np.array([0.01, 0.01]), np.array([0.1, 0.1]) 37 kernel = model.make_kernel([qx, qy]) 38 Iqxy = call_kernel(kernel, {}) 39 40 result = """ 41 Iq(%s) = %s 42 Iqxy(%s, %s) = %s 43 """%(q, Iq, qx, qy, Iqxy) 44 45 return result 46 47 def show_model_output(parent, fname): 48 # Make sure we have a python file; not sure why we care though... 49 if not (fname and os.path.exists(fname) and fname.endswith('.py')): 50 mssg = "\n This is not a python file." 51 wx.MessageBox(str(mssg), 'Error', style=wx.ICON_ERROR) 52 return False 53 27 54 try: 28 import py_compile 29 py_compile.compile(file=path, doraise=True) 30 except: 31 type, value, traceback = sys.exc_info() 32 return value 33 return None 55 result, errmsg = check_model(fname), None 56 except Exception: 57 import traceback 58 result, errmsg = None, traceback.format_exc(limit=2) 59 60 parts = ["Running model '%s'..." % os.path.basename(fname)] 61 if errmsg is not None: 62 parts.extend(["", "Error occurred:", errmsg, ""]) 63 title, icon = "Error", wx.ICON_ERROR 64 else: 65 parts.extend(["", "Success:", result, ""]) 66 title, icon = "Info", wx.ICON_INFORMATION 67 text = "\n".join(parts) 68 dlg = ScrolledMessageDialog(parent, text, title, size=((550, 250))) 69 fnt = wx.Font(10, wx.TELETYPE, wx.NORMAL, wx.NORMAL) 70 dlg.GetChildren()[0].SetFont(fnt) 71 dlg.GetChildren()[0].SetInsertionPoint(0) 72 dlg.ShowModal() 73 dlg.Destroy() 74 return errmsg is None 34 75 35 76 class PyConsole(editor.EditorNotebookFrame): … … 65 106 self.Bind(wx.EVT_MENU, self.OnSaveFile, id=wx.ID_SAVE) 66 107 self.Bind(wx.EVT_MENU, self.OnSaveAsFile, id=wx.ID_SAVEAS) 67 self.Bind(wx.EVT_MENU, self.OnC ompile, id=ID_COMPILE)108 self.Bind(wx.EVT_MENU, self.OnCheckModel, id=ID_CHECK_MODEL) 68 109 self.Bind(wx.EVT_MENU, self.OnRun, id=ID_RUN) 69 self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateCompileMenu, id=ID_C OMPILE)110 self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateCompileMenu, id=ID_CHECK_MODEL) 70 111 self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateCompileMenu, id=ID_RUN) 71 112 self.Bind(wx.EVT_CLOSE, self.on_close) … … 81 122 """ 82 123 self.compileMenu = wx.Menu() 83 self.compileMenu.Append(ID_C OMPILE, 'Compile',84 ' Compile the file')124 self.compileMenu.Append(ID_CHECK_MODEL, 'Check model', 125 'Loading and run the model') 85 126 self.compileMenu.AppendSeparator() 86 127 self.compileMenu.Append(ID_RUN, 'Run in Shell', … … 192 233 Run 193 234 """ 194 if self._check_changed():235 if not self._check_saved(): 195 236 return True 196 237 if self.buffer and self.buffer.doc.filepath: … … 207 248 icon = wx.ICON_ERROR 208 249 wx.MessageBox(str(mssg), title, style=icon) 209 return 0210 211 def OnC ompile(self, event):250 return False 251 252 def OnCheckModel(self, event): 212 253 """ 213 254 Compile 214 255 """ 215 if self._check_changed():256 if not self._check_saved(): 216 257 return True 217 run_out = self.OnRun(None) 218 if self._get_err_msg(run_out): 219 if self._manager != None and self.panel != None: 220 self._manager.set_edit_menu_helper(self.parent) 221 # Update custom model list in fitpage combobox 222 wx.CallAfter(self._manager.update_custom_combo) 223 224 def _check_changed(self): 258 fname = self.editor.getStatus()[0] 259 success = show_model_output(self, fname) 260 261 # Update custom model list in fitpage combobox 262 if success and self._manager != None and self.panel != None: 263 self._manager.set_edit_menu_helper(self.parent) 264 wx.CallAfter(self._manager.update_custom_combo) 265 266 def _check_saved(self): 225 267 """ 226 268 If content was changed, suggest to save it first … … 228 270 if self.bufferHasChanged() and self.buffer.doc.filepath: 229 271 cancel = self.bufferSuggestSave() 230 if cancel: 231 return cancel 232 233 def _get_err_msg(self, text=''): 234 """ 235 Get err_msg 236 """ 237 name = None 238 mssg = "\n This is not a python file." 239 title = 'Error' 240 icon = wx.ICON_ERROR 241 try: 242 fname = self.editor.getStatus()[0] 243 name = os.path.basename(fname) 244 if name.split('.')[-1] != 'py': 245 wx.MessageBox(str(mssg), title, style=icon) 246 return False 247 msg = compile_file(fname) 248 except: 249 msg = None 250 if name == None: 251 wx.MessageBox(str(mssg), title, style=icon) 252 return False 253 mssg = "Compiling '%s'...\n" % name 254 if msg != None: 255 mssg += "Error occurred:\n" 256 mssg += str(msg) + "\n\n" 257 if text: 258 mssg += "Run-Test results:\n" 259 mssg += str(text) 260 title = 'Warning' 261 icon = wx.ICON_WARNING 262 else: 263 mssg += "Successful.\n\n" 264 if text: 265 if text.count('Failed') or text.count('Error:') > 0: 266 mssg += "But Simple Test FAILED: Please check your code.\n" 267 mssg += "Run-Test results:\n" 268 mssg += str(text) 269 title = 'Info' 270 icon = wx.ICON_INFORMATION 271 dlg = wx.lib.dialogs.ScrolledMessageDialog(self, mssg, title, 272 size=((550, 250))) 273 fnt = wx.Font(10, wx.TELETYPE, wx.NORMAL, wx.NORMAL) 274 dlg.GetChildren()[0].SetFont(fnt) 275 dlg.GetChildren()[0].SetInsertionPoint(0) 276 dlg.ShowModal() 277 dlg.Destroy() 272 return not cancel 278 273 return True 279 274 … … 286 281 event.Enable(True) 287 282 try: 288 if id == ID_C OMPILEor id == ID_RUN:283 if id == ID_CHECK_MODEL or id == ID_RUN: 289 284 menu_on = False 290 285 if self.buffer and self.buffer.doc.filepath: -
src/sas/sasgui/perspectives/fitting/__init__.py
r9e531f2 ra7c4ad2 39 39 data_files = [] 40 40 path = os.path.dirname(__file__) 41 #p_path = os.path.join(path, 'plugin_models')42 #for f in findall(p_path):43 #data_files.append(('plugin_models', [f]))41 p_path = os.path.join(path, 'plugin_models') 42 for f in findall(p_path): 43 data_files.append(('plugin_models', [f])) 44 44 # path = get_data_path(media="media") 45 45 for f in findall(path): -
src/sas/sasgui/perspectives/fitting/fitpage.py
rcb4ef58 r934ce649 1330 1330 qmin=float(self.qmin_x), 1331 1331 qmax=float(self.qmax_x), 1332 enable_smearer=enable_smearer, 1333 draw=True) 1332 enable_smearer=enable_smearer) 1334 1333 if flag: 1335 1334 #self.compute_chisqr(smearer= temp_smearer) … … 2606 2605 qmin=float(self.qmin_x), 2607 2606 qmax=float(self.qmax_x), 2608 enable_smearer=enable_smearer, 2609 draw=True) 2607 enable_smearer=enable_smearer) 2610 2608 2611 2609 self.state.enable_smearer = self.enable_smearer.GetValue() -
src/sas/sasgui/perspectives/fitting/fitpanel.py
rf60251f r05228b0 17 17 import models 18 18 _BOX_WIDTH = 80 19 20 19 21 20 class FitPanel(nb, PanelBase): … … 154 153 """ 155 154 """ 156 from bumps.options import FIT_CONFIG157 current = FIT_CONFIG.selected_name158 self.parent.SetTitle(self.window_name + " - Active Fitting Optimizer: " + current)159 155 pos = self.GetSelection() 160 156 if pos != -1: -
src/sas/sasgui/perspectives/fitting/fitting.py
r86b049b r934ce649 19 19 import time 20 20 from copy import deepcopy 21 import models21 import traceback 22 22 23 23 from sas.sascalc.dataloader.loader import Loader … … 46 46 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 47 47 48 from . import models 49 48 50 MAX_NBR_DATA = 4 49 51 … … 56 58 ON_MAC = True 57 59 58 60 import bumps.options 61 from bumps.gui.fit_dialog import show_fit_config 62 try: 63 from bumps.gui.fit_dialog import EVT_FITTER_CHANGED 64 except ImportError: 65 # CRUFT: bumps 0.7.5.8 and below 66 EVT_FITTER_CHANGED = None # type: wx.PyCommandEvent 59 67 60 68 class Plugin(PluginBase): … … 254 262 msg += "and try it again." 255 263 wx.MessageBox(msg, 'Info') 256 # wx.PostEvent(self.parent, StatusEvent(status=msg, type='stop',257 # info='warning'))264 #evt = StatusEvent(status=msg, type='stop', info='warning') 265 #wx.PostEvent(self.parent, evt) 258 266 else: 259 267 self.delete_menu.Delete(event_id) … … 262 270 self.edit_menu.DeleteItem(item) 263 271 msg = "The custom model, %s, has been deleted." % label 264 wx.PostEvent(self.parent, StatusEvent(status=msg,265 type='stop', info='info'))272 evt = StatusEvent(status=msg, type='stop', info='info') 273 wx.PostEvent(self.parent, evt) 266 274 break 267 275 except: … … 501 509 self.parent.Bind(EVT_SLICER_PANEL, self._on_slicer_event) 502 510 self.parent.Bind(EVT_SLICER_PARS_UPDATE, self._onEVT_SLICER_PANEL) 511 512 # CRUFT: EVT_FITTER_CHANGED is not None for bumps 0.7.5.9 and above 513 if EVT_FITTER_CHANGED is not None: 514 self.parent.Bind(EVT_FITTER_CHANGED, self.on_fitter_changed) 515 self._set_fitter_label(bumps.options.FIT_CONFIG) 516 503 517 #self.parent._mgr.Bind(wx.aui.EVT_AUI_PANE_CLOSE,self._onclearslicer) 504 518 #Create reader when fitting panel are created … … 567 581 except: 568 582 msg = "Fitting: cannot deal with the theory received" 583 evt = StatusEvent(status=msg, info="error") 569 584 logging.error("set_theory " + msg + "\n" + str(sys.exc_value)) 570 wx.PostEvent(self.parent, 571 StatusEvent(status=msg, info="error")) 585 wx.PostEvent(self.parent, evt) 572 586 573 587 def set_state(self, state=None, datainfo=None, format=None): … … 763 777 Open the bumps options panel. 764 778 """ 765 try: 766 from bumps.gui.fit_dialog import show_fit_config 767 show_fit_config(self.parent, help=self.on_help) 768 except ImportError: 769 # CRUFT: Bumps 0.7.5.6 and earlier do not have the help button 770 from bumps.gui.fit_dialog import OpenFitOptions 771 OpenFitOptions() 779 show_fit_config(self.parent, help=self.on_help) 780 781 def on_fitter_changed(self, event): 782 self._set_fitter_label(event.config) 783 784 def _set_fitter_label(self, config): 785 self.fit_panel.parent.SetTitle(self.fit_panel.window_name 786 + " - Active Fitting Optimizer: " 787 + config.selected_name) 772 788 773 789 def on_help(self, algorithm_id): … … 954 970 if not page.param_toFit: 955 971 msg = "No fitting parameters for %s" % page.window_caption 956 wx.PostEvent(page.parent.parent, 957 StatusEvent(status=msg, info="error", 958 type="stop")) 972 evt = StatusEvent(status=msg, info="error", type="stop") 973 wx.PostEvent(page.parent.parent, evt) 959 974 return False 960 975 if not page._update_paramv_on_fit(): … … 962 977 msg += " invalid in %s" % \ 963 978 page.window_caption 964 wx.PostEvent(page.parent.parent, 965 StatusEvent(status=msg, info="error", 966 type="stop")) 979 evt = StatusEvent(status=msg, info="error", type="stop") 980 wx.PostEvent(page.parent.parent, evt) 967 981 return False 968 982 … … 985 999 except KeyboardInterrupt: 986 1000 msg = "Fitting terminated" 987 wx.PostEvent(self.parent, StatusEvent(status=msg, info="info",988 type="stop"))1001 evt = StatusEvent(status=msg, info="info", type="stop") 1002 wx.PostEvent(self.parent, evt) 989 1003 return True 990 1004 except: 991 1005 raise 992 1006 msg = "Fitting error: %s" % str(sys.exc_value) 993 wx.PostEvent(self.parent, StatusEvent(status=msg, info="error",994 type="stop"))1007 evt = StatusEvent(status=msg, info="error", type="stop") 1008 wx.PostEvent(self.parent, evt) 995 1009 return False 996 1010 ## If a thread is already started, stop it … … 1087 1101 # add data associated to the page created 1088 1102 if page != None: 1089 wx.PostEvent(self.parent, StatusEvent(status="Page Created",1090 info="info"))1103 evt = StatusEvent(status="Page Created", info="info") 1104 wx.PostEvent(self.parent, evt) 1091 1105 else: 1092 1106 msg = "Page was already Created" 1093 wx.PostEvent(self.parent, StatusEvent(status=msg,1094 info="warning"))1107 evt = StatusEvent(status=msg, info="warning") 1108 wx.PostEvent(self.parent, evt) 1095 1109 except: 1096 1110 msg = "Creating Fit page: %s" % sys.exc_value … … 1254 1268 msg = "Fit completed on %s \n" % str_time 1255 1269 msg += "Duration time: %s s.\n" % str(elapsed) 1256 wx.PostEvent(self.parent, StatusEvent(status=msg, info="info",1257 type="stop"))1270 evt = StatusEvent(status=msg, info="info", type="stop") 1271 wx.PostEvent(self.parent, evt) 1258 1272 1259 1273 if batch_outputs is None: … … 1405 1419 batch_inputs=batch_inputs) 1406 1420 1407 wx.PostEvent(self.parent, StatusEvent(status=msg, error="info",1408 type="stop"))1421 evt = StatusEvent(status=msg, error="info", type="stop") 1422 wx.PostEvent(self.parent, evt) 1409 1423 # Remove parameters that are not shown 1410 1424 cpage = self.fit_panel.get_page_by_id(uid) … … 1485 1499 msg = "Fit completed on %s \n" % str_time 1486 1500 msg += "Duration time: %s s.\n" % str(elapsed) 1487 wx.PostEvent(self.parent, StatusEvent(status=msg, info="info",1488 type="stop"))1501 evt = StatusEvent(status=msg, info="info", type="stop") 1502 wx.PostEvent(self.parent, evt) 1489 1503 wx.PostEvent(self.result_panel, PlotResultEvent(result=result)) 1490 1504 wx.CallAfter(self._update_fit_button, page_id) … … 1510 1524 not numpy.all(numpy.isfinite(res.pvec)): 1511 1525 msg = "Fitting did not converge!!!" 1512 wx.PostEvent(self.parent, 1513 StatusEvent(status=msg, 1514 info="warning", 1515 type="stop")) 1526 evt = StatusEvent(status=msg, info="warning", type="stop") 1527 wx.PostEvent(self.parent, evt) 1516 1528 wx.CallAfter(self._update_fit_button, page_id) 1517 1529 else: … … 1537 1549 except KeyboardInterrupt: 1538 1550 msg = "Singular point: Fitting Stoped." 1539 wx.PostEvent(self.parent, StatusEvent(status=msg, 1540 info="info", 1541 type="stop")) 1551 evt = StatusEvent(status=msg, info="info", type="stop") 1552 wx.PostEvent(self.parent, evt) 1542 1553 except: 1543 1554 msg = "Singular point: Fitting Error occurred." 1544 wx.PostEvent(self.parent, StatusEvent(status=msg, 1545 info="error", 1546 type="stop")) 1555 evt = StatusEvent(status=msg, info="error", type="stop") 1556 wx.PostEvent(self.parent, evt) 1547 1557 1548 1558 except: … … 1550 1560 % sys.exc_value) 1551 1561 #import traceback; msg = "\n".join((traceback.format_exc(), msg)) 1552 wx.PostEvent(self.parent, StatusEvent(status=msg, info="warning",1553 type="stop"))1562 evt = StatusEvent(status=msg, info="warning", type="stop") 1563 wx.PostEvent(self.parent, evt) 1554 1564 1555 1565 def _update_fit_button(self, page_id): … … 1588 1598 ## post a message to status bar 1589 1599 msg = "Set Chain Fitting: %s" % str(not self.batch_reset_flag) 1590 wx.PostEvent(self.parent, 1591 StatusEvent(status=msg)) 1600 wx.PostEvent(self.parent, StatusEvent(status=msg)) 1592 1601 1593 1602 … … 1735 1744 raise 1736 1745 1746 def _calc_exception(self, etype, value, tb): 1747 """ 1748 Handle exception from calculator by posting it as an error. 1749 """ 1750 logging.error("".join(traceback.format_exception(etype, value, tb))) 1751 msg = traceback.format_exception(etype, value, tb, limit=1) 1752 evt = StatusEvent(status="".join(msg), type="stop", info="error") 1753 wx.PostEvent(self.parent, evt) 1754 1737 1755 def _update2D(self, output, time=None): 1738 1756 """ 1739 1757 Update the output of plotting model 1740 1758 """ 1741 wx.PostEvent(self.parent, StatusEvent(status="Plot \ 1742 #updating ... ", type="update")) 1743 #self.ready_fit() 1759 msg = "Plot updating ... " 1760 wx.PostEvent(self.parent, StatusEvent(msg, type="update")) 1744 1761 1745 1762 def _complete2D(self, image, data, model, page_id, elapsed, index, qmin, … … 1847 1864 time.sleep(0.1) 1848 1865 self.calc_2D = Calc2D(model=model, 1849 data=data, 1850 page_id=page_id, 1851 smearer=smearer, 1852 qmin=qmin, 1853 qmax=qmax, 1854 weight=weight, 1855 fid=fid, 1856 toggle_mode_on=toggle_mode_on, 1857 state=state, 1858 completefn=self._complete2D, 1859 update_chisqr=update_chisqr, source=source) 1866 data=data, 1867 page_id=page_id, 1868 smearer=smearer, 1869 qmin=qmin, 1870 qmax=qmax, 1871 weight=weight, 1872 fid=fid, 1873 toggle_mode_on=toggle_mode_on, 1874 state=state, 1875 completefn=self._complete2D, 1876 update_chisqr=update_chisqr, 1877 exception_handler=self._calc_exception, 1878 source=source) 1860 1879 self.calc_2D.queue() 1861 1880 except: … … 1912 1931 #updatefn = self._update1D, 1913 1932 update_chisqr=update_chisqr, 1933 exception_handler=self._calc_exception, 1914 1934 source=source) 1915 1935 self.calc_1D.queue() -
src/sas/sasgui/perspectives/fitting/model_thread.py
rd85c194 r934ce649 25 25 source='model', 26 26 yieldtime=0.04, 27 worktime=0.04 27 worktime=0.04, 28 exception_handler=None, 28 29 ): 29 CalcThread.__init__(self, completefn, updatefn, yieldtime, worktime) 30 CalcThread.__init__(self, completefn, updatefn, yieldtime, worktime, 31 exception_handler=exception_handler) 30 32 self.qmin = qmin 31 33 self.qmax = qmax … … 133 135 updatefn=None, 134 136 yieldtime=0.01, 135 worktime=0.01 137 worktime=0.01, 138 exception_handler=None, 136 139 ): 137 140 """ 138 141 """ 139 CalcThread.__init__(self, completefn, 140 updatefn, 141 yieldtime, 142 worktime) 142 CalcThread.__init__(self, completefn, updatefn, yieldtime, worktime, 143 exception_handler=exception_handler) 143 144 self.fid = fid 144 145 self.data = data -
src/sas/sasgui/perspectives/invariant/media/invariant_help.rst
r7805458 r70305bd2 19 19 .. image:: image001.gif 20 20 21 where *g = Q* for pinhole geometry (SAS) and *g = Qv*(the slit height) for21 where *g = q* for pinhole geometry (SAS) and *g = q*\ :sub:`v` (the slit height) for 22 22 slit geometry (USAS). 23 23 -
src/sas/sasgui/plottools/plottables.py
rd7bb526 rcd54205 704 704 else: 705 705 self.dy = None 706 tempx = []707 tempy = []708 706 if not has_err_x: 709 707 dx = numpy.zeros(len(x)) … … 724 722 if has_err_y: 725 723 self.dy.append(tempdy) 726 except: 727 tempx = x[i] 728 tempy = y[i] 729 tempdy = dy[i] 724 except Exception: 725 pass 730 726 # Sanity check 731 727 if not len(self.x) == len(self.y): … … 733 729 msg += "and y are not of the same length" 734 730 raise ValueError, msg 735 if has_err_x and not (len(self.x) andlen(self.dx)):731 if has_err_x and not (len(self.x) == len(self.dx)): 736 732 msg = "Plottable.View: transformed x and dx" 737 733 msg += " are not of the same length" 738 734 raise ValueError, msg 739 if has_err_y and not (len(self.y) andlen(self.dy)):735 if has_err_y and not (len(self.y) == len(self.dy)): 740 736 msg = "Plottable.View: transformed y" 741 737 msg += " and dy are not of the same length" -
src/sas/sasgui/perspectives/fitting/models.py
rcb4ef58 r6afc14b 147 147 try: 148 148 import compileall 149 compileall.compile_dir(dir=dir, ddir=dir, force= 1,149 compileall.compile_dir(dir=dir, ddir=dir, force=0, 150 150 quiet=report_problem) 151 151 except:
Note: See TracChangeset
for help on using the changeset viewer.