Changeset b768e92 in sasview


Ignore:
Timestamp:
Jun 2, 2016 8:14:35 AM (8 years ago)
Author:
Gonzalez, Miguel <gonzalez@…>
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.
Message:

Merge branch 'master' of https://github.com/SasView/sasview

Files:
5 added
8 deleted
33 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

    r02098e3 re04f87b  
    5151/test/sasdataloader/test/test_log.txt 
    5252 
     53# autogenerated scripts 
     54/sasview/installer.iss 
     55 
  • build_tools/conda/bumps/meta.yaml

    rb75079b r243fbc0  
    11package: 
    22  name: bumps 
    3   version: !!str 0.7.5.4 
     3  version: !!str 0.7.5.9 
    44 
    55source: 
    6   fn: bumps-0.7.5.4.tar.gz 
    7   url: https://pypi.python.org/packages/source/b/bumps/bumps-0.7.5.4.tar.gz 
     6  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 
    88  md5: a47c035fbb18afa5ca53067506a5ff1c 
    99#  patches: 
  • build_tools/jenkins_linux_build.sh

    r9d5427f rbf3ca1e  
    1 #! /bin/sh 
     1export PATH=$PATH:/usr/local/bin/ 
    22 
    3 # try to find reasonable settings, if not provided in the environment 
    43PYTHON=${PYTHON:-`which python`} 
    54EASY_INSTALL=${EASY_INSTALL:-`which easy_install`} 
    65PYLINT=${PYLINT:-`which pylint`} 
    7 BUILD_TOOLS_DIR=`dirname $0` 
    8 WORKSPACE=${WORKSPACE:-`readlink -f $BUILD_TOOLS_DIR/..`} 
    9 # WORKSPACE top level of source 
     6 
     7export PYTHONPATH=$PYTHONPATH:$WORKSPACE/sasview/utils 
     8export PYTHONPATH=$PYTHONPATH:$WORKSPACE/sasview/sasview-install 
     9 
    1010 
    1111cd $WORKSPACE 
     12 
     13# SASMODLES 
     14cd $WORKSPACE 
     15cd sasmodels 
     16 
     17rm -rf build 
     18rm -rf dist 
     19 
     20$PYTHON setup.py clean 
     21$PYTHON setup.py build 
     22 
     23 
     24# SASMODLES - BUILD DOCS 
     25cd  doc 
     26make html 
     27 
     28cd $WORKSPACE 
     29cd sasmodels 
     30$PYTHON setup.py bdist_egg 
     31 
     32 
     33# SASVIEW 
     34cd $WORKSPACE 
     35cd sasview 
    1236rm -rf sasview-install 
    13 mkdir sasview-install 
     37mkdir  sasview-install 
     38rm -rf utils 
     39mkdir  utils 
    1440rm -rf dist 
    1541rm -rf build 
    1642 
    17 "$EASY_INSTALL" -d "$WORKSPACE/utils" bumps==0.7.5.6 
    18 "$EASY_INSTALL" -d "$WORKSPACE/utils" periodictable==1.3.0 
    1943 
    20 export PYTHONPATH=$WORKSPACE/sasview-install:$WORKSPACE/utils:$PYTHONPATH 
     44# INSTALL SASMODELS 
     45cd $WORKSPACE 
     46cd sasmodels 
     47cd dist 
     48$EASY_INSTALL -d $WORKSPACE/sasview/utils sasmodels*.egg 
    2149 
    22 $PYTHON check_packages.py 
    23 $PYTHON setup.py bdist_egg 
    2450 
    25 cd $WORKSPACE/dist 
    26 # ln -s sasview*.egg sasview.egg || true 
    27 $EASY_INSTALL -N -d ../sasview-install sasview*.egg 
     51# BUILD SASVIEW 
     52cd $WORKSPACE 
     53cd sasview 
     54$PYTHON setup.py clean 
     55$PYTHON setup.py build docs bdist_egg 
    2856 
     57 
     58# INSTALL SASVIEW 
     59cd $WORKSPACE 
     60cd sasview 
     61cd dist 
     62$EASY_INSTALL -d $WORKSPACE/sasview/sasview-install sasview*.egg 
     63 
     64 
     65# TEST 
     66cd $WORKSPACE 
     67cd sasview 
     68cd 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  
    11export PATH=$PATH:/usr/local/bin/ 
    2  
    32 
    43PYTHON=${PYTHON:-`which python`} 
     
    87export PYTHONPATH=$PYTHONPATH:$WORKSPACE/sasview/utils 
    98export PYTHONPATH=$PYTHONPATH:$WORKSPACE/sasview/sasview-install 
     9export PYTHONPATH=$PYTHONPATH:/Library/Python/2.7/site-packages 
     10 
    1011export LC_ALL=en_US.UTF-8 
    1112export LANG=en_US.UTF-8 
     
    5657cd sasview 
    5758$PYTHON setup.py clean 
    58 $PYTHON setup.py build 
    59 $PYTHON setup.py docs 
     59$PYTHON setup.py build docs bdist_egg 
    6060 
    6161 
    62 # SASVIEW BUILD_egg with new docs 
     62# INSTALL SASVIEW 
    6363cd $WORKSPACE 
    6464cd sasview 
    65 python setup.py bdist_egg 
    6665cd dist 
    6766$EASY_INSTALL -d $WORKSPACE/sasview/sasview-install sasview*.egg 
     67 
    6868 
    6969# TEST 
     
    7878$PYLINT --rcfile "build_tools/pylint.rc" -f parseable sasview-install/sasview*.egg/sas sasview | tee  test/sasview.txt 
    7979 
    80  
    8180# BUILD APP 
    8281cd $WORKSPACE 
    8382cd sasview/sasview 
    84 python setup_mac.py py2app 
     83$PYTHON setup_mac.py py2app 
    8584 
  • build_tools/jenkins_rhel6_build.sh

    r9d5427f r243fbc0  
    2828"$EASY_INSTALL" -d "$WORKSPACE/utils" lxml 
    2929"$EASY_INSTALL" -d "$WORKSPACE/utils" pyparsing==1.5.5 
    30 "$EASY_INSTALL" -d "$WORKSPACE/utils" bumps==0.7.5.6 
     30"$EASY_INSTALL" -d "$WORKSPACE/utils" bumps==0.7.5.9 
    3131"$EASY_INSTALL" -d "$WORKSPACE/utils" periodictable==1.3.0 
    3232python deps.py 
  • build_tools/jenkins_win_build.bat

    r261e075 rb4994b7  
     1set PYTHON=c:\python27\python 
     2set EASY_INSTALL=c:\python27\scripts\easy_install.exe 
     3set PATH=c:\python27;c:\mingw\bin;%PATH% 
     4set PYLINT= C:\Python27\Scripts\pylint 
     5set INNO="C:\Program Files (x86)\Inno Setup 5\ISCC.exe" 
    16 
    2 set PYTHON=C:\Python27\python 
    3 set EASY_INSTALL=c:\python27\scripts\easy_install.exe 
    4 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 
     7set PYTHONPATH=%PYTHONPATH%;%WORKSPACE%\sasview\utils 
     8set PYTHONPATH=%PYTHONPATH%;%WORKSPACE%\sasview\sasview-install 
     9 
     10echo %PYTHONPATH% 
     11echo %WORKSPACE% 
    712 
    813 
    9 cd %WORKSPACE%\sasview 
    10 %PYTHON% check_packages.py 
     14:: MAKE DIR FOR EGGS ################################################## 
     15cd %WORKSPACE% 
     16cd sasview 
     17MD sasview-install 
     18MD utils 
    1119 
    1220 
    13 cd %WORKSPACE%\sasview 
    14 python setup.py build -cmingw32 
     21:: SASMODELS build #################################################### 
     22cd %WORKSPACE% 
     23cd sasmodels 
     24%PYTHON% setup.py build 
    1525 
    1626 
    17 cd %WORKSPACE%\sasview 
    18 python setup.py docs 
     27 
     28:: SASMODELS doc ###################################################### 
     29cd doc 
     30make html 
    1931 
    2032 
    21 cd %WORKSPACE%\sasview 
    22 python setup.py bdist_egg --skip-build 
     33:: SASMODELS build egg ################################################ 
     34cd %WORKSPACE% 
     35cd sasmodels 
     36%PYTHON% setup.py bdist_egg 
    2337 
    2438 
     39:: SASMODELS install egg ############################################## 
     40cd %WORKSPACE% 
     41cd sasmodels 
     42cd dist 
     43echo 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 
     51cd %WORKSPACE% 
     52cd sasview 
     53%PYTHON% setup.py build docs bdist_egg 
     54 
     55 
     56:: SASVIEW utest ###################################################### 
    2557cd %WORKSPACE%\sasview\test 
    2658%PYTHON% utest_sasview.py 
    2759 
    2860 
    29 cd %WORKSPACE%\sasview 
    30 mkdir sasview-install 
    31 set PYTHONPATH=%WORKSPACE%\sasview\sasview-install;%PYTHONPATH% 
     61:: SASVIEW INSTALL EGG ################################################ 
     62cd %WORKSPACE% 
     63cd sasview 
     64cd dist 
     65echo F | xcopy sasview-*.egg sasview.egg /Y 
     66%EASY_INSTALL% -d %WORKSPACE%\sasview\sasview-install sasview.egg 
    3267 
    3368 
    34 cd %WORKSPACE%\sasview 
    35 cd dist 
    36 %EASY_INSTALL% -d ..\sasview-install sasview-3.1.2-py2.7-win32.egg 
     69:: TINYCC build #################################################### 
     70cd %WORKSPACE% 
     71cd tinycc 
     72%PYTHON% setup.py build 
     73xcopy /S build\lib\* %WORKSPACE%\sasview\utils\ 
    3774 
    38  
    39 cd %WORKSPACE%\sasview\sasview 
    40 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 ################################################## 
     76cd %WORKSPACE% 
     77cd sasview 
     78cd sasview 
     79%PYTHON% setup_exe.py py2exe 
     80%PYTHON% installer_generator.py 
     81%INNO% installer.iss 
    4582cd Output 
    4683xcopy setupSasView.exe %WORKSPACE%\sasview\dist 
    4784 
     85:: SASVIEW PYLINT ##################################################### 
    4886cd %WORKSPACE%\sasview 
    49 %PYLINT% --rcfile "build_tools/pylint.rc" -f parseable sasview-install/sasview*.egg/sas sasview > test/sasview.txt 
     87%PYLINT% --rcfile "build_tools/pylint.rc" -f parseable sasview-install/sasview.egg/sas sasview > test/sasview.txt 
    5088 
    5189 
    52 cd  %WORKSPACE% 
     90:: GO BACK ############################################################ 
     91cd %WORKSPACE% 
  • build_tools/requirements.txt

    ra985c93 r243fbc0  
    99PIL==1.1.7 
    1010periodictable==1.3.0 
    11 bumps==0.7.5.5 
     11bumps==0.7.5.9 
    1212# numpy==1.6.1 
    1313# scipy==0.10.1 
  • check_packages.py

    r8e7044c r96e151f  
    77# Fix for error: hash-collision-3-both-1-and-1/ 
    88# 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 
     9try: 
     10    import PIL.Image 
     11except ImportError: 
     12    pass 
     13else: 
     14    sys.modules['Image'] = PIL.Image 
     15 
    1116 
    1217common_required_package_list = { 
     
    1924    'pylint':{'version':None,'import_name':'pylint','test':None}, 
    2025    '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__'}, 
    2227    'numpy':{'version':'1.6.1','import_name':'numpy','test':'__version__'}, 
    2328    'scipy':{'version':'0.10.1','import_name':'scipy','test':'__version__'}, 
  • docs/sphinx-docs/Makefile

    rc23de6a r1d5f5c2  
    118118        $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 
    119119        @echo "Running LaTeX files through pdflatex..." 
    120         $(MAKE) -C $(BUILDDIR)/latex all-pdf 
     120        "$(MAKE)" -C $(BUILDDIR)/latex all-pdf 
    121121        @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 
    122122 
     
    124124        $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 
    125125        @echo "Running LaTeX files through platex and dvipdfmx..." 
    126         $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 
     126        "$(MAKE)" -C $(BUILDDIR)/latex all-pdf-ja 
    127127        @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 
    128128 
  • sasview/README.txt

    rfa4ea80 r243fbc0  
    343343            - unittest-xml-reporting 1.12.0 (MAC 1.10.0) 
    344344            - matplotlib Version Installed: 1.4.3 (MAC 1.1.1) 
    345             - bumps Version Installed: 0.7.5.6 
     345            - bumps Version Installed: 0.7.5.9 
    346346            - scipy Version Installed: 0.16.0b2 (MAC 0.11.0) 
    347347            - periodictable Version Installed: 1.4.1 
  • sasview/installer_generator.py

    r50008e3 r6a698c0  
    197197    msg += """Source: "dist\*";\tDestDir: "{app}";\t""" 
    198198    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""" 
    200202    msg += """Flags: recursesubdirs createallsubdirs\n""" 
    201203    msg += """Source: "dist\config\custom_config.py";\tDestDir: "{userdesktop}\..\.sasview\config";\t"""  
  • sasview/sasview.py

    r558d64e r1be5202  
    8181#Always use private .matplotlib setup to avoid conflicts with other 
    8282#uses of matplotlib 
     83#Have to check if .sasview exists first  
     84sasdir = os.path.join(os.path.expanduser("~"),'.sasview') 
     85if not os.path.exists(sasdir): 
     86    os.mkdir(sasdir) 
    8387mplconfigdir = os.path.join(os.path.expanduser("~"),'.sasview','.matplotlib') 
    8488if not os.path.exists(mplconfigdir): 
  • sasview/setup_exe.py

    r40fc798 r9528caa  
    1616import os 
    1717import sys 
     18import warnings 
     19from glob import glob 
     20import shutil 
     21 
     22from distutils.util import get_platform 
     23from distutils.core import setup 
     24from distutils.filelist import findall 
     25from distutils.sysconfig import get_python_lib 
     26import py2exe 
     27 
     28#from idlelib.PyShell import warning_stream 
    1829 
    1930# put the build directory at the front of the path 
    2031if os.path.abspath(os.path.dirname(__file__)) != os.path.abspath(os.getcwd()): 
    2132    raise RuntimeError("Must run setup_exe from the sasview directory") 
    22 from distutils.util import get_platform 
    2333root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 
    2434platform = '%s-%s'%(get_platform(), sys.version[:3]) 
    2535build_path = os.path.join(root, 'build', 'lib.'+platform) 
     36#build_path = os.path.join(root, 'sasview-install', 'Lib', 'site-packages') 
    2637sys.path.insert(0, build_path) 
    2738 
    2839import local_config 
     40from installer_generator import generate_installer 
     41 
     42import matplotlib 
     43try: 
     44    import tinycc 
     45except ImportError: 
     46    warnings.warn("TinyCC package is not available and will not be included") 
     47    tinycc = None 
    2948 
    3049if len(sys.argv) == 1: 
    3150    sys.argv.append('py2exe') 
     51 
    3252# When using the SasView build script, we need to be able to pass 
    3353# an extra path to be added to the python path. The extra arguments 
     
    4565                sys.exc_value 
    4666 
    47 from distutils.core import setup 
    48 from distutils.filelist import findall 
    49 import matplotlib 
    5067 
    5168# Solution taken from here: http://www.py2exe.org/index.cgi/win32com.shell 
     
    7996    pass 
    8097 
    81 import py2exe 
    82 import shutil 
    8398# Remove the build folder 
    8499shutil.rmtree("build", ignore_errors=True) 
     
    86101shutil.rmtree("dist", ignore_errors=True) 
    87102 
    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 
     103is_64bits = sys.maxsize > 2**32 
     104arch = "amd64" if is_64bits else "x86" 
     105manifest = """ 
     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 
     151if is_64bits: 
     152    msvcrtdll = glob(r"C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*") 
    96153else: 
    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\*.*") 
     155if msvcrtdll: 
     156    msvcrtdll_data_files = ("Microsoft.VC90.CRT", msvcrtdll) 
    125157else: 
    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 
    213159 
    214160 
     
    238184matplotlibdatadir = matplotlib.get_data_path() 
    239185matplotlibdata = findall(matplotlibdatadir) 
     186 
     187site_loc = get_python_lib() 
     188opencl_include_dir = os.path.join(site_loc, "pyopencl", "cl") 
     189 
    240190data_files = [] 
     191 
     192if tinycc: 
     193    data_files += tinycc.data_files() 
     194 
    241195# Copying SLD data 
    242196import periodictable 
    243 import logging 
    244197data_files += periodictable.data_files() 
    245198 
     
    256209data_files += guiframe.data_files() 
    257210 
    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. 
     213import sasmodels.core 
     214dll_path = os.path.join(build_path, 'compiled_models') 
     215compiled_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 
     219data_files.append(('compiled_models', compiled_dlls)) 
     220 
     221import sasmodels 
     222data_files += sasmodels.data_files() 
    260223 
    261224for f in matplotlibdata: 
     
    313276        data_files.append(("test\\upcoming_formats", [f])) 
    314277 
     278# Copying opencl include files 
     279for f in findall(opencl_include_dir): 
     280    data_files.append(("includes\\pyopencl",[f])) 
    315281 
    316282# See if the documentation has been built, and if so include it. 
     
    324290    raise Exception("You must first build the documentation before creating an installer.") 
    325291 
    326 if py26MSdll is not None: 
     292if msvcrtdll_data_files is not None: 
    327293    # 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) 
    332295 
    333296# NOTE: 
     
    338301packages = [ 
    339302    'matplotlib', 'scipy', 'encodings', 'comtypes', 
    340     'win32com', 'xhtml2pdf', 'bumps', 
     303    'win32com', 'xhtml2pdf', 'bumps','sasmodels', 'sas', 
    341304    ] 
    342305packages.extend([ 
     
    356319includes = ['site', 'lxml._elementpath', 'lxml.etree'] 
    357320 
     321if tinycc: 
     322    packages.append('tinycc') 
     323 
    358324# Exclude packages that are not needed but are often found on build systems 
    359 excludes = ['Tkinter', 'PyQt4', '_tkagg', 'sip', 'pytz'] 
     325excludes = ['Tkinter', 'PyQt4', '_tkagg', 'sip', 'pytz', 'sympy'] 
    360326 
    361327 
     
    372338    # accidental links to msys/cygwin binaries; shouldn't be needed 
    373339    'cygwin1.dll', 
     340    # no need to distribute OpenCL.dll - users should have their own copy 
     341    'OpenCL.dll' 
    374342    ] 
    375343 
     
    385353if is_64bits: 
    386354    bundle_option = 3 
    387 import installer_generator as gen 
    388 gen.generate_installer() 
     355generate_installer() 
    389356#initialize category stuff 
    390357#from sas.sasgui.guiframe.CategoryInstaller import CategoryInstaller 
  • sasview/setup_mac.py

    rbd971ec r7c752d0e  
    2020import sys 
    2121import platform 
     22#Extending recursion limit 
     23sys.setrecursionlimit(10000) 
    2224 
    2325from distutils.util import get_platform 
     
    2628build_path = os.path.join(root, 'build','lib.'+platform) 
    2729sys.path.insert(0, build_path) 
    28  
     30print "BUILDING PATH INSIDE", build_path 
    2931ICON = local_config.SetupIconFile_mac 
    3032EXTENSIONS_LIST = [] 
     
    4143import sas.sasgui.perspectives.invariant as invariant 
    4244DATA_FILES += invariant.data_files() 
    43 import sas.models as models 
     45import sasmodels as models 
    4446DATA_FILES += models.data_files() 
    4547import sas.sasgui.guiframe as guiframe 
     
    6769# See if the documentation has been built, and if so include it. 
    6870doc_path = os.path.join(build_path, "doc") 
     71print doc_path 
    6972if os.path.exists(doc_path): 
    7073    for dirpath, dirnames, filenames in os.walk(doc_path): 
     
    131134           'packages': ['lxml','numpy', 'scipy', 'pytz', 'encodings', 
    132135                        'encodings','matplotlib', 'periodictable', 
    133                         'reportlab','sasmodels' 
     136                        'reportlab','sasmodels',"pyopencl" 
    134137                        ], 
    135138           'iconfile': ICON, 
  • setup.py

    rc8843be r3371d81  
    99from distutils.command.build_ext import build_ext 
    1010from distutils.core import Command 
    11 from shutil import rmtree 
    12  
    13 try: 
    14     from numpy.distutils.misc_util import get_numpy_include_dirs 
    15     NUMPY_INC = get_numpy_include_dirs()[0] 
    16 except: 
    17     try: 
    18         import numpy 
    19         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) 
    2511 
    2612# Manage version number ###################################### 
     
    3824# except when there is no such file 
    3925# Todo : make this list generic 
    40 # plugin_model_list = ['polynominal5.py', 'sph_bessel_jn.py', 
     26#plugin_model_list = ['polynominal5.py', 'sph_bessel_jn.py', 
    4127#                      'sum_Ap1_1_Ap2.py', 'sum_p1_p2.py', 
    4228#                      'testmodel_2.py', 'testmodel.py', 
     
    5945    if os.path.isfile(f_path): 
    6046        os.remove(f_path) 
    61     # f_path = os.path.join(sas_dir, 'plugin_models') 
    62     # if os.path.isdir(f_path): 
     47    #f_path = os.path.join(sas_dir, 'plugin_models') 
     48    #if os.path.isdir(f_path): 
    6349    #     for f in os.listdir(f_path): 
    6450    #         if f in plugin_model_list: 
     
    204190 
    205191# sas.sascalc.calculator 
    206 numpy_incl_path = os.path.join(NUMPY_INC, "numpy") 
    207192gen_dir = os.path.join("src", "sas", "sascalc", "calculator", "c_extensions") 
    208193package_dir["sas.sascalc.calculator.core"] = gen_dir 
     
    215200            os.path.join(gen_dir, "libfunc.c"), 
    216201            os.path.join(gen_dir, "librefl.c"), 
    217             os.path.join(gen_dir, "winFuncs.c"), 
    218202        ], 
    219         include_dirs=[numpy_incl_path, gen_dir], 
     203        include_dirs=[gen_dir], 
    220204    ) 
    221205) 
     
    231215                                         os.path.join(srcdir, "invertor.c"), 
    232216                                         ], 
    233                               include_dirs=[numpy_incl_path], 
     217                              include_dirs=[], 
    234218                              ) ) 
    235219         
     
    249233 
    250234package_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/*'] 
     235package_dir["sas.sasgui.perspectives.fitting.plugin_models"] = os.path.join("src", "sas", "sasgui", "perspectives", "fitting", "plugin_models") 
     236packages.extend(["sas.sasgui.perspectives.fitting", "sas.sasgui.perspectives.fitting.plugin_models"]) 
     237package_data['sas.sasgui.perspectives.fitting'] = ['media/*', 'plugin_models/*'] 
    253238 
    254239packages.extend(["sas.sasgui.perspectives", "sas.sasgui.perspectives.calculator"]) 
     
    266251# package_dir["sas.models"] = os.path.join("src", "sas", "models") 
    267252# packages.append("sas.models") 
    268  
    269 IGNORED_FILES = [".svn"] 
    270 if not os.name=='nt': 
    271     IGNORED_FILES.extend(["gamma_win.c","winFuncs.c"]) 
    272253 
    273254EXTENSIONS = [".c", ".cpp"] 
     
    280261        if os.path.isfile(os.path.join(dir_path, f)): 
    281262            _, ext = os.path.splitext(f) 
    282             if ext.lower() in EXTENSIONS and f not in IGNORED_FILES: 
     263            if ext.lower() in EXTENSIONS: 
    283264                file_list.append(os.path.join(dir_path, f)) 
    284265        elif os.path.isdir(os.path.join(dir_path, f)) and \ 
     
    288269                if os.path.isfile(os.path.join(sub_dir, new_f)): 
    289270                    _, 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: 
    292272                        file_list.append(os.path.join(sub_dir, new_f)) 
    293273 
     
    296276append_file(file_sources, gen_dir) 
    297277 
     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 
    298288# SasView 
    299289package_dir["sas.sasview"] = "sasview" 
    300 package_data['sas.sasview'] = ['images/*',  
     290package_data['sas.sasview'] = ['images/*', 
    301291                               'media/*', 
    302292                               'test/*.txt', 
     
    309299 
    310300required = [ 
    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', 
    312302 
    313303    # 'lxml>=2.2.2', 
     
    323313    required.extend(['html5lib', 'reportlab']) 
    324314else: 
    325     required.extend(['pil']) 
    326     
     315    # 'pil' is now called 'pillow' 
     316    required.extend(['pillow']) 
     317 
    327318# Set up SasView     
    328319setup( 
  • src/sas/sascalc/calculator/c_extensions/librefl.c

    r9e531f2 r4c29e4d  
    88#include <stdlib.h> 
    99#if defined(_MSC_VER) 
    10 #include "winFuncs.h" 
     10#define NEED_ERF 
    1111#endif 
     12 
     13 
     14 
     15#if defined(NEED_ERF) 
     16/* erf.c  - public domain implementation of error function erf(3m) 
     17 
     18reference - 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 
     38static double q_gamma(double, double, double); 
     39 
     40/* Incomplete gamma function 
     41   1 / Gamma(a) * Int_0^x exp(-t) t^(a-1) dt  */ 
     42static 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  */ 
     61static 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 
     84double 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 
     94double 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 
    12104 
    13105complex cassign(real, imag) 
  • src/sas/sascalc/calculator/c_extensions/sld2i.cpp

    r9e531f2 rb523c0e  
    164164        //Assume that pixel volumes are given in vol_pix in A^3 unit 
    165165        // 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++){ 
    167167                sumj =0.0;               
    168                 for(size_t j=0; j<n_pix; j++){ 
     168                for(int j=0; j<n_pix; j++){ 
    169169                        //Isotropic: Assumes all slds are real (no magnetic) 
    170170                        //Also assumes there is no polarization: No dependency on spin 
     
    183183                                //full calculation 
    184184                                //pragma omp parallel for 
    185                                 for(size_t k=0; k<n_pix; k++){ 
     185                                for(int k=0; k<n_pix; k++){ 
    186186                                        sld_j =  sldn_val[j] * sldn_val[k] * vol_pix[j] * vol_pix[k]; 
    187187                                        qr = (x_val[j]-x_val[k])*(x_val[j]-x_val[k])+ 
  • src/sas/sascalc/calculator/c_extensions/sld2i.hh

    r9e531f2 r4c29e4d  
    3939                        double s_theta); 
    4040        // compute function 
    41         virtual void genicomXY(int npoints, double* qx, double* qy, double *I_out); 
    42         virtual 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); 
    4343}; 
    4444 
  • src/sas/sascalc/calculator/c_extensions/sld2i_module.cpp

    r9e531f2 rb523c0e  
    153153initsld2i(void) 
    154154{ 
    155     PyObject* m; 
    156  
    157     m = Py_InitModule3("sld2i", module_methods, 
    158                        "Sld2i module"); 
     155    Py_InitModule3("sld2i", module_methods, "Sld2i module"); 
    159156} 
  • src/sas/sascalc/data_util/calcthread.py

    rb699768 r934ce649  
    119119 
    120120    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): 
    122123        """Prepare the calculator""" 
    123124        self.yieldtime     = yieldtime 
     
    125126        self.completefn    = completefn 
    126127        self.updatefn      = updatefn 
     128        self.exception_handler = exception_handler 
    127129        self._interrupting = False 
    128130        self._running      = False 
     
    199201 
    200202    def update(self, **kwargs): 
    201  
    202203        """Update GUI with the lastest results from the current work unit.""" 
    203204        if self.updatefn != None and clock() > self._time_for_update: 
     
    225226        """Perform a work unit.  The subclass will provide details of 
    226227        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', 
    228248 
    229249    def _run(self): 
     
    250270                pass 
    251271            except: 
    252                 traceback.print_exc() 
    253                 #print 'CalcThread exception', 
     272                self.exception() 
    254273        self._running = False 
    255274 
  • src/sas/sascalc/dataloader/readers/cansas_reader.py

    r45d90b9 raf09f48  
    221221                            output.append(return_value) 
    222222                    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()) 
    225225                except: 
    226226                    # If the file does not match the schema, raise this error 
  • src/sas/sascalc/pr/c_extensions/Cinvertor.c

    rb699768 rb523c0e  
    115115 
    116116        //self->params.x = data; 
    117         self->params.npoints = ndata; 
     117        self->params.npoints = (int)ndata; 
    118118        return Py_BuildValue("i", self->params.npoints); 
    119119} 
     
    180180 
    181181        //self->params.y = data; 
    182         self->params.ny = ndata; 
     182        self->params.ny = (int)ndata; 
    183183        return Py_BuildValue("i", self->params.ny); 
    184184} 
     
    245245 
    246246        //self->params.err = data; 
    247         self->params.nerr = ndata; 
     247        self->params.nerr = (int)ndata; 
    248248        return Py_BuildValue("i", self->params.nerr); 
    249249} 
     
    523523    residuals = PyList_New(self->params.npoints); 
    524524 
    525     regterm = reg_term(pars, self->params.d_max, npars, nslice); 
     525    regterm = reg_term(pars, self->params.d_max, (int)npars, nslice); 
    526526 
    527527    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]); 
    529529        residual = diff*diff / (self->params.err[i]*self->params.err[i]); 
    530530 
     
    573573    residuals = PyList_New(self->params.npoints); 
    574574 
    575     regterm = reg_term(pars, self->params.d_max, npars, nslice); 
     575    regterm = reg_term(pars, self->params.d_max, (int)npars, nslice); 
    576576 
    577577 
    578578    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]); 
    580580        residual = diff*diff / (self->params.err[i]*self->params.err[i]); 
    581581 
     
    611611        OUTVECTOR(data_obj,pars,npars); 
    612612 
    613         iq_value = iq(pars, self->params.d_max, npars, q); 
     613        iq_value = iq(pars, self->params.d_max, (int)npars, q); 
    614614        return Py_BuildValue("f", iq_value); 
    615615} 
     
    636636        OUTVECTOR(data_obj,pars,npars); 
    637637 
    638         iq_value = iq_smeared(pars, self->params.d_max, npars, 
     638        iq_value = iq_smeared(pars, self->params.d_max, (int)npars, 
    639639                                                        self->params.slit_height, self->params.slit_width, 
    640640                                                        q, 21); 
     
    661661        OUTVECTOR(data_obj,pars,npars); 
    662662 
    663         pr_value = pr(pars, self->params.d_max, npars, r); 
     663        pr_value = pr(pars, self->params.d_max, (int)npars, r); 
    664664        return Py_BuildValue("f", pr_value); 
    665665} 
     
    689689 
    690690        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); 
    692692                pr_err_value = 0.0; 
    693693        } else { 
    694694                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); 
    696696        } 
    697697        return Py_BuildValue("ff", pr_value, pr_err_value); 
     
    728728        OUTVECTOR(data_obj,pars,npars); 
    729729 
    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); 
    732732        return Py_BuildValue("f", sqrt(oscill/norm)/acos(-1.0)*self->params.d_max ); 
    733733 
     
    749749        OUTVECTOR(data_obj,pars,npars); 
    750750 
    751         count = npeaks(pars, self->params.d_max, npars, 100); 
     751        count = npeaks(pars, self->params.d_max, (int)npars, 100); 
    752752 
    753753        return Py_BuildValue("i", count ); 
     
    770770        OUTVECTOR(data_obj,pars,npars); 
    771771 
    772         fraction = positive_integral(pars, self->params.d_max, npars, 100); 
     772        fraction = positive_integral(pars, self->params.d_max, (int)npars, 100); 
    773773 
    774774        return Py_BuildValue("f", fraction ); 
     
    795795        OUTVECTOR(err_obj,pars_err,npars2); 
    796796 
    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); 
    798798 
    799799        return Py_BuildValue("f", fraction ); 
     
    815815        OUTVECTOR(data_obj,pars,npars); 
    816816 
    817         value = rg(pars, self->params.d_max, npars, 101); 
     817        value = rg(pars, self->params.d_max, (int)npars, 101); 
    818818 
    819819        return Py_BuildValue("f", value ); 
     
    835835        OUTVECTOR(data_obj,pars,npars); 
    836836 
    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); 
    838838 
    839839        return Py_BuildValue("f", value ); 
  • src/sas/sasgui/guiframe/local_perspectives/data_loader/data_loader.py

    rd85c194 rfaa3ae7  
    155155        """ 
    156156        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)) 
    158163            data_error = True 
    159             message += "\tError: {0}\n".format(error_data) 
     164         
    160165        data = self.parent.create_gui_data(item, p_file) 
    161166        output[data.id] = data 
     
    203208                                                          error_message) 
    204209            except: 
     210                logging.error(sys.exc_value) 
    205211                any_error = True 
    206212            if any_error or error_message != "": 
  • src/sas/sasgui/perspectives/calculator/model_editor.py

    rcb4ef58 rbb841ef  
    3030from wx.py.editwindow import EditWindow 
    3131from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
     32from .pyconsole import show_model_output, check_model 
    3233 
    3334 
     
    4546PANEL_WIDTH = 500 
    4647_BOX_WIDTH = 55 
    47  
    48  
    49 def _compile_file(path): 
    50     """ 
    51     Compile the file in the path 
    52     """ 
    53     try: 
    54         import py_compile 
    55         py_compile.compile(file=path, doraise=True) 
    56         return '' 
    57     except: 
    58         _, value, _ = sys.exc_info() 
    59         return value 
    6048 
    6149def _delete_file(path): 
     
    384372            name2 = label[1] 
    385373            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() 
    388377            msg = self._notes 
    389378            info = 'Info' 
     
    618607        """ 
    619608        path = self.fname 
    620         _compile_file(path) 
     609        show_model_output(self, path) 
    621610 
    622611    def delete_file(self, path): 
     
    954943        info = 'Info' 
    955944        msg = '' 
     945        result, check_err = '', '' 
    956946        # Sort out the errors if occur 
    957947        # First check for valid python name then if the name already exists 
     
    969959                    self.write_file(self.fname, name, description, param_str, 
    970960                                    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 
    971968                    # Modified compiling test, as it will fail for sasmodels.sasview_model class 
    972969                    # Should add a test to check that the class is correctly built  
     
    10311028            color = 'red' 
    10321029        else: 
    1033             msg = "Successful! " 
     1030            self._notes = result 
     1031            msg = "Successful! Please look for %s in Customized Models."%name 
    10341032            msg += "  " + self._notes 
    1035             msg += " Please look for it in the Customized Models." 
    10361033            info = 'Info' 
    10371034            color = 'blue' 
     
    10411038        if self.base != None: 
    10421039            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)) 
    10441042        self.warning = msg 
    10451043 
     
    13331331import copy 
    13341332 
    1335 import nuympy 
     1333import numpy 
    13361334 
    13371335from sas.sascalc.fit.pluginmodel import Model1DPlugin 
  • src/sas/sasgui/perspectives/calculator/pyconsole.py

    rd85c194 r26d6e045  
    44import sys 
    55import os 
     6 
     7import numpy as np 
     8 
    69import wx 
    7 import wx.lib.dialogs 
     10from wx.lib.dialogs import ScrolledMessageDialog 
    811import wx.py.editor as editor 
    9 import wx.py.frame as frame 
    10 import py_compile 
    1112 
    1213if sys.platform.count("win32") > 0: 
     
    1819    PANEL_HEIGHT = 730 
    1920    FONT_VARIANT = 1 
    20 ID_COMPILE = wx.NewId() 
     21ID_CHECK_MODEL = wx.NewId() 
    2122ID_RUN = wx.NewId() 
    2223 
    23 def compile_file(path): 
     24def check_model(path): 
    2425    """ 
    25     Compile a python file 
     26    Check that the model on the path can run. 
    2627    """ 
     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 
     47def 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 
    2754    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 
    3475 
    3576class PyConsole(editor.EditorNotebookFrame): 
     
    65106        self.Bind(wx.EVT_MENU, self.OnSaveFile, id=wx.ID_SAVE) 
    66107        self.Bind(wx.EVT_MENU, self.OnSaveAsFile, id=wx.ID_SAVEAS) 
    67         self.Bind(wx.EVT_MENU, self.OnCompile, id=ID_COMPILE) 
     108        self.Bind(wx.EVT_MENU, self.OnCheckModel, id=ID_CHECK_MODEL) 
    68109        self.Bind(wx.EVT_MENU, self.OnRun, id=ID_RUN) 
    69         self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateCompileMenu, id=ID_COMPILE) 
     110        self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateCompileMenu, id=ID_CHECK_MODEL) 
    70111        self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateCompileMenu, id=ID_RUN) 
    71112        self.Bind(wx.EVT_CLOSE, self.on_close) 
     
    81122        """ 
    82123        self.compileMenu = wx.Menu() 
    83         self.compileMenu.Append(ID_COMPILE, 'Compile', 
    84                  'Compile the file') 
     124        self.compileMenu.Append(ID_CHECK_MODEL, 'Check model', 
     125                 'Loading and run the model') 
    85126        self.compileMenu.AppendSeparator() 
    86127        self.compileMenu.Append(ID_RUN, 'Run in Shell', 
     
    192233        Run 
    193234        """ 
    194         if self._check_changed(): 
     235        if not self._check_saved(): 
    195236            return True 
    196237        if self.buffer and self.buffer.doc.filepath: 
     
    207248            icon = wx.ICON_ERROR 
    208249            wx.MessageBox(str(mssg), title, style=icon) 
    209             return 0 
    210  
    211     def OnCompile(self, event): 
     250            return False 
     251 
     252    def OnCheckModel(self, event): 
    212253        """ 
    213254        Compile 
    214255        """ 
    215         if self._check_changed(): 
     256        if not self._check_saved(): 
    216257            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): 
    225267        """ 
    226268        If content was changed, suggest to save it first 
     
    228270        if self.bufferHasChanged() and self.buffer.doc.filepath: 
    229271            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 
    278273        return True 
    279274 
     
    286281        event.Enable(True) 
    287282        try: 
    288             if id == ID_COMPILE or id == ID_RUN: 
     283            if id == ID_CHECK_MODEL or id == ID_RUN: 
    289284                menu_on = False 
    290285                if self.buffer and self.buffer.doc.filepath: 
  • src/sas/sasgui/perspectives/fitting/__init__.py

    r9e531f2 ra7c4ad2  
    3939    data_files = [] 
    4040    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])) 
    4444    # path = get_data_path(media="media") 
    4545    for f in findall(path): 
  • src/sas/sasgui/perspectives/fitting/fitpage.py

    rcb4ef58 r934ce649  
    13301330                                              qmin=float(self.qmin_x), 
    13311331                                              qmax=float(self.qmax_x), 
    1332                                               enable_smearer=enable_smearer, 
    1333                                               draw=True) 
     1332                                              enable_smearer=enable_smearer) 
    13341333                if flag: 
    13351334                    #self.compute_chisqr(smearer= temp_smearer) 
     
    26062605                     qmin=float(self.qmin_x), 
    26072606                     qmax=float(self.qmax_x), 
    2608                      enable_smearer=enable_smearer, 
    2609                      draw=True) 
     2607                     enable_smearer=enable_smearer) 
    26102608 
    26112609        self.state.enable_smearer = self.enable_smearer.GetValue() 
  • src/sas/sasgui/perspectives/fitting/fitpanel.py

    rf60251f r05228b0  
    1717import models 
    1818_BOX_WIDTH = 80 
    19  
    2019 
    2120class FitPanel(nb, PanelBase): 
     
    154153        """ 
    155154        """ 
    156         from bumps.options import FIT_CONFIG 
    157         current = FIT_CONFIG.selected_name 
    158         self.parent.SetTitle(self.window_name + " - Active Fitting Optimizer: " + current) 
    159155        pos = self.GetSelection() 
    160156        if pos != -1: 
  • src/sas/sasgui/perspectives/fitting/fitting.py

    r86b049b r934ce649  
    1919import time 
    2020from copy import deepcopy 
    21 import models 
     21import traceback 
    2222 
    2323from sas.sascalc.dataloader.loader import Loader 
     
    4646from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
    4747 
     48from . import models 
     49 
    4850MAX_NBR_DATA = 4 
    4951 
     
    5658    ON_MAC = True 
    5759 
    58  
     60import bumps.options 
     61from bumps.gui.fit_dialog import show_fit_config 
     62try: 
     63    from bumps.gui.fit_dialog import EVT_FITTER_CHANGED 
     64except ImportError: 
     65    # CRUFT: bumps 0.7.5.8 and below 
     66    EVT_FITTER_CHANGED = None  # type: wx.PyCommandEvent 
    5967 
    6068class Plugin(PluginBase): 
     
    254262                msg += "and try it again." 
    255263                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) 
    258266            else: 
    259267                self.delete_menu.Delete(event_id) 
     
    262270                        self.edit_menu.DeleteItem(item) 
    263271                        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) 
    266274                        break 
    267275        except: 
     
    501509        self.parent.Bind(EVT_SLICER_PANEL, self._on_slicer_event) 
    502510        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 
    503517        #self.parent._mgr.Bind(wx.aui.EVT_AUI_PANE_CLOSE,self._onclearslicer) 
    504518        #Create reader when fitting panel are created 
     
    567581            except: 
    568582                msg = "Fitting: cannot deal with the theory received" 
     583                evt = StatusEvent(status=msg, info="error") 
    569584                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) 
    572586 
    573587    def set_state(self, state=None, datainfo=None, format=None): 
     
    763777        Open the bumps options panel. 
    764778        """ 
    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) 
    772788 
    773789    def on_help(self, algorithm_id): 
     
    954970                    if not page.param_toFit: 
    955971                        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) 
    959974                        return False 
    960975                    if not page._update_paramv_on_fit(): 
     
    962977                        msg += " invalid in %s" % \ 
    963978                                    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) 
    967981                        return False 
    968982 
     
    985999            except KeyboardInterrupt: 
    9861000                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) 
    9891003                return True 
    9901004            except: 
    9911005                raise 
    9921006                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) 
    9951009                return False 
    9961010        ## If a thread is already started, stop it 
     
    10871101            # add data associated to the page created 
    10881102            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) 
    10911105            else: 
    10921106                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) 
    10951109        except: 
    10961110            msg = "Creating Fit page: %s" % sys.exc_value 
     
    12541268        msg = "Fit completed on %s \n" % str_time 
    12551269        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) 
    12581272 
    12591273        if batch_outputs is None: 
     
    14051419                                         batch_inputs=batch_inputs) 
    14061420 
    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) 
    14091423        # Remove parameters that are not shown 
    14101424        cpage = self.fit_panel.get_page_by_id(uid) 
     
    14851499        msg = "Fit completed on %s \n" % str_time 
    14861500        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) 
    14891503        wx.PostEvent(self.result_panel, PlotResultEvent(result=result)) 
    14901504        wx.CallAfter(self._update_fit_button, page_id) 
     
    15101524                    not numpy.all(numpy.isfinite(res.pvec)): 
    15111525                    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) 
    15161528                    wx.CallAfter(self._update_fit_button, page_id) 
    15171529                else: 
     
    15371549                    except KeyboardInterrupt: 
    15381550                        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) 
    15421553                    except: 
    15431554                        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) 
    15471557 
    15481558        except: 
     
    15501560                   % sys.exc_value) 
    15511561            #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) 
    15541564 
    15551565    def _update_fit_button(self, page_id): 
     
    15881598        ## post a message to status bar 
    15891599        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)) 
    15921601 
    15931602 
     
    17351744            raise 
    17361745 
     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 
    17371755    def _update2D(self, output, time=None): 
    17381756        """ 
    17391757        Update the output of plotting model 
    17401758        """ 
    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")) 
    17441761 
    17451762    def _complete2D(self, image, data, model, page_id, elapsed, index, qmin, 
     
    18471864                    time.sleep(0.1) 
    18481865            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) 
    18601879            self.calc_2D.queue() 
    18611880        except: 
     
    19121931                                  #updatefn = self._update1D, 
    19131932                                  update_chisqr=update_chisqr, 
     1933                                  exception_handler=self._calc_exception, 
    19141934                                  source=source) 
    19151935            self.calc_1D.queue() 
  • src/sas/sasgui/perspectives/fitting/model_thread.py

    rd85c194 r934ce649  
    2525                 source='model', 
    2626                 yieldtime=0.04, 
    27                  worktime=0.04 
     27                 worktime=0.04, 
     28                 exception_handler=None, 
    2829                 ): 
    29         CalcThread.__init__(self, completefn, updatefn, yieldtime, worktime) 
     30        CalcThread.__init__(self, completefn, updatefn, yieldtime, worktime, 
     31                            exception_handler=exception_handler) 
    3032        self.qmin = qmin 
    3133        self.qmax = qmax 
     
    133135                 updatefn=None, 
    134136                 yieldtime=0.01, 
    135                  worktime=0.01 
     137                 worktime=0.01, 
     138                 exception_handler=None, 
    136139                 ): 
    137140        """ 
    138141        """ 
    139         CalcThread.__init__(self, completefn, 
    140                  updatefn, 
    141                  yieldtime, 
    142                  worktime) 
     142        CalcThread.__init__(self, completefn, updatefn, yieldtime, worktime, 
     143                            exception_handler=exception_handler) 
    143144        self.fid = fid 
    144145        self.data = data 
  • src/sas/sasgui/perspectives/invariant/media/invariant_help.rst

    r7805458 r70305bd2  
    1919.. image:: image001.gif 
    2020 
    21 where *g = Q* for pinhole geometry (SAS) and *g = Qv* (the slit height) for   
     21where *g = q* for pinhole geometry (SAS) and *g = q*\ :sub:`v` (the slit height) for   
    2222slit geometry (USAS). 
    2323 
  • src/sas/sasgui/plottools/plottables.py

    rd7bb526 rcd54205  
    704704            else: 
    705705                self.dy = None 
    706             tempx = [] 
    707             tempy = [] 
    708706            if not has_err_x: 
    709707                dx = numpy.zeros(len(x)) 
     
    724722                    if has_err_y: 
    725723                        self.dy.append(tempdy) 
    726                 except: 
    727                     tempx = x[i] 
    728                     tempy = y[i] 
    729                     tempdy = dy[i] 
     724                except Exception: 
     725                    pass 
    730726            # Sanity check 
    731727            if not len(self.x) == len(self.y): 
     
    733729                msg += "and y are not of the same length" 
    734730                raise ValueError, msg 
    735             if has_err_x and not (len(self.x) and len(self.dx)): 
     731            if has_err_x and not (len(self.x) == len(self.dx)): 
    736732                msg = "Plottable.View: transformed x and dx" 
    737733                msg += " are not of the same length" 
    738734                raise ValueError, msg 
    739             if has_err_y and not (len(self.y) and len(self.dy)): 
     735            if has_err_y and not (len(self.y) == len(self.dy)): 
    740736                msg = "Plottable.View: transformed y" 
    741737                msg += " and dy are not of the same length" 
  • src/sas/sasgui/perspectives/fitting/models.py

    rcb4ef58 r6afc14b  
    147147    try: 
    148148        import compileall 
    149         compileall.compile_dir(dir=dir, ddir=dir, force=1, 
     149        compileall.compile_dir(dir=dir, ddir=dir, force=0, 
    150150                               quiet=report_problem) 
    151151    except: 
Note: See TracChangeset for help on using the changeset viewer.