Changeset 14e08bf in sasmodels


Ignore:
Timestamp:
Apr 7, 2017 3:48:27 AM (8 years ago)
Author:
GitHub <noreply@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
46056006
Parents:
650c6d2 (diff), d810d96 (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.
git-author:
Andrew Jackson <andrew.jackson@…> (04/07/17 03:48:27)
git-committer:
GitHub <noreply@…> (04/07/17 03:48:27)
Message:

Merge pull request #39 from andyfaff/appveyor

Add Appveyor

Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • .travis.yml

    rbec0e75 r01e551a  
    1 # Test Travis CL 
    2  
    31language: python 
    42python: 
    5   - "2.7" 
    6 # whitelist 
     3- '2.7' 
    74branches: 
    85  only: 
    9     - master 
    10 # command to install dependencies 
     6  - master 
    117virtualenv: 
    128  system_site_packages: true 
    139before_install: 
    14   - sudo apt-get update; 
    15   - sudo apt-get install python-numpy python-scipy 
    16 #  - sudo apt-get install opencl-headers 
    17  
     10- sudo apt-get update; 
     11- sudo apt-get install python-numpy python-scipy 
    1812install: 
    19 #  - pip install pyopencl 
    20   - pip install bumps 
    21   - pip install unittest-xml-reporting 
     13- pip install bumps 
     14- pip install unittest-xml-reporting 
    2215script: 
    23   - export WORKSPACE=/home/travis/build/SasView/sasmodels/ 
    24   - python -m sasmodels.model_test dll all 
     16- export WORKSPACE=/home/travis/build/SasView/sasmodels/ 
     17- python -m sasmodels.model_test dll all 
     18notifications: 
     19  slack: 
     20    secure: xNAUeSu1/it/x9Q2CSg79aw1LLc7d6mLpcqSCTeKROp71RhkFf8VjJnJm/lEbKHNC8yj5H9UHrz5DmzwJzI+6oMt4NdEeS6WvGhwGY/wCt2IcJKxw0vj1DAU04qFMS041Khwclo6jIqm76DloinXvmvsS+K/nSyQkF7q4egSlwA= 
  • LICENSE.txt

    rc8de1bd rf68e2a5  
    1 This program is in the public domain. 
     1Copyright (c) 2009-2017, SasView Developers 
     2All rights reserved. 
    23 
    3 Individual files may be copyright different authors, with licences that 
    4 allow modification and redistribution in source or binary form with or 
    5 without modification, and a disclaimer of warranty. 
     4Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 
     5 
     61. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
     7 
     82. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 
     9 
     103. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 
     11 
     12THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  • sasmodels/compare.py

    rf72d70a r650c6d2  
    3030 
    3131import sys 
     32import os 
    3233import math 
    3334import datetime 
     
    4041from . import kerneldll 
    4142from . import exception 
    42 from .data import plot_theory, empty_data1D, empty_data2D 
     43from .data import plot_theory, empty_data1D, empty_data2D, load_data 
    4344from .direct_model import DirectModel 
    4445from .convert import revert_name, revert_pars, constrain_new_to_old 
     
    8586    -html shows the model docs instead of running the model 
    8687    -title="note" adds note to the plot title, after the model name 
     88    -data="path" uses q, dq from the data file 
    8789 
    8890Any two calculation engines can be selected for comparison: 
     
    544546    'f32': '32', 
    545547    'f64': '64', 
     548    'float16': '16', 
     549    'float32': '32', 
     550    'float64': '64', 
     551    'float128': '128', 
    546552    'longdouble': '128', 
    547553} 
     
    747753    comp = opts['engines'][1] if have_comp else None 
    748754    data = opts['data'] 
     755    use_data = have_base ^ have_comp 
    749756 
    750757    # Plot if requested 
     
    763770    if have_base: 
    764771        if have_comp: plt.subplot(131) 
    765         plot_theory(data, base_value, view=view, use_data=False, limits=limits) 
     772        plot_theory(data, base_value, view=view, use_data=use_data, limits=limits) 
    766773        plt.title("%s t=%.2f ms"%(base.engine, base_time)) 
    767774        #cbar_title = "log I" 
     
    769776        if have_base: plt.subplot(132) 
    770777        if not opts['is2d'] and have_base: 
    771             plot_theory(data, base_value, view=view, use_data=False, limits=limits) 
    772         plot_theory(data, comp_value, view=view, use_data=False, limits=limits) 
     778            plot_theory(data, base_value, view=view, use_data=use_data, limits=limits) 
     779        plot_theory(data, comp_value, view=view, use_data=use_data, limits=limits) 
    773780        plt.title("%s t=%.2f ms"%(comp.engine, comp_time)) 
    774781        #cbar_title = "log I" 
     
    784791            err[err>cutoff] = cutoff 
    785792        #err,errstr = base/comp,"ratio" 
    786         plot_theory(data, None, resid=err, view=errview, use_data=False) 
     793        plot_theory(data, None, resid=err, view=errview, use_data=use_data) 
    787794        if view == 'linear': 
    788795            plt.xscale('linear') 
     
    834841VALUE_OPTIONS = [ 
    835842    # Note: random is both a name option and a value option 
    836     'cutoff', 'random', 'nq', 'res', 'accuracy', 'title', 
     843    'cutoff', 'random', 'nq', 'res', 'accuracy', 'title', 'data', 
    837844    ] 
    838845 
     
    951958        'html'      : False, 
    952959        'title'     : None, 
     960        'data'      : None, 
    953961    } 
    954962    engines = [] 
     
    971979        elif arg.startswith('-cutoff='):   opts['cutoff'] = float(arg[8:]) 
    972980        elif arg.startswith('-random='):   opts['seed'] = int(arg[8:]) 
    973         elif arg.startswith('-title'):     opts['title'] = arg[7:] 
     981        elif arg.startswith('-title='):    opts['title'] = arg[7:] 
     982        elif arg.startswith('-data='):     opts['data'] = arg[6:] 
    974983        elif arg == '-random':  opts['seed'] = np.random.randint(1000000) 
    975984        elif arg == '-preset':  opts['seed'] = -1 
     
    11121121 
    11131122    # Create the computational engines 
    1114     data, _ = make_data(opts) 
     1123    if opts['data'] is not None: 
     1124        data = load_data(os.path.expanduser(opts['data'])) 
     1125    else: 
     1126        data, _ = make_data(opts) 
    11151127    if n1: 
    11161128        base = make_engine(model_info, data, engines[0], opts['cutoff']) 
     
    11421154    show html docs for the model 
    11431155    """ 
    1144     import wx  # type: ignore 
    1145     from .generate import view_html_from_info 
    1146     app = wx.App() if wx.GetApp() is None else None 
    1147     view_html_from_info(opts['def'][0]) 
    1148     if app: app.MainLoop() 
    1149  
     1156    import os 
     1157    from .generate import make_html 
     1158    from . import rst2html 
     1159 
     1160    info = opts['def'][0] 
     1161    html = make_html(info) 
     1162    path = os.path.dirname(info.filename) 
     1163    url = "file://"+path.replace("\\","/")[2:]+"/" 
     1164    rst2html.view_html_qtapp(html, url) 
    11501165 
    11511166def explore(opts): 
  • sasmodels/core.py

    r5124c969 r650c6d2  
    250250        dtype = "longdouble" 
    251251    elif dtype == "half": 
    252         dtype = "f16" 
     252        dtype = "float16" 
    253253 
    254254    # Convert dtype string to numpy dtype. 
  • sasmodels/data.py

    r40a87fa ra769b54  
    5454    if data is None: 
    5555        raise IOError("Data %r could not be loaded" % filename) 
     56    if hasattr(data, 'x'): 
     57        data.qmin, data.qmax = data.x.min(), data.x.max() 
     58        data.mask = (np.isnan(data.y) if data.y is not None 
     59                     else np.zeros_like(data.x, dtype='bool')) 
    5660    return data 
    5761 
     
    348352    # data, but they already handle the masking and graph markup already, so 
    349353    # do not repeat. 
    350     if hasattr(data, 'lam'): 
     354    if hasattr(data, 'isSesans') and data.isSesans: 
    351355        _plot_result_sesans(data, None, None, use_data=True, limits=limits) 
    352356    elif hasattr(data, 'qx_data'): 
     
    376380    *Iq_calc* is the raw theory values without resolution smearing 
    377381    """ 
    378     if hasattr(data, 'lam'): 
     382    if hasattr(data, 'isSesans') and data.isSesans: 
    379383        _plot_result_sesans(data, theory, resid, use_data=True, limits=limits) 
    380384    elif hasattr(data, 'qx_data'): 
  • sasmodels/direct_model.py

    rb397165 ra769b54  
    192192 
    193193        # interpret data 
    194         if hasattr(data, 'lam'): 
     194        if hasattr(data, 'isSesans') and data.isSesans: 
    195195            self.data_type = 'sesans' 
    196196        elif hasattr(data, 'qx_data'): 
  • sasmodels/generate.py

    r1e7b0db0 rc4e3215  
    928928    from . import rst2html 
    929929    url = "file://"+dirname(info.filename)+"/" 
    930     rst2html.wxview(make_html(info), url=url) 
     930    rst2html.view_html(make_html(info), url=url) 
    931931 
    932932def demo_time(): 
  • sasmodels/models/hayter_msa.py

    ra807206 r5702f52  
    7474    ["radius_effective", "Ang", 20.75,   [0, inf],    "volume", "effective radius of charged sphere"], 
    7575    ["volfraction",   "None",     0.0192, [0, 0.74],   "", "volume fraction of spheres"], 
    76     ["charge",        "e",   19.0,    [0, inf],    "", "charge on sphere (in electrons)"], 
    77     ["temperature",   "K",  318.16,   [0, inf],    "", "temperature, in Kelvin, for Debye length calculation"], 
    78     ["concentration_salt",      "M",    0.0,    [-inf, inf], "", "conc of salt, moles/litre, 1:1 electolyte, for Debye length"], 
     76    ["charge",        "e",   19.0,    [0, 200],    "", "charge on sphere (in electrons)"], 
     77    ["temperature",   "K",  318.16,   [0, 450],    "", "temperature, in Kelvin, for Debye length calculation"], 
     78    ["concentration_salt",      "M",    0.0,    [0, inf], "", "conc of salt, moles/litre, 1:1 electolyte, for Debye length"], 
    7979    ["dielectconst",  "None",    71.08,   [-inf, inf], "", "dielectric constant (relative permittivity) of solvent, default water, for Debye length"] 
    8080    ] 
  • sasmodels/rst2html.py

    r0890871 rc4e3215  
    2929from docutils.writers.html4css1 import HTMLTranslator 
    3030from docutils.nodes import SkipNode 
    31  
    32 def wxview(html, url="", size=(850, 540)): 
    33     import wx 
    34     from wx.html2 import WebView 
    35     frame = wx.Frame(None, -1, size=size) 
    36     view = WebView.New(frame) 
    37     view.SetPage(html, url) 
    38     frame.Show() 
    39     return frame 
    40  
    41 def view_rst(filename): 
    42     from os.path import expanduser 
    43     with open(expanduser(filename)) as fid: 
    44         rst = fid.read() 
    45     html = rst2html(rst) 
    46     wxview(html) 
    4731 
    4832def rst2html(rst, part="whole", math_output="mathjax"): 
     
    155139    assert replace_dollar(u"a (again $in parens$) a") == u"a (again :math:`in parens`) a" 
    156140 
    157 def view_rst_app(filename): 
     141def load_rst_as_html(filename): 
     142    from os.path import expanduser 
     143    with open(expanduser(filename)) as fid: 
     144        rst = fid.read() 
     145    html = rst2html(rst) 
     146    return html 
     147 
     148def wxview(html, url="", size=(850, 540)): 
     149    import wx 
     150    from wx.html2 import WebView 
     151    frame = wx.Frame(None, -1, size=size) 
     152    view = WebView.New(frame) 
     153    view.SetPage(html, url) 
     154    frame.Show() 
     155    return frame 
     156 
     157def qtview(html, url=""): 
     158    try: 
     159        from PyQt5.QtWebKitWidgets import QWebView 
     160        from PyQt5.QtCore import QUrl 
     161    except ImportError: 
     162        from PyQt4.QtWebkit import QWebView 
     163        from PyQt4.QtCore import QUrl 
     164    helpView = QWebView() 
     165    helpView.setHtml(html, QUrl(url)) 
     166    helpView.show() 
     167    return helpView 
     168 
     169def view_html_wxapp(html, url=""): 
    158170    import wx  # type: ignore 
    159171    app = wx.App() 
    160     view_rst(filename) 
     172    frame = wxview(html, url) 
    161173    app.MainLoop() 
    162174 
     175def view_html_qtapp(html, url=""): 
     176    import sys 
     177    try: 
     178        from PyQt5.QtWidgets import QApplication 
     179    except ImportError: 
     180        from PyQt4.QtGui import QApplication 
     181    app = QApplication([]) 
     182    frame = qtview(html, url) 
     183    sys.exit(app.exec_()) 
     184 
     185def view_rst_app(filename, qt=False): 
     186    import os 
     187    html = load_rst_as_html(filename) 
     188    url="file://"+os.path.abspath(filename)+"/" 
     189    if qt: 
     190        view_html_qtapp(html, url) 
     191    else: 
     192        view_html_wxapp(html, url) 
    163193 
    164194if __name__ == "__main__": 
    165195    import sys 
    166     view_rst_app(sys.argv[1]) 
     196    view_rst_app(sys.argv[1], qt=True) 
    167197 
Note: See TracChangeset for help on using the changeset viewer.