Changeset 3964f92 in sasmodels
- Timestamp:
- Feb 7, 2016 11:31:27 PM (9 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 216fa6d
- Parents:
- 321736f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/convert.py
rd368d21 r3964f92 1 """ 2 Convert models to and from sasview. 3 """ 4 import warnings 1 5 6 # List of models which SasView versions don't contain the explicit 'scale' argument. 7 # When converting such a model, please update this list. 8 MODELS_WITHOUT_SCALE = [ 9 'teubner_strey', 10 'broad_peak', 11 'two_lorentzian', 12 'gel_fit', 13 'gauss_lorentz_gel', 14 'be_polyelectrolyte', 15 'correlation_length', 16 'binary_hard_sphere' 17 ] 2 18 19 # List of models which SasView versions don't contain the explicit 'background' argument. 20 # When converting such a model, please update this list. 21 MODELS_WITHOUT_BACKGROUND = [ 22 'guinier', 23 ] 3 24 25 PD_DOT = [ 26 ("", ""), 27 ("_pd", ".width"), 28 ("_pd_n", ".npts"), 29 ("_pd_nsigma", ".nsigmas"), 30 ("_pd_type", ".type"), 31 ] 32 def _convert_pars(pars, mapping): 33 """ 34 Rename the parameters and any associated polydispersity attributes. 35 """ 36 newpars = pars.copy() 37 for new, old in mapping.items(): 38 if old == new: continue 39 for pd, dot in PD_DOT: 40 if old+dot in newpars: 41 if new is not None: 42 newpars[new+pd] = pars[old+dot] 43 del newpars[old+dot] 44 return newpars 4 45 5 <!DOCTYPE html> 6 <html lang="en" class=" is-copy-enabled is-u2f-enabled"> 7 <head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# object: http://ogp.me/ns/object# article: http://ogp.me/ns/article# profile: http://ogp.me/ns/profile#"> 8 <meta charset='utf-8'> 46 def _rescale_sld(pars): 47 """ 48 rescale all sld parameters in the new model definition by 1e6 so the 49 numbers are nicer. Relies on the fact that all sld parameters in the 50 new model definition end with sld. 51 """ 52 return dict((p, (v*1e6 if p.endswith('sld') else v)) 53 for p, v in pars.items()) 9 54 10 <link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/github-e3dd2ae433414e240167f740f90ff2599e28804648787933de7c0183fae81c29.css" integrity="sha256-490q5DNBTiQBZ/dA+Q/yWZ4ogEZIeHkz3nwBg/roHCk=" media="all" rel="stylesheet" /> 11 <link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/github2-fd8d48abb9063f51f186b0da98caa88d32b7ca8baecaa10d8a91c18a6f129b7f.css" integrity="sha256-/Y1Iq7kGP1HxhrDamMqojTK3youuyqENipHBim8Sm38=" media="all" rel="stylesheet" /> 12 13 14 55 def convert_model(name, pars): 56 """ 57 Convert model from old style parameter names to new style. 58 """ 59 _, _ = name, pars # lint 60 raise NotImplementedError 61 # need to load all new models in order to determine old=>new 62 # model name mapping 15 63 16 <link as="script" href="https://assets-cdn.github.com/assets/frameworks-ee521b8e9facac68ff27e93fc3ae0f8ed811d7bf9e434e84f4b9ea227780b084.js" rel="preload" /> 17 <link as="script" href="https://assets-cdn.github.com/assets/github-696336964b7c42e4c6f4dfbaf1f8e57f425cd9a9d18a12f3fe6e3dd744fd7d13.js" rel="preload" /> 64 def _unscale_sld(pars): 65 """ 66 rescale all sld parameters in the new model definition by 1e6 so the 67 numbers are nicer. Relies on the fact that all sld parameters in the 68 new model definition end with sld. 69 """ 70 return dict((p, (v*1e-6 if p.endswith('sld') else v)) 71 for p, v in pars.items()) 18 72 19 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 20 <meta http-equiv="Content-Language" content="en"> 21 <meta name="viewport" content="width=1020"> 22 23 24 <title>sasmodels/convert.py at master · SasView/sasmodels · GitHub</title> 25 <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub"> 26 <link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub"> 27 <link rel="apple-touch-icon" href="/apple-touch-icon.png"> 28 <link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png"> 29 <link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png"> 30 <link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-72x72.png"> 31 <link rel="apple-touch-icon" sizes="76x76" href="/apple-touch-icon-76x76.png"> 32 <link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-114x114.png"> 33 <link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-120x120.png"> 34 <link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-144x144.png"> 35 <link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png"> 36 <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon-180x180.png"> 37 <meta property="fb:app_id" content="1401488693436528"> 73 def _remove_pd(pars, key, name): 74 """ 75 Remove polydispersity from the parameter list. 38 76 39 <meta content="https://avatars1.githubusercontent.com/u/10882470?v=3&s=400" name="twitter:image:src" /><meta content="@github" name="twitter:site" /><meta content="summary" name="twitter:card" /><meta content="SasView/sasmodels" name="twitter:title" /><meta content="sasmodels - Package for calculation of small angle scattering models using OpenCL. Builds here: https://jenkins.esss.dk/sasview/view/Sasmodels-Builds/" name="twitter:description" /> 40 <meta content="https://avatars1.githubusercontent.com/u/10882470?v=3&s=400" property="og:image" /><meta content="GitHub" property="og:site_name" /><meta content="object" property="og:type" /><meta content="SasView/sasmodels" property="og:title" /><meta content="https://github.com/SasView/sasmodels" property="og:url" /><meta content="sasmodels - Package for calculation of small angle scattering models using OpenCL. Builds here: https://jenkins.esss.dk/sasview/view/Sasmodels-Builds/" property="og:description" /> 41 <meta name="browser-stats-url" content="https://api.github.com/_private/browser/stats"> 42 <meta name="browser-errors-url" content="https://api.github.com/_private/browser/errors"> 43 <link rel="assets" href="https://assets-cdn.github.com/"> 44 45 <meta name="pjax-timeout" content="1000"> 46 77 Note: operates in place 78 """ 79 # Bumps style parameter names 80 pd = pars.pop(key+".width", 0.0) 81 pd_n = pars.pop(key+".npts", 0) 82 if pd != 0.0 and pd_n != 0: 83 warnings.warn("parameter %s not polydisperse in sasview %s"%(key, name)) 84 pars.pop(key+".nsigmas", None) 85 pars.pop(key+".type", None) 86 return pars 47 87 48 <meta name="msapplication-TileImage" content="/windows-tile.png"> 49 <meta name="msapplication-TileColor" content="#ffffff"> 50 <meta name="selected-link" value="repo_source" data-pjax-transient> 88 def _revert_pars(pars, mapping): 89 """ 90 Rename the parameters and any associated polydispersity attributes. 91 """ 92 newpars = pars.copy() 51 93 52 <meta name="google-site-verification" content="KT5gs8h0wvaagLKAVWq8bbeNwnZZK1r1XQysX3xurLU"> 53 <meta name="google-site-verification" content="ZzhVyEFwb7w3e0-uOTltm8Jsck2F5StVihD0exw2fsA"> 54 <meta name="google-analytics" content="UA-3769691-2"> 94 for new, old in mapping.items(): 95 for pd, dot in PD_DOT: 96 if old and old+pd == new+dot: 97 continue 98 if new+pd in newpars: 99 if old is not None: 100 newpars[old+dot] = pars[new+pd] 101 del newpars[new+pd] 102 for k in list(newpars.keys()): 103 for pd, dot in PD_DOT[1:]: # skip "" => "" 104 if k.endswith(pd): 105 newpars[k[:-len(pd)]+dot] = newpars[k] 106 del newpars[k] 107 return newpars 55 108 56 <meta content="collector.githubapp.com" name="octolytics-host" /><meta content="github" name="octolytics-app-id" /><meta content="32FD15EB:517B:95519E0:56B61366" name="octolytics-dimension-request_id" /> 57 <meta content="/<user-name>/<repo-name>/blob/show" data-pjax-transient="true" name="analytics-location" /> 109 def revert_model(model_definition, pars): 110 """ 111 Convert model from new style parameter names to old style. 112 """ 113 mapping = model_definition.oldpars 114 oldname = model_definition.oldname 115 oldpars = _revert_pars(_unscale_sld(pars), mapping) 58 116 117 # Note: update compare.constrain_pars to match 118 name = model_definition.name 119 if name in MODELS_WITHOUT_SCALE: 120 if oldpars.pop('scale', 1.0) != 1.0: 121 warnings.warn("parameter scale not used in sasview %s"%name) 122 elif name in MODELS_WITHOUT_BACKGROUND: 123 if oldpars.pop('background', 0.0) != 0.0: 124 warnings.warn("parameter background not used in sasview %s"%name) 125 elif getattr(model_definition, 'category', None) == 'structure-factor': 126 if oldpars.pop('scale', 1.0) != 1.0: 127 warnings.warn("parameter scale not used in sasview %s"%name) 128 if oldpars.pop('background', 0.0) != 0.0: 129 warnings.warn("parameter background not used in sasview %s"%name) 130 elif name == 'pearl_necklace': 131 _remove_pd(oldpars, 'num_pearls', name) 132 _remove_pd(oldpars, 'thick_string', name) 133 elif name == 'rpa': 134 # convert scattering lengths from femtometers to centimeters 135 for p in "La", "Lb", "Lc", "Ld": 136 if p in oldpars: oldpars[p] *= 1e-13 59 137 138 return oldname, oldpars 60 139 61 <meta class="js-ga-set" name="dimension1" content="Logged Out"> 140 def constrain_new_to_old(model_definition, pars): 141 """ 142 Restrict parameter values to those that will match sasview. 143 """ 144 # Note: update convert.revert_model to match 145 name = model_definition.name 146 if name in MODELS_WITHOUT_SCALE: 147 pars['scale'] = 1 148 elif name in MODELS_WITHOUT_BACKGROUND: 149 pars['background'] = 0 150 elif name == 'pearl_necklace': 151 pars['string_thickness_pd_n'] = 0 152 pars['number_of_pearls_pd_n'] = 0 153 elif name == 'rpa': 154 pars['case_num'] = int(pars['case_num']) 155 elif getattr(model_definition, 'category', None) == 'structure-factor': 156 pars['scale'], pars['background'] = 1, 0 62 157 63 64 65 <meta name="hostname" content="github.com">66 <meta name="user-login" content="">67 68 <meta name="expected-hostname" content="github.com">69 70 <link rel="mask-icon" href="https://assets-cdn.github.com/pinned-octocat.svg" color="#4078c0">71 <link rel="icon" type="image/x-icon" href="https://assets-cdn.github.com/favicon.ico">72 73 <meta content="ed1699ee8f88e1fc0f2738f860d9b53cf2d34560" name="form-nonce" />74 75 <meta http-equiv="x-pjax-version" content="2330245d99bfcba85ea2b6d282c0cb53">76 77 78 <meta name="description" content="sasmodels - Package for calculation of small angle scattering models using OpenCL. Builds here: https://jenkins.esss.dk/sasview/view/Sasmodels-Builds/">79 <meta name="go-import" content="github.com/SasView/sasmodels git https://github.com/SasView/sasmodels.git">80 81 <meta content="10882470" name="octolytics-dimension-user_id" /><meta content="SasView" name="octolytics-dimension-user_login" /><meta content="30761174" name="octolytics-dimension-repository_id" /><meta content="SasView/sasmodels" name="octolytics-dimension-repository_nwo" /><meta content="true" name="octolytics-dimension-repository_public" /><meta content="false" name="octolytics-dimension-repository_is_fork" /><meta content="30761174" name="octolytics-dimension-repository_network_root_id" /><meta content="SasView/sasmodels" name="octolytics-dimension-repository_network_root_nwo" />82 <link href="https://github.com/SasView/sasmodels/commits/master.atom" rel="alternate" title="Recent Commits to sasmodels:master" type="application/atom+xml">83 84 85 <link rel="canonical" href="https://github.com/SasView/sasmodels/blob/master/sasmodels/convert.py" data-pjax-transient>86 </head>87 88 89 <body class="logged_out env-production windows vis-public page-blob">90 <a href="#start-of-content" tabindex="1" class="accessibility-aid js-skip-to-content">Skip to content</a>91 92 93 94 95 96 97 98 99 <div class="header header-logged-out" role="banner">100 <div class="container clearfix">101 102 <a class="header-logo-wordmark" href="https://github.com/" data-ga-click="(Logged out) Header, go to homepage, icon:logo-wordmark">103 <svg aria-hidden="true" class="octicon octicon-logo-github" height="28" role="img" version="1.1" viewBox="0 0 45 16" width="78"><path d="M8.64 5.19H4.88c-0.11 0-0.19 0.08-0.19 0.17v1.84c0 0.09 0.08 0.17 0.19 0.17h1.47v2.3s-0.33 0.11-1.25 0.11c-1.08 0-2.58-0.39-2.58-3.7s1.58-3.73 3.05-3.73c1.27 0 1.81 0.22 2.17 0.33 0.11 0.03 0.2-0.08 0.2-0.17l0.42-1.78c0-0.05-0.02-0.09-0.06-0.14-0.14-0.09-1.02-0.58-3.2-0.58C2.58 0 0 1.06 0 6.2s2.95 5.92 5.44 5.92c2.06 0 3.31-0.89 3.31-0.89 0.05-0.02 0.06-0.09 0.06-0.13V5.36c0-0.09-0.08-0.17-0.19-0.17h0.02zM27.7 0.44h-2.13c-0.09 0-0.17 0.08-0.17 0.17v4.09h-3.31V0.61c0-0.09-0.08-0.17-0.17-0.17h-2.13c-0.09 0-0.17 0.08-0.17 0.17v11.11c0 0.09 0.09 0.17 0.17 0.17h2.13c0.09 0 0.17-0.08 0.17-0.17V6.97h3.31l-0.02 4.75c0 0.09 0.08 0.17 0.17 0.17h2.13c0.09 0 0.17-0.08 0.17-0.17V0.61c0-0.09-0.08-0.17-0.17-0.17h0.02zM11.19 0.69c-0.77 0-1.38 0.61-1.38 1.38s0.61 1.38 1.38 1.38c0.75 0 1.36-0.61 1.36-1.38s-0.61-1.38-1.36-1.38z m1.22 3.55c0-0.09-0.08-0.17-0.17-0.17H10.11c-0.09 0-0.17 0.09-0.17 0.2 0 0 0 6.17 0 7.34 0 0.2 0.13 0.27 0.3 0.27 0 0 0.91 0 1.92 0 0.2 0 0.25-0.09 0.25-0.27 0-0.39 0-7.36 0-7.36v-0.02z m23.52-0.16h-2.09c-0.11 0-0.17 0.08-0.17 0.19v5.44s-0.55 0.39-1.3 0.39-0.97-0.34-0.97-1.09c0-0.73 0-4.75 0-4.75 0-0.09-0.08-0.17-0.17-0.17h-2.14c-0.09 0-0.17 0.08-0.17 0.17 0 0 0 2.91 0 5.11s1.23 2.75 2.92 2.75c1.39 0 2.52-0.77 2.52-0.77s0.05 0.39 0.08 0.45c0.02 0.05 0.09 0.09 0.16 0.09h1.34c0.11 0 0.17-0.08 0.17-0.17l0.02-7.47c0-0.09-0.08-0.17-0.19-0.17z m5.77-0.25c-1.2 0-2.02 0.53-2.02 0.53V0.59c0-0.09-0.08-0.17-0.17-0.17h-2.13c-0.09 0-0.17 0.08-0.17 0.17l-0.02 11.11c0 0.09 0.09 0.17 0.19 0.17h1.48c0.06 0 0.11-0.02 0.14-0.08 0.05-0.06 0.09-0.52 0.09-0.52s0.88 0.83 2.52 0.83c1.94 0 3.05-0.98 3.05-4.41s-1.77-3.88-2.97-3.88z m-0.83 6.27c-0.73-0.02-1.22-0.36-1.22-0.36V6.22s0.48-0.3 1.08-0.34c0.77-0.08 1.5 0.16 1.5 1.97 0 1.91-0.33 2.28-1.36 2.25z m-22.33-0.05c-0.09 0-0.33 0.05-0.58 0.05-0.78 0-1.05-0.36-1.05-0.83s0-3.13 0-3.13h1.59c0.09 0 0.16-0.08 0.16-0.19V4.25c0-0.09-0.08-0.17-0.16-0.17h-1.59V1.97c0-0.08-0.05-0.13-0.14-0.13H14.61c-0.09 0-0.14 0.05-0.14 0.13v2.17s-1.09 0.27-1.16 0.28c-0.08 0.02-0.13 0.09-0.13 0.17v1.36c0 0.11 0.08 0.19 0.17 0.19h1.11s0 1.44 0 3.28c0 2.44 1.7 2.69 2.86 2.69 0.53 0 1.17-0.17 1.27-0.22 0.06-0.02 0.09-0.09 0.09-0.16v-1.5c0-0.11-0.08-0.19-0.17-0.19h0.02z"></path></svg>104 </a>105 106 <div class="header-actions" role="navigation">107 <a class="btn btn-primary" href="/join?source=header-repo" data-ga-click="(Logged out) Header, clicked Sign up, text:sign-up">Sign up</a>108 <a class="btn" href="/login?return_to=%2FSasView%2Fsasmodels%2Fblob%2Fmaster%2Fsasmodels%2Fconvert.py" data-ga-click="(Logged out) Header, clicked Sign in, text:sign-in">Sign in</a>109 </div>110 111 <div class="site-search repo-scope js-site-search" role="search">112 <!-- </textarea> --><!-- '"` --><form accept-charset="UTF-8" action="/SasView/sasmodels/search" class="js-site-search-form" data-global-search-url="/search" data-repo-search-url="/SasView/sasmodels/search" method="get"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /></div>113 <label class="js-chromeless-input-container form-control">114 <div class="scope-badge">This repository</div>115 <input type="text"116 class="js-site-search-focus js-site-search-field is-clearable chromeless-input"117 data-hotkey="s"118 name="q"119 placeholder="Search"120 aria-label="Search this repository"121 data-global-scope-placeholder="Search GitHub"122 data-repo-scope-placeholder="Search"123 tabindex="1"124 autocapitalize="off">125 </label>126 </form>127 </div>128 129 <ul class="header-nav left" role="navigation">130 <li class="header-nav-item">131 <a class="header-nav-link" href="/explore" data-ga-click="(Logged out) Header, go to explore, text:explore">Explore</a>132 </li>133 <li class="header-nav-item">134 <a class="header-nav-link" href="/features" data-ga-click="(Logged out) Header, go to features, text:features">Features</a>135 </li>136 <li class="header-nav-item">137 <a class="header-nav-link" href="https://enterprise.github.com/" data-ga-click="(Logged out) Header, go to enterprise, text:enterprise">Enterprise</a>138 </li>139 <li class="header-nav-item">140 <a class="header-nav-link" href="/pricing" data-ga-click="(Logged out) Header, go to pricing, text:pricing">Pricing</a>141 </li>142 </ul>143 144 </div>145 </div>146 147 148 149 <div id="start-of-content" class="accessibility-aid"></div>150 151 <div id="js-flash-container">152 </div>153 154 155 <div role="main" class="main-content">156 <div itemscope itemtype="http://schema.org/WebPage">157 <div id="js-repo-pjax-container" class="context-loader-container js-repo-nav-next" data-pjax-container>158 159 <div class="pagehead repohead instapaper_ignore readability-menu experiment-repo-nav">160 <div class="container repohead-details-container">161 162 163 164 <ul class="pagehead-actions">165 166 <li>167 <a href="/login?return_to=%2FSasView%2Fsasmodels"168 class="btn btn-sm btn-with-count tooltipped tooltipped-n"169 aria-label="You must be signed in to watch a repository" rel="nofollow">170 <svg aria-hidden="true" class="octicon octicon-eye" height="16" role="img" version="1.1" viewBox="0 0 16 16" width="16"><path d="M8.06 2C3 2 0 8 0 8s3 6 8.06 6c4.94 0 7.94-6 7.94-6S13 2 8.06 2z m-0.06 10c-2.2 0-4-1.78-4-4 0-2.2 1.8-4 4-4 2.22 0 4 1.8 4 4 0 2.22-1.78 4-4 4z m2-4c0 1.11-0.89 2-2 2s-2-0.89-2-2 0.89-2 2-2 2 0.89 2 2z"></path></svg>171 Watch172 </a>173 <a class="social-count" href="/SasView/sasmodels/watchers">174 16175 </a>176 177 </li>178 179 <li>180 <a href="/login?return_to=%2FSasView%2Fsasmodels"181 class="btn btn-sm btn-with-count tooltipped tooltipped-n"182 aria-label="You must be signed in to star a repository" rel="nofollow">183 <svg aria-hidden="true" class="octicon octicon-star" height="16" role="img" version="1.1" viewBox="0 0 14 16" width="14"><path d="M14 6l-4.9-0.64L7 1 4.9 5.36 0 6l3.6 3.26L2.67 14l4.33-2.33 4.33 2.33L10.4 9.26 14 6z"></path></svg>184 Star185 </a>186 187 <a class="social-count js-social-count" href="/SasView/sasmodels/stargazers">188 0189 </a>190 191 </li>192 193 <li>194 <a href="/login?return_to=%2FSasView%2Fsasmodels"195 class="btn btn-sm btn-with-count tooltipped tooltipped-n"196 aria-label="You must be signed in to fork a repository" rel="nofollow">197 <svg aria-hidden="true" class="octicon octicon-repo-forked" height="16" role="img" version="1.1" viewBox="0 0 10 16" width="10"><path d="M8 1c-1.11 0-2 0.89-2 2 0 0.73 0.41 1.38 1 1.72v1.28L5 8 3 6v-1.28c0.59-0.34 1-0.98 1-1.72 0-1.11-0.89-2-2-2S0 1.89 0 3c0 0.73 0.41 1.38 1 1.72v1.78l3 3v1.78c-0.59 0.34-1 0.98-1 1.72 0 1.11 0.89 2 2 2s2-0.89 2-2c0-0.73-0.41-1.38-1-1.72V9.5l3-3V4.72c0.59-0.34 1-0.98 1-1.72 0-1.11-0.89-2-2-2zM2 4.2c-0.66 0-1.2-0.55-1.2-1.2s0.55-1.2 1.2-1.2 1.2 0.55 1.2 1.2-0.55 1.2-1.2 1.2z m3 10c-0.66 0-1.2-0.55-1.2-1.2s0.55-1.2 1.2-1.2 1.2 0.55 1.2 1.2-0.55 1.2-1.2 1.2z m3-10c-0.66 0-1.2-0.55-1.2-1.2s0.55-1.2 1.2-1.2 1.2 0.55 1.2 1.2-0.55 1.2-1.2 1.2z"></path></svg>198 Fork199 </a>200 201 <a href="/SasView/sasmodels/network" class="social-count">202 0203 </a>204 </li>205 </ul>206 207 <h1 itemscope itemtype="http://data-vocabulary.org/Breadcrumb" class="entry-title public ">208 <svg aria-hidden="true" class="octicon octicon-repo" height="16" role="img" version="1.1" viewBox="0 0 12 16" width="12"><path d="M4 9h-1v-1h1v1z m0-3h-1v1h1v-1z m0-2h-1v1h1v-1z m0-2h-1v1h1v-1z m8-1v12c0 0.55-0.45 1-1 1H6v2l-1.5-1.5-1.5 1.5V14H1c-0.55 0-1-0.45-1-1V1C0 0.45 0.45 0 1 0h10c0.55 0 1 0.45 1 1z m-1 10H1v2h2v-1h3v1h5V11z m0-10H2v9h9V1z"></path></svg>209 <span class="author"><a href="/SasView" class="url fn" itemprop="url" rel="author"><span itemprop="title">SasView</span></a></span><!--210 --><span class="path-divider">/</span><!--211 --><strong><a href="/SasView/sasmodels" data-pjax="#js-repo-pjax-container">sasmodels</a></strong>212 213 <span class="page-context-loader">214 <img alt="" height="16" src="https://assets-cdn.github.com/images/spinners/octocat-spinner-32.gif" width="16" />215 </span>216 217 </h1>218 219 </div>220 <div class="container">221 222 <nav class="reponav js-repo-nav js-sidenav-container-pjax js-octicon-loaders"223 role="navigation"224 data-pjax="#js-repo-pjax-container">225 226 <a href="/SasView/sasmodels" aria-label="Code" aria-selected="true" class="js-selected-navigation-item selected reponav-item" data-hotkey="g c" data-selected-links="repo_source repo_downloads repo_commits repo_releases repo_tags repo_branches /SasView/sasmodels">227 <svg aria-hidden="true" class="octicon octicon-code" height="16" role="img" version="1.1" viewBox="0 0 14 16" width="14"><path d="M9.5 3l-1.5 1.5 3.5 3.5L8 11.5l1.5 1.5 4.5-5L9.5 3zM4.5 3L0 8l4.5 5 1.5-1.5L2.5 8l3.5-3.5L4.5 3z"></path></svg>228 Code229 </a>230 231 <a href="/SasView/sasmodels/pulls" class="js-selected-navigation-item reponav-item" data-hotkey="g p" data-selected-links="repo_pulls /SasView/sasmodels/pulls">232 <svg aria-hidden="true" class="octicon octicon-git-pull-request" height="16" role="img" version="1.1" viewBox="0 0 12 16" width="12"><path d="M11 11.28c0-1.73 0-6.28 0-6.28-0.03-0.78-0.34-1.47-0.94-2.06s-1.28-0.91-2.06-0.94c0 0-1.02 0-1 0V0L4 3l3 3V4h1c0.27 0.02 0.48 0.11 0.69 0.31s0.3 0.42 0.31 0.69v6.28c-0.59 0.34-1 0.98-1 1.72 0 1.11 0.89 2 2 2s2-0.89 2-2c0-0.73-0.41-1.38-1-1.72z m-1 2.92c-0.66 0-1.2-0.55-1.2-1.2s0.55-1.2 1.2-1.2 1.2 0.55 1.2 1.2-0.55 1.2-1.2 1.2zM4 3c0-1.11-0.89-2-2-2S0 1.89 0 3c0 0.73 0.41 1.38 1 1.72 0 1.55 0 5.56 0 6.56-0.59 0.34-1 0.98-1 1.72 0 1.11 0.89 2 2 2s2-0.89 2-2c0-0.73-0.41-1.38-1-1.72V4.72c0.59-0.34 1-0.98 1-1.72z m-0.8 10c0 0.66-0.55 1.2-1.2 1.2s-1.2-0.55-1.2-1.2 0.55-1.2 1.2-1.2 1.2 0.55 1.2 1.2z m-1.2-8.8c-0.66 0-1.2-0.55-1.2-1.2s0.55-1.2 1.2-1.2 1.2 0.55 1.2 1.2-0.55 1.2-1.2 1.2z"></path></svg>233 Pull requests234 <span class="counter">0</span>235 </a>236 237 <a href="/SasView/sasmodels/pulse" class="js-selected-navigation-item reponav-item" data-selected-links="pulse /SasView/sasmodels/pulse">238 <svg aria-hidden="true" class="octicon octicon-pulse" height="16" role="img" version="1.1" viewBox="0 0 14 16" width="14"><path d="M11.5 8L8.8 5.4 6.6 8.5 5.5 1.6 2.38 8H0V10h3.6L4.5 8.2l0.9 5.4L9 8.5l1.6 1.5H14V8H11.5z"></path></svg>239 Pulse240 </a>241 <a href="/SasView/sasmodels/graphs" class="js-selected-navigation-item reponav-item" data-selected-links="repo_graphs repo_contributors /SasView/sasmodels/graphs">242 <svg aria-hidden="true" class="octicon octicon-graph" height="16" role="img" version="1.1" viewBox="0 0 16 16" width="16"><path d="M16 14v1H0V0h1v14h15z m-11-1H3V8h2v5z m4 0H7V3h2v10z m4 0H11V6h2v7z"></path></svg>243 Graphs244 </a>245 246 </nav>247 248 </div>249 </div>250 251 <div class="container new-discussion-timeline experiment-repo-nav">252 <div class="repository-content">253 254 255 256 <a href="/SasView/sasmodels/blob/d5e650da432c58f8cd7c4d86e8ecb26828e17a21/sasmodels/convert.py" class="hidden js-permalink-shortcut" data-hotkey="y">Permalink</a>257 258 <!-- blob contrib key: blob_contributors:v21:db8856a43e364dee3a304855aa1d4b41 -->259 260 <div class="file-navigation js-zeroclipboard-container">261 262 <div class="select-menu js-menu-container js-select-menu left">263 <button class="btn btn-sm select-menu-button js-menu-target css-truncate" data-hotkey="w"264 title="master"265 type="button" aria-label="Switch branches or tags" tabindex="0" aria-haspopup="true">266 <i>Branch:</i>267 <span class="js-select-button css-truncate-target">master</span>268 </button>269 270 <div class="select-menu-modal-holder js-menu-content js-navigation-container" data-pjax aria-hidden="true">271 272 <div class="select-menu-modal">273 <div class="select-menu-header">274 <svg aria-label="Close" class="octicon octicon-x js-menu-close" height="16" role="img" version="1.1" viewBox="0 0 12 16" width="12"><path d="M7.48 8l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75-1.48-1.48 3.75-3.75L0.77 4.25l1.48-1.48 3.75 3.75 3.75-3.75 1.48 1.48-3.75 3.75z"></path></svg>275 <span class="select-menu-title">Switch branches/tags</span>276 </div>277 278 <div class="select-menu-filters">279 <div class="select-menu-text-filter">280 <input type="text" aria-label="Filter branches/tags" id="context-commitish-filter-field" class="js-filterable-field js-navigation-enable" placeholder="Filter branches/tags">281 </div>282 <div class="select-menu-tabs">283 <ul>284 <li class="select-menu-tab">285 <a href="#" data-tab-filter="branches" data-filter-placeholder="Filter branches/tags" class="js-select-menu-tab" role="tab">Branches</a>286 </li>287 <li class="select-menu-tab">288 <a href="#" data-tab-filter="tags" data-filter-placeholder="Find a tagâŠ" class="js-select-menu-tab" role="tab">Tags</a>289 </li>290 </ul>291 </div>292 </div>293 294 <div class="select-menu-list select-menu-tab-bucket js-select-menu-tab-bucket" data-tab-filter="branches" role="menu">295 296 <div data-filterable-for="context-commitish-filter-field" data-filterable-type="substring">297 298 299 <a class="select-menu-item js-navigation-item js-navigation-open "300 href="/SasView/sasmodels/blob/develop_ric/sasmodels/convert.py"301 data-name="develop_ric"302 data-skip-pjax="true"303 rel="nofollow">304 <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" role="img" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5L4 13 0 9l1.5-1.5 2.5 2.5 6.5-6.5 1.5 1.5z"></path></svg>305 <span class="select-menu-item-text css-truncate-target" title="develop_ric">306 develop_ric307 </span>308 </a>309 <a class="select-menu-item js-navigation-item js-navigation-open "310 href="/SasView/sasmodels/blob/gh-pages/sasmodels/convert.py"311 data-name="gh-pages"312 data-skip-pjax="true"313 rel="nofollow">314 <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" role="img" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5L4 13 0 9l1.5-1.5 2.5 2.5 6.5-6.5 1.5 1.5z"></path></svg>315 <span class="select-menu-item-text css-truncate-target" title="gh-pages">316 gh-pages317 </span>318 </a>319 <a class="select-menu-item js-navigation-item js-navigation-open selected"320 href="/SasView/sasmodels/blob/master/sasmodels/convert.py"321 data-name="master"322 data-skip-pjax="true"323 rel="nofollow">324 <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" role="img" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5L4 13 0 9l1.5-1.5 2.5 2.5 6.5-6.5 1.5 1.5z"></path></svg>325 <span class="select-menu-item-text css-truncate-target" title="master">326 master327 </span>328 </a>329 </div>330 331 <div class="select-menu-no-results">Nothing to show</div>332 </div>333 334 <div class="select-menu-list select-menu-tab-bucket js-select-menu-tab-bucket" data-tab-filter="tags">335 <div data-filterable-for="context-commitish-filter-field" data-filterable-type="substring">336 337 338 </div>339 340 <div class="select-menu-no-results">Nothing to show</div>341 </div>342 343 </div>344 </div>345 </div>346 347 <div class="btn-group right">348 <a href="/SasView/sasmodels/find/master"349 class="js-show-file-finder btn btn-sm"350 data-pjax351 data-hotkey="t">352 Find file353 </a>354 <button aria-label="Copy file path to clipboard" class="js-zeroclipboard btn btn-sm zeroclipboard-button tooltipped tooltipped-s" data-copied-hint="Copied!" type="button">Copy path</button>355 </div>356 <div class="breadcrumb js-zeroclipboard-target">357 <span class="repo-root js-repo-root"><span itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="/SasView/sasmodels" class="" data-branch="master" data-pjax="true" itemscope="url"><span itemprop="title">sasmodels</span></a></span></span><span class="separator">/</span><span itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="/SasView/sasmodels/tree/master/sasmodels" class="" data-branch="master" data-pjax="true" itemscope="url"><span itemprop="title">sasmodels</span></a></span><span class="separator">/</span><strong class="final-path">convert.py</strong>358 </div>359 </div>360 361 <include-fragment class="commit-tease" src="/SasView/sasmodels/contributors/master/sasmodels/convert.py">362 <div>363 Fetching contributors…364 </div>365 366 <div class="commit-tease-contributors">367 <img alt="" class="loader-loading left" height="16" src="https://assets-cdn.github.com/images/spinners/octocat-spinner-32-EAF2F5.gif" width="16" />368 <span class="loader-error">Cannot retrieve contributors at this time</span>369 </div>370 </include-fragment>371 <div class="file">372 <div class="file-header">373 <div class="file-actions">374 375 <div class="btn-group">376 <a href="/SasView/sasmodels/raw/master/sasmodels/convert.py" class="btn btn-sm " id="raw-url">Raw</a>377 <a href="/SasView/sasmodels/blame/master/sasmodels/convert.py" class="btn btn-sm js-update-url-with-hash">Blame</a>378 <a href="/SasView/sasmodels/commits/master/sasmodels/convert.py" class="btn btn-sm " rel="nofollow">History</a>379 </div>380 381 <a class="btn-octicon tooltipped tooltipped-nw"382 href="https://windows.github.com"383 aria-label="Open this file in GitHub Desktop"384 data-ga-click="Repository, open with desktop, type:windows">385 <svg aria-hidden="true" class="octicon octicon-device-desktop" height="16" role="img" version="1.1" viewBox="0 0 16 16" width="16"><path d="M15 2H1c-0.55 0-1 0.45-1 1v9c0 0.55 0.45 1 1 1h5.34c-0.25 0.61-0.86 1.39-2.34 2h8c-1.48-0.61-2.09-1.39-2.34-2h5.34c0.55 0 1-0.45 1-1V3c0-0.55-0.45-1-1-1z m0 9H1V3h14v8z"></path></svg>386 </a>387 388 <button type="button" class="btn-octicon disabled tooltipped tooltipped-nw"389 aria-label="You must be signed in to make or propose changes">390 <svg aria-hidden="true" class="octicon octicon-pencil" height="16" role="img" version="1.1" viewBox="0 0 14 16" width="14"><path d="M0 12v3h3l8-8-3-3L0 12z m3 2H1V12h1v1h1v1z m10.3-9.3l-1.3 1.3-3-3 1.3-1.3c0.39-0.39 1.02-0.39 1.41 0l1.59 1.59c0.39 0.39 0.39 1.02 0 1.41z"></path></svg>391 </button>392 <button type="button" class="btn-octicon btn-octicon-danger disabled tooltipped tooltipped-nw"393 aria-label="You must be signed in to make or propose changes">394 <svg aria-hidden="true" class="octicon octicon-trashcan" height="16" role="img" version="1.1" viewBox="0 0 12 16" width="12"><path d="M10 2H8c0-0.55-0.45-1-1-1H4c-0.55 0-1 0.45-1 1H1c-0.55 0-1 0.45-1 1v1c0 0.55 0.45 1 1 1v9c0 0.55 0.45 1 1 1h7c0.55 0 1-0.45 1-1V5c0.55 0 1-0.45 1-1v-1c0-0.55-0.45-1-1-1z m-1 12H2V5h1v8h1V5h1v8h1V5h1v8h1V5h1v9z m1-10H1v-1h9v1z"></path></svg>395 </button>396 </div>397 398 <div class="file-info">399 157 lines (141 sloc)400 <span class="file-info-divider"></span>401 5.04 KB402 </div>403 </div>404 405 406 407 <div class="blob-wrapper data type-python">408 <table class="highlight tab-size js-file-line-container" data-tab-size="8">409 <tr>410 <td id="L1" class="blob-num js-line-number" data-line-number="1"></td>411 <td id="LC1" class="blob-code blob-code-inner js-file-line"><span class="pl-s"><span class="pl-pds">"""</span></span></td>412 </tr>413 <tr>414 <td id="L2" class="blob-num js-line-number" data-line-number="2"></td>415 <td id="LC2" class="blob-code blob-code-inner js-file-line"><span class="pl-s">Convert models to and from sasview.</span></td>416 </tr>417 <tr>418 <td id="L3" class="blob-num js-line-number" data-line-number="3"></td>419 <td id="LC3" class="blob-code blob-code-inner js-file-line"><span class="pl-s"><span class="pl-pds">"""</span></span></td>420 </tr>421 <tr>422 <td id="L4" class="blob-num js-line-number" data-line-number="4"></td>423 <td id="LC4" class="blob-code blob-code-inner js-file-line"><span class="pl-k">import</span> warnings</td>424 </tr>425 <tr>426 <td id="L5" class="blob-num js-line-number" data-line-number="5"></td>427 <td id="LC5" class="blob-code blob-code-inner js-file-line">428 </td>429 </tr>430 <tr>431 <td id="L6" class="blob-num js-line-number" data-line-number="6"></td>432 <td id="LC6" class="blob-code blob-code-inner js-file-line"><span class="pl-c"># List of models which SasView versions don't contain the explicit 'scale' argument.</span></td>433 </tr>434 <tr>435 <td id="L7" class="blob-num js-line-number" data-line-number="7"></td>436 <td id="LC7" class="blob-code blob-code-inner js-file-line"><span class="pl-c"># When converting such a model, please update this list.</span></td>437 </tr>438 <tr>439 <td id="L8" class="blob-num js-line-number" data-line-number="8"></td>440 <td id="LC8" class="blob-code blob-code-inner js-file-line"><span class="pl-c1">MODELS_WITHOUT_SCALE</span> <span class="pl-k">=</span> [</td>441 </tr>442 <tr>443 <td id="L9" class="blob-num js-line-number" data-line-number="9"></td>444 <td id="LC9" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">'</span>teubner_strey<span class="pl-pds">'</span></span>,</td>445 </tr>446 <tr>447 <td id="L10" class="blob-num js-line-number" data-line-number="10"></td>448 <td id="LC10" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">'</span>broad_peak<span class="pl-pds">'</span></span>,</td>449 </tr>450 <tr>451 <td id="L11" class="blob-num js-line-number" data-line-number="11"></td>452 <td id="LC11" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">'</span>two_lorentzian<span class="pl-pds">'</span></span>,</td>453 </tr>454 <tr>455 <td id="L12" class="blob-num js-line-number" data-line-number="12"></td>456 <td id="LC12" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">'</span>gel_fit<span class="pl-pds">'</span></span>,</td>457 </tr>458 <tr>459 <td id="L13" class="blob-num js-line-number" data-line-number="13"></td>460 <td id="LC13" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">'</span>gauss_lorentz_gel<span class="pl-pds">'</span></span>,</td>461 </tr>462 <tr>463 <td id="L14" class="blob-num js-line-number" data-line-number="14"></td>464 <td id="LC14" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">'</span>be_polyelectrolyte<span class="pl-pds">'</span></span>,</td>465 </tr>466 <tr>467 <td id="L15" class="blob-num js-line-number" data-line-number="15"></td>468 <td id="LC15" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">'</span>correlation_length<span class="pl-pds">'</span></span>,</td>469 </tr>470 <tr>471 <td id="L16" class="blob-num js-line-number" data-line-number="16"></td>472 <td id="LC16" class="blob-code blob-code-inner js-file-line">]</td>473 </tr>474 <tr>475 <td id="L17" class="blob-num js-line-number" data-line-number="17"></td>476 <td id="LC17" class="blob-code blob-code-inner js-file-line">477 </td>478 </tr>479 <tr>480 <td id="L18" class="blob-num js-line-number" data-line-number="18"></td>481 <td id="LC18" class="blob-code blob-code-inner js-file-line"><span class="pl-c"># List of models which SasView versions don't contain the explicit 'background' argument.</span></td>482 </tr>483 <tr>484 <td id="L19" class="blob-num js-line-number" data-line-number="19"></td>485 <td id="LC19" class="blob-code blob-code-inner js-file-line"><span class="pl-c"># When converting such a model, please update this list.</span></td>486 </tr>487 <tr>488 <td id="L20" class="blob-num js-line-number" data-line-number="20"></td>489 <td id="LC20" class="blob-code blob-code-inner js-file-line"><span class="pl-c1">MODELS_WITHOUT_BACKGROUND</span> <span class="pl-k">=</span> [</td>490 </tr>491 <tr>492 <td id="L21" class="blob-num js-line-number" data-line-number="21"></td>493 <td id="LC21" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">'</span>guinier<span class="pl-pds">'</span></span>,</td>494 </tr>495 <tr>496 <td id="L22" class="blob-num js-line-number" data-line-number="22"></td>497 <td id="LC22" class="blob-code blob-code-inner js-file-line">]</td>498 </tr>499 <tr>500 <td id="L23" class="blob-num js-line-number" data-line-number="23"></td>501 <td id="LC23" class="blob-code blob-code-inner js-file-line">502 </td>503 </tr>504 <tr>505 <td id="L24" class="blob-num js-line-number" data-line-number="24"></td>506 <td id="LC24" class="blob-code blob-code-inner js-file-line"><span class="pl-c1">PD_DOT</span> <span class="pl-k">=</span> [</td>507 </tr>508 <tr>509 <td id="L25" class="blob-num js-line-number" data-line-number="25"></td>510 <td id="LC25" class="blob-code blob-code-inner js-file-line"> (<span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>),</td>511 </tr>512 <tr>513 <td id="L26" class="blob-num js-line-number" data-line-number="26"></td>514 <td id="LC26" class="blob-code blob-code-inner js-file-line"> (<span class="pl-s"><span class="pl-pds">"</span>_pd<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>.width<span class="pl-pds">"</span></span>),</td>515 </tr>516 <tr>517 <td id="L27" class="blob-num js-line-number" data-line-number="27"></td>518 <td id="LC27" class="blob-code blob-code-inner js-file-line"> (<span class="pl-s"><span class="pl-pds">"</span>_pd_n<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>.npts<span class="pl-pds">"</span></span>),</td>519 </tr>520 <tr>521 <td id="L28" class="blob-num js-line-number" data-line-number="28"></td>522 <td id="LC28" class="blob-code blob-code-inner js-file-line"> (<span class="pl-s"><span class="pl-pds">"</span>_pd_nsigma<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>.nsigmas<span class="pl-pds">"</span></span>),</td>523 </tr>524 <tr>525 <td id="L29" class="blob-num js-line-number" data-line-number="29"></td>526 <td id="LC29" class="blob-code blob-code-inner js-file-line"> (<span class="pl-s"><span class="pl-pds">"</span>_pd_type<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>.type<span class="pl-pds">"</span></span>),</td>527 </tr>528 <tr>529 <td id="L30" class="blob-num js-line-number" data-line-number="30"></td>530 <td id="LC30" class="blob-code blob-code-inner js-file-line"> ]</td>531 </tr>532 <tr>533 <td id="L31" class="blob-num js-line-number" data-line-number="31"></td>534 <td id="LC31" class="blob-code blob-code-inner js-file-line"><span class="pl-k">def</span> <span class="pl-en">_convert_pars</span>(<span class="pl-smi">pars</span>, <span class="pl-smi">mapping</span>):</td>535 </tr>536 <tr>537 <td id="L32" class="blob-num js-line-number" data-line-number="32"></td>538 <td id="LC32" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">"""</span></span></td>539 </tr>540 <tr>541 <td id="L33" class="blob-num js-line-number" data-line-number="33"></td>542 <td id="LC33" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> Rename the parameters and any associated polydispersity attributes.</span></td>543 </tr>544 <tr>545 <td id="L34" class="blob-num js-line-number" data-line-number="34"></td>546 <td id="LC34" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> <span class="pl-pds">"""</span></span></td>547 </tr>548 <tr>549 <td id="L35" class="blob-num js-line-number" data-line-number="35"></td>550 <td id="LC35" class="blob-code blob-code-inner js-file-line"> newpars <span class="pl-k">=</span> pars.copy()</td>551 </tr>552 <tr>553 <td id="L36" class="blob-num js-line-number" data-line-number="36"></td>554 <td id="LC36" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">for</span> new, old <span class="pl-k">in</span> mapping.items():</td>555 </tr>556 <tr>557 <td id="L37" class="blob-num js-line-number" data-line-number="37"></td>558 <td id="LC37" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">if</span> old <span class="pl-k">==</span> new: <span class="pl-k">continue</span></td>559 </tr>560 <tr>561 <td id="L38" class="blob-num js-line-number" data-line-number="38"></td>562 <td id="LC38" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">for</span> pd, dot <span class="pl-k">in</span> <span class="pl-c1">PD_DOT</span>:</td>563 </tr>564 <tr>565 <td id="L39" class="blob-num js-line-number" data-line-number="39"></td>566 <td id="LC39" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">if</span> old<span class="pl-k">+</span>dot <span class="pl-k">in</span> newpars:</td>567 </tr>568 <tr>569 <td id="L40" class="blob-num js-line-number" data-line-number="40"></td>570 <td id="LC40" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">if</span> new <span class="pl-k">is</span> <span class="pl-k">not</span> <span class="pl-c1">None</span>:</td>571 </tr>572 <tr>573 <td id="L41" class="blob-num js-line-number" data-line-number="41"></td>574 <td id="LC41" class="blob-code blob-code-inner js-file-line"> newpars[new<span class="pl-k">+</span>pd] <span class="pl-k">=</span> pars[old<span class="pl-k">+</span>dot]</td>575 </tr>576 <tr>577 <td id="L42" class="blob-num js-line-number" data-line-number="42"></td>578 <td id="LC42" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">del</span> newpars[old<span class="pl-k">+</span>dot]</td>579 </tr>580 <tr>581 <td id="L43" class="blob-num js-line-number" data-line-number="43"></td>582 <td id="LC43" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">return</span> newpars</td>583 </tr>584 <tr>585 <td id="L44" class="blob-num js-line-number" data-line-number="44"></td>586 <td id="LC44" class="blob-code blob-code-inner js-file-line">587 </td>588 </tr>589 <tr>590 <td id="L45" class="blob-num js-line-number" data-line-number="45"></td>591 <td id="LC45" class="blob-code blob-code-inner js-file-line"><span class="pl-k">def</span> <span class="pl-en">_rescale_sld</span>(<span class="pl-smi">pars</span>):</td>592 </tr>593 <tr>594 <td id="L46" class="blob-num js-line-number" data-line-number="46"></td>595 <td id="LC46" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">"""</span></span></td>596 </tr>597 <tr>598 <td id="L47" class="blob-num js-line-number" data-line-number="47"></td>599 <td id="LC47" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> rescale all sld parameters in the new model definition by 1e6 so the</span></td>600 </tr>601 <tr>602 <td id="L48" class="blob-num js-line-number" data-line-number="48"></td>603 <td id="LC48" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> numbers are nicer. Relies on the fact that all sld parameters in the</span></td>604 </tr>605 <tr>606 <td id="L49" class="blob-num js-line-number" data-line-number="49"></td>607 <td id="LC49" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> new model definition end with sld.</span></td>608 </tr>609 <tr>610 <td id="L50" class="blob-num js-line-number" data-line-number="50"></td>611 <td id="LC50" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> <span class="pl-pds">"""</span></span></td>612 </tr>613 <tr>614 <td id="L51" class="blob-num js-line-number" data-line-number="51"></td>615 <td id="LC51" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">return</span> <span class="pl-c1">dict</span>((p, (v<span class="pl-k">*</span><span class="pl-c1">1e6</span> <span class="pl-k">if</span> p.endswith(<span class="pl-s"><span class="pl-pds">'</span>sld<span class="pl-pds">'</span></span>) <span class="pl-k">else</span> v))</td>616 </tr>617 <tr>618 <td id="L52" class="blob-num js-line-number" data-line-number="52"></td>619 <td id="LC52" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">for</span> p, v <span class="pl-k">in</span> pars.items())</td>620 </tr>621 <tr>622 <td id="L53" class="blob-num js-line-number" data-line-number="53"></td>623 <td id="LC53" class="blob-code blob-code-inner js-file-line">624 </td>625 </tr>626 <tr>627 <td id="L54" class="blob-num js-line-number" data-line-number="54"></td>628 <td id="LC54" class="blob-code blob-code-inner js-file-line"><span class="pl-k">def</span> <span class="pl-en">convert_model</span>(<span class="pl-smi">name</span>, <span class="pl-smi">pars</span>):</td>629 </tr>630 <tr>631 <td id="L55" class="blob-num js-line-number" data-line-number="55"></td>632 <td id="LC55" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">"""</span></span></td>633 </tr>634 <tr>635 <td id="L56" class="blob-num js-line-number" data-line-number="56"></td>636 <td id="LC56" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> Convert model from old style parameter names to new style.</span></td>637 </tr>638 <tr>639 <td id="L57" class="blob-num js-line-number" data-line-number="57"></td>640 <td id="LC57" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> <span class="pl-pds">"""</span></span></td>641 </tr>642 <tr>643 <td id="L58" class="blob-num js-line-number" data-line-number="58"></td>644 <td id="LC58" class="blob-code blob-code-inner js-file-line"> _, _ <span class="pl-k">=</span> name, pars <span class="pl-c"># lint</span></td>645 </tr>646 <tr>647 <td id="L59" class="blob-num js-line-number" data-line-number="59"></td>648 <td id="LC59" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">raise</span> <span class="pl-c1">NotImplementedError</span></td>649 </tr>650 <tr>651 <td id="L60" class="blob-num js-line-number" data-line-number="60"></td>652 <td id="LC60" class="blob-code blob-code-inner js-file-line"> <span class="pl-c"># need to load all new models in order to determine old=>new</span></td>653 </tr>654 <tr>655 <td id="L61" class="blob-num js-line-number" data-line-number="61"></td>656 <td id="LC61" class="blob-code blob-code-inner js-file-line"> <span class="pl-c"># model name mapping</span></td>657 </tr>658 <tr>659 <td id="L62" class="blob-num js-line-number" data-line-number="62"></td>660 <td id="LC62" class="blob-code blob-code-inner js-file-line">661 </td>662 </tr>663 <tr>664 <td id="L63" class="blob-num js-line-number" data-line-number="63"></td>665 <td id="LC63" class="blob-code blob-code-inner js-file-line"><span class="pl-k">def</span> <span class="pl-en">_unscale_sld</span>(<span class="pl-smi">pars</span>):</td>666 </tr>667 <tr>668 <td id="L64" class="blob-num js-line-number" data-line-number="64"></td>669 <td id="LC64" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">"""</span></span></td>670 </tr>671 <tr>672 <td id="L65" class="blob-num js-line-number" data-line-number="65"></td>673 <td id="LC65" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> rescale all sld parameters in the new model definition by 1e6 so the</span></td>674 </tr>675 <tr>676 <td id="L66" class="blob-num js-line-number" data-line-number="66"></td>677 <td id="LC66" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> numbers are nicer. Relies on the fact that all sld parameters in the</span></td>678 </tr>679 <tr>680 <td id="L67" class="blob-num js-line-number" data-line-number="67"></td>681 <td id="LC67" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> new model definition end with sld.</span></td>682 </tr>683 <tr>684 <td id="L68" class="blob-num js-line-number" data-line-number="68"></td>685 <td id="LC68" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> <span class="pl-pds">"""</span></span></td>686 </tr>687 <tr>688 <td id="L69" class="blob-num js-line-number" data-line-number="69"></td>689 <td id="LC69" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">return</span> <span class="pl-c1">dict</span>((p, (v<span class="pl-k">*</span><span class="pl-c1">1e-6</span> <span class="pl-k">if</span> p.endswith(<span class="pl-s"><span class="pl-pds">'</span>sld<span class="pl-pds">'</span></span>) <span class="pl-k">else</span> v))</td>690 </tr>691 <tr>692 <td id="L70" class="blob-num js-line-number" data-line-number="70"></td>693 <td id="LC70" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">for</span> p, v <span class="pl-k">in</span> pars.items())</td>694 </tr>695 <tr>696 <td id="L71" class="blob-num js-line-number" data-line-number="71"></td>697 <td id="LC71" class="blob-code blob-code-inner js-file-line">698 </td>699 </tr>700 <tr>701 <td id="L72" class="blob-num js-line-number" data-line-number="72"></td>702 <td id="LC72" class="blob-code blob-code-inner js-file-line"><span class="pl-k">def</span> <span class="pl-en">_remove_pd</span>(<span class="pl-smi">pars</span>, <span class="pl-smi">key</span>, <span class="pl-smi">name</span>):</td>703 </tr>704 <tr>705 <td id="L73" class="blob-num js-line-number" data-line-number="73"></td>706 <td id="LC73" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">"""</span></span></td>707 </tr>708 <tr>709 <td id="L74" class="blob-num js-line-number" data-line-number="74"></td>710 <td id="LC74" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> Remove polydispersity from the parameter list.</span></td>711 </tr>712 <tr>713 <td id="L75" class="blob-num js-line-number" data-line-number="75"></td>714 <td id="LC75" class="blob-code blob-code-inner js-file-line"><span class="pl-s"></span></td>715 </tr>716 <tr>717 <td id="L76" class="blob-num js-line-number" data-line-number="76"></td>718 <td id="LC76" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> Note: operates in place</span></td>719 </tr>720 <tr>721 <td id="L77" class="blob-num js-line-number" data-line-number="77"></td>722 <td id="LC77" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> <span class="pl-pds">"""</span></span></td>723 </tr>724 <tr>725 <td id="L78" class="blob-num js-line-number" data-line-number="78"></td>726 <td id="LC78" class="blob-code blob-code-inner js-file-line"> <span class="pl-c"># Bumps style parameter names</span></td>727 </tr>728 <tr>729 <td id="L79" class="blob-num js-line-number" data-line-number="79"></td>730 <td id="LC79" class="blob-code blob-code-inner js-file-line"> pd <span class="pl-k">=</span> pars.pop(key<span class="pl-k">+</span><span class="pl-s"><span class="pl-pds">"</span>.width<span class="pl-pds">"</span></span>, <span class="pl-c1">0.0</span>)</td>731 </tr>732 <tr>733 <td id="L80" class="blob-num js-line-number" data-line-number="80"></td>734 <td id="LC80" class="blob-code blob-code-inner js-file-line"> pd_n <span class="pl-k">=</span> pars.pop(key<span class="pl-k">+</span><span class="pl-s"><span class="pl-pds">"</span>.npts<span class="pl-pds">"</span></span>, <span class="pl-c1">0</span>)</td>735 </tr>736 <tr>737 <td id="L81" class="blob-num js-line-number" data-line-number="81"></td>738 <td id="LC81" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">if</span> pd <span class="pl-k">!=</span> <span class="pl-c1">0.0</span> <span class="pl-k">and</span> pd_n <span class="pl-k">!=</span> <span class="pl-c1">0</span>:</td>739 </tr>740 <tr>741 <td id="L82" class="blob-num js-line-number" data-line-number="82"></td>742 <td id="LC82" class="blob-code blob-code-inner js-file-line"> warnings.warn(<span class="pl-s"><span class="pl-pds">"</span>parameter <span class="pl-c1">%s</span> not polydisperse in sasview <span class="pl-c1">%s</span><span class="pl-pds">"</span></span><span class="pl-k">%</span>(key, name))</td>743 </tr>744 <tr>745 <td id="L83" class="blob-num js-line-number" data-line-number="83"></td>746 <td id="LC83" class="blob-code blob-code-inner js-file-line"> pars.pop(key<span class="pl-k">+</span><span class="pl-s"><span class="pl-pds">"</span>.nsigmas<span class="pl-pds">"</span></span>, <span class="pl-c1">None</span>)</td>747 </tr>748 <tr>749 <td id="L84" class="blob-num js-line-number" data-line-number="84"></td>750 <td id="LC84" class="blob-code blob-code-inner js-file-line"> pars.pop(key<span class="pl-k">+</span><span class="pl-s"><span class="pl-pds">"</span>.type<span class="pl-pds">"</span></span>, <span class="pl-c1">None</span>)</td>751 </tr>752 <tr>753 <td id="L85" class="blob-num js-line-number" data-line-number="85"></td>754 <td id="LC85" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">return</span> pars</td>755 </tr>756 <tr>757 <td id="L86" class="blob-num js-line-number" data-line-number="86"></td>758 <td id="LC86" class="blob-code blob-code-inner js-file-line">759 </td>760 </tr>761 <tr>762 <td id="L87" class="blob-num js-line-number" data-line-number="87"></td>763 <td id="LC87" class="blob-code blob-code-inner js-file-line"><span class="pl-k">def</span> <span class="pl-en">_revert_pars</span>(<span class="pl-smi">pars</span>, <span class="pl-smi">mapping</span>):</td>764 </tr>765 <tr>766 <td id="L88" class="blob-num js-line-number" data-line-number="88"></td>767 <td id="LC88" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">"""</span></span></td>768 </tr>769 <tr>770 <td id="L89" class="blob-num js-line-number" data-line-number="89"></td>771 <td id="LC89" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> Rename the parameters and any associated polydispersity attributes.</span></td>772 </tr>773 <tr>774 <td id="L90" class="blob-num js-line-number" data-line-number="90"></td>775 <td id="LC90" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> <span class="pl-pds">"""</span></span></td>776 </tr>777 <tr>778 <td id="L91" class="blob-num js-line-number" data-line-number="91"></td>779 <td id="LC91" class="blob-code blob-code-inner js-file-line"> newpars <span class="pl-k">=</span> pars.copy()</td>780 </tr>781 <tr>782 <td id="L92" class="blob-num js-line-number" data-line-number="92"></td>783 <td id="LC92" class="blob-code blob-code-inner js-file-line">784 </td>785 </tr>786 <tr>787 <td id="L93" class="blob-num js-line-number" data-line-number="93"></td>788 <td id="LC93" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">for</span> new, old <span class="pl-k">in</span> mapping.items():</td>789 </tr>790 <tr>791 <td id="L94" class="blob-num js-line-number" data-line-number="94"></td>792 <td id="LC94" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">for</span> pd, dot <span class="pl-k">in</span> <span class="pl-c1">PD_DOT</span>:</td>793 </tr>794 <tr>795 <td id="L95" class="blob-num js-line-number" data-line-number="95"></td>796 <td id="LC95" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">if</span> old <span class="pl-k">and</span> old<span class="pl-k">+</span>pd <span class="pl-k">==</span> new<span class="pl-k">+</span>dot:</td>797 </tr>798 <tr>799 <td id="L96" class="blob-num js-line-number" data-line-number="96"></td>800 <td id="LC96" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">continue</span></td>801 </tr>802 <tr>803 <td id="L97" class="blob-num js-line-number" data-line-number="97"></td>804 <td id="LC97" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">if</span> new<span class="pl-k">+</span>pd <span class="pl-k">in</span> newpars:</td>805 </tr>806 <tr>807 <td id="L98" class="blob-num js-line-number" data-line-number="98"></td>808 <td id="LC98" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">if</span> old <span class="pl-k">is</span> <span class="pl-k">not</span> <span class="pl-c1">None</span>:</td>809 </tr>810 <tr>811 <td id="L99" class="blob-num js-line-number" data-line-number="99"></td>812 <td id="LC99" class="blob-code blob-code-inner js-file-line"> newpars[old<span class="pl-k">+</span>dot] <span class="pl-k">=</span> pars[new<span class="pl-k">+</span>pd]</td>813 </tr>814 <tr>815 <td id="L100" class="blob-num js-line-number" data-line-number="100"></td>816 <td id="LC100" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">del</span> newpars[new<span class="pl-k">+</span>pd]</td>817 </tr>818 <tr>819 <td id="L101" class="blob-num js-line-number" data-line-number="101"></td>820 <td id="LC101" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">for</span> k <span class="pl-k">in</span> <span class="pl-c1">list</span>(newpars.keys()):</td>821 </tr>822 <tr>823 <td id="L102" class="blob-num js-line-number" data-line-number="102"></td>824 <td id="LC102" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">for</span> pd, dot <span class="pl-k">in</span> <span class="pl-c1">PD_DOT</span>[<span class="pl-c1">1</span>:]: <span class="pl-c"># skip "" => ""</span></td>825 </tr>826 <tr>827 <td id="L103" class="blob-num js-line-number" data-line-number="103"></td>828 <td id="LC103" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">if</span> k.endswith(pd):</td>829 </tr>830 <tr>831 <td id="L104" class="blob-num js-line-number" data-line-number="104"></td>832 <td id="LC104" class="blob-code blob-code-inner js-file-line"> newpars[k[:<span class="pl-k">-</span><span class="pl-c1">len</span>(pd)]<span class="pl-k">+</span>dot] <span class="pl-k">=</span> newpars[k]</td>833 </tr>834 <tr>835 <td id="L105" class="blob-num js-line-number" data-line-number="105"></td>836 <td id="LC105" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">del</span> newpars[k]</td>837 </tr>838 <tr>839 <td id="L106" class="blob-num js-line-number" data-line-number="106"></td>840 <td id="LC106" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">return</span> newpars</td>841 </tr>842 <tr>843 <td id="L107" class="blob-num js-line-number" data-line-number="107"></td>844 <td id="LC107" class="blob-code blob-code-inner js-file-line">845 </td>846 </tr>847 <tr>848 <td id="L108" class="blob-num js-line-number" data-line-number="108"></td>849 <td id="LC108" class="blob-code blob-code-inner js-file-line"><span class="pl-k">def</span> <span class="pl-en">revert_model</span>(<span class="pl-smi">model_definition</span>, <span class="pl-smi">pars</span>):</td>850 </tr>851 <tr>852 <td id="L109" class="blob-num js-line-number" data-line-number="109"></td>853 <td id="LC109" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">"""</span></span></td>854 </tr>855 <tr>856 <td id="L110" class="blob-num js-line-number" data-line-number="110"></td>857 <td id="LC110" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> Convert model from new style parameter names to old style.</span></td>858 </tr>859 <tr>860 <td id="L111" class="blob-num js-line-number" data-line-number="111"></td>861 <td id="LC111" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> <span class="pl-pds">"""</span></span></td>862 </tr>863 <tr>864 <td id="L112" class="blob-num js-line-number" data-line-number="112"></td>865 <td id="LC112" class="blob-code blob-code-inner js-file-line"> mapping <span class="pl-k">=</span> model_definition.oldpars</td>866 </tr>867 <tr>868 <td id="L113" class="blob-num js-line-number" data-line-number="113"></td>869 <td id="LC113" class="blob-code blob-code-inner js-file-line"> oldname <span class="pl-k">=</span> model_definition.oldname</td>870 </tr>871 <tr>872 <td id="L114" class="blob-num js-line-number" data-line-number="114"></td>873 <td id="LC114" class="blob-code blob-code-inner js-file-line"> oldpars <span class="pl-k">=</span> _revert_pars(_unscale_sld(pars), mapping)</td>874 </tr>875 <tr>876 <td id="L115" class="blob-num js-line-number" data-line-number="115"></td>877 <td id="LC115" class="blob-code blob-code-inner js-file-line">878 </td>879 </tr>880 <tr>881 <td id="L116" class="blob-num js-line-number" data-line-number="116"></td>882 <td id="LC116" class="blob-code blob-code-inner js-file-line"> <span class="pl-c"># Note: update compare.constrain_pars to match</span></td>883 </tr>884 <tr>885 <td id="L117" class="blob-num js-line-number" data-line-number="117"></td>886 <td id="LC117" class="blob-code blob-code-inner js-file-line"> name <span class="pl-k">=</span> model_definition.name</td>887 </tr>888 <tr>889 <td id="L118" class="blob-num js-line-number" data-line-number="118"></td>890 <td id="LC118" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">if</span> name <span class="pl-k">in</span> <span class="pl-c1">MODELS_WITHOUT_SCALE</span>:</td>891 </tr>892 <tr>893 <td id="L119" class="blob-num js-line-number" data-line-number="119"></td>894 <td id="LC119" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">if</span> oldpars.pop(<span class="pl-s"><span class="pl-pds">'</span>scale<span class="pl-pds">'</span></span>, <span class="pl-c1">1.0</span>) <span class="pl-k">!=</span> <span class="pl-c1">1.0</span>:</td>895 </tr>896 <tr>897 <td id="L120" class="blob-num js-line-number" data-line-number="120"></td>898 <td id="LC120" class="blob-code blob-code-inner js-file-line"> warnings.warn(<span class="pl-s"><span class="pl-pds">"</span>parameter scale not used in sasview <span class="pl-c1">%s</span><span class="pl-pds">"</span></span><span class="pl-k">%</span>name)</td>899 </tr>900 <tr>901 <td id="L121" class="blob-num js-line-number" data-line-number="121"></td>902 <td id="LC121" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">elif</span> name <span class="pl-k">in</span> <span class="pl-c1">MODELS_WITHOUT_BACKGROUND</span>:</td>903 </tr>904 <tr>905 <td id="L122" class="blob-num js-line-number" data-line-number="122"></td>906 <td id="LC122" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">if</span> oldpars.pop(<span class="pl-s"><span class="pl-pds">'</span>background<span class="pl-pds">'</span></span>, <span class="pl-c1">0.0</span>) <span class="pl-k">!=</span> <span class="pl-c1">0.0</span>:</td>907 </tr>908 <tr>909 <td id="L123" class="blob-num js-line-number" data-line-number="123"></td>910 <td id="LC123" class="blob-code blob-code-inner js-file-line"> warnings.warn(<span class="pl-s"><span class="pl-pds">"</span>parameter background not used in sasview <span class="pl-c1">%s</span><span class="pl-pds">"</span></span><span class="pl-k">%</span>name)</td>911 </tr>912 <tr>913 <td id="L124" class="blob-num js-line-number" data-line-number="124"></td>914 <td id="LC124" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">elif</span> <span class="pl-c1">getattr</span>(model_definition, <span class="pl-s"><span class="pl-pds">'</span>category<span class="pl-pds">'</span></span>, <span class="pl-c1">None</span>) <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">'</span>structure-factor<span class="pl-pds">'</span></span>:</td>915 </tr>916 <tr>917 <td id="L125" class="blob-num js-line-number" data-line-number="125"></td>918 <td id="LC125" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">if</span> oldpars.pop(<span class="pl-s"><span class="pl-pds">'</span>scale<span class="pl-pds">'</span></span>, <span class="pl-c1">1.0</span>) <span class="pl-k">!=</span> <span class="pl-c1">1.0</span>:</td>919 </tr>920 <tr>921 <td id="L126" class="blob-num js-line-number" data-line-number="126"></td>922 <td id="LC126" class="blob-code blob-code-inner js-file-line"> warnings.warn(<span class="pl-s"><span class="pl-pds">"</span>parameter scale not used in sasview <span class="pl-c1">%s</span><span class="pl-pds">"</span></span><span class="pl-k">%</span>name)</td>923 </tr>924 <tr>925 <td id="L127" class="blob-num js-line-number" data-line-number="127"></td>926 <td id="LC127" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">if</span> oldpars.pop(<span class="pl-s"><span class="pl-pds">'</span>background<span class="pl-pds">'</span></span>, <span class="pl-c1">0.0</span>) <span class="pl-k">!=</span> <span class="pl-c1">0.0</span>:</td>927 </tr>928 <tr>929 <td id="L128" class="blob-num js-line-number" data-line-number="128"></td>930 <td id="LC128" class="blob-code blob-code-inner js-file-line"> warnings.warn(<span class="pl-s"><span class="pl-pds">"</span>parameter background not used in sasview <span class="pl-c1">%s</span><span class="pl-pds">"</span></span><span class="pl-k">%</span>name)</td>931 </tr>932 <tr>933 <td id="L129" class="blob-num js-line-number" data-line-number="129"></td>934 <td id="LC129" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">elif</span> name <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">'</span>pearl_necklace<span class="pl-pds">'</span></span>:</td>935 </tr>936 <tr>937 <td id="L130" class="blob-num js-line-number" data-line-number="130"></td>938 <td id="LC130" class="blob-code blob-code-inner js-file-line"> _remove_pd(oldpars, <span class="pl-s"><span class="pl-pds">'</span>num_pearls<span class="pl-pds">'</span></span>, name)</td>939 </tr>940 <tr>941 <td id="L131" class="blob-num js-line-number" data-line-number="131"></td>942 <td id="LC131" class="blob-code blob-code-inner js-file-line"> _remove_pd(oldpars, <span class="pl-s"><span class="pl-pds">'</span>thick_string<span class="pl-pds">'</span></span>, name)</td>943 </tr>944 <tr>945 <td id="L132" class="blob-num js-line-number" data-line-number="132"></td>946 <td id="LC132" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">elif</span> name <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">'</span>rpa<span class="pl-pds">'</span></span>:</td>947 </tr>948 <tr>949 <td id="L133" class="blob-num js-line-number" data-line-number="133"></td>950 <td id="LC133" class="blob-code blob-code-inner js-file-line"> <span class="pl-c"># convert scattering lengths from femtometers to centimeters</span></td>951 </tr>952 <tr>953 <td id="L134" class="blob-num js-line-number" data-line-number="134"></td>954 <td id="LC134" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">for</span> p <span class="pl-k">in</span> <span class="pl-s"><span class="pl-pds">"</span>La<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>Lb<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>Lc<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>Ld<span class="pl-pds">"</span></span>:</td>955 </tr>956 <tr>957 <td id="L135" class="blob-num js-line-number" data-line-number="135"></td>958 <td id="LC135" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">if</span> p <span class="pl-k">in</span> oldpars: oldpars[p] <span class="pl-k">*=</span> <span class="pl-c1">1e-13</span></td>959 </tr>960 <tr>961 <td id="L136" class="blob-num js-line-number" data-line-number="136"></td>962 <td id="LC136" class="blob-code blob-code-inner js-file-line">963 </td>964 </tr>965 <tr>966 <td id="L137" class="blob-num js-line-number" data-line-number="137"></td>967 <td id="LC137" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">return</span> oldname, oldpars</td>968 </tr>969 <tr>970 <td id="L138" class="blob-num js-line-number" data-line-number="138"></td>971 <td id="LC138" class="blob-code blob-code-inner js-file-line">972 </td>973 </tr>974 <tr>975 <td id="L139" class="blob-num js-line-number" data-line-number="139"></td>976 <td id="LC139" class="blob-code blob-code-inner js-file-line"><span class="pl-k">def</span> <span class="pl-en">constrain_new_to_old</span>(<span class="pl-smi">model_definition</span>, <span class="pl-smi">pars</span>):</td>977 </tr>978 <tr>979 <td id="L140" class="blob-num js-line-number" data-line-number="140"></td>980 <td id="LC140" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">"""</span></span></td>981 </tr>982 <tr>983 <td id="L141" class="blob-num js-line-number" data-line-number="141"></td>984 <td id="LC141" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> Restrict parameter values to those that will match sasview.</span></td>985 </tr>986 <tr>987 <td id="L142" class="blob-num js-line-number" data-line-number="142"></td>988 <td id="LC142" class="blob-code blob-code-inner js-file-line"><span class="pl-s"> <span class="pl-pds">"""</span></span></td>989 </tr>990 <tr>991 <td id="L143" class="blob-num js-line-number" data-line-number="143"></td>992 <td id="LC143" class="blob-code blob-code-inner js-file-line"> <span class="pl-c"># Note: update convert.revert_model to match</span></td>993 </tr>994 <tr>995 <td id="L144" class="blob-num js-line-number" data-line-number="144"></td>996 <td id="LC144" class="blob-code blob-code-inner js-file-line"> name <span class="pl-k">=</span> model_definition.name</td>997 </tr>998 <tr>999 <td id="L145" class="blob-num js-line-number" data-line-number="145"></td>1000 <td id="LC145" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">if</span> name <span class="pl-k">in</span> <span class="pl-c1">MODELS_WITHOUT_SCALE</span>:</td>1001 </tr>1002 <tr>1003 <td id="L146" class="blob-num js-line-number" data-line-number="146"></td>1004 <td id="LC146" class="blob-code blob-code-inner js-file-line"> pars[<span class="pl-s"><span class="pl-pds">'</span>scale<span class="pl-pds">'</span></span>] <span class="pl-k">=</span> <span class="pl-c1">1</span></td>1005 </tr>1006 <tr>1007 <td id="L147" class="blob-num js-line-number" data-line-number="147"></td>1008 <td id="LC147" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">elif</span> name <span class="pl-k">in</span> <span class="pl-c1">MODELS_WITHOUT_BACKGROUND</span>:</td>1009 </tr>1010 <tr>1011 <td id="L148" class="blob-num js-line-number" data-line-number="148"></td>1012 <td id="LC148" class="blob-code blob-code-inner js-file-line"> pars[<span class="pl-s"><span class="pl-pds">'</span>background<span class="pl-pds">'</span></span>] <span class="pl-k">=</span> <span class="pl-c1">0</span></td>1013 </tr>1014 <tr>1015 <td id="L149" class="blob-num js-line-number" data-line-number="149"></td>1016 <td id="LC149" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">elif</span> name <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">'</span>pearl_necklace<span class="pl-pds">'</span></span>:</td>1017 </tr>1018 <tr>1019 <td id="L150" class="blob-num js-line-number" data-line-number="150"></td>1020 <td id="LC150" class="blob-code blob-code-inner js-file-line"> pars[<span class="pl-s"><span class="pl-pds">'</span>string_thickness_pd_n<span class="pl-pds">'</span></span>] <span class="pl-k">=</span> <span class="pl-c1">0</span></td>1021 </tr>1022 <tr>1023 <td id="L151" class="blob-num js-line-number" data-line-number="151"></td>1024 <td id="LC151" class="blob-code blob-code-inner js-file-line"> pars[<span class="pl-s"><span class="pl-pds">'</span>number_of_pearls_pd_n<span class="pl-pds">'</span></span>] <span class="pl-k">=</span> <span class="pl-c1">0</span></td>1025 </tr>1026 <tr>1027 <td id="L152" class="blob-num js-line-number" data-line-number="152"></td>1028 <td id="LC152" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">elif</span> name <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">'</span>rpa<span class="pl-pds">'</span></span>:</td>1029 </tr>1030 <tr>1031 <td id="L153" class="blob-num js-line-number" data-line-number="153"></td>1032 <td id="LC153" class="blob-code blob-code-inner js-file-line"> pars[<span class="pl-s"><span class="pl-pds">'</span>case_num<span class="pl-pds">'</span></span>] <span class="pl-k">=</span> <span class="pl-c1">int</span>(pars[<span class="pl-s"><span class="pl-pds">'</span>case_num<span class="pl-pds">'</span></span>])</td>1033 </tr>1034 <tr>1035 <td id="L154" class="blob-num js-line-number" data-line-number="154"></td>1036 <td id="LC154" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">elif</span> <span class="pl-c1">getattr</span>(model_definition, <span class="pl-s"><span class="pl-pds">'</span>category<span class="pl-pds">'</span></span>, <span class="pl-c1">None</span>) <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">'</span>structure-factor<span class="pl-pds">'</span></span>:</td>1037 </tr>1038 <tr>1039 <td id="L155" class="blob-num js-line-number" data-line-number="155"></td>1040 <td id="LC155" class="blob-code blob-code-inner js-file-line"> pars[<span class="pl-s"><span class="pl-pds">'</span>scale<span class="pl-pds">'</span></span>], pars[<span class="pl-s"><span class="pl-pds">'</span>background<span class="pl-pds">'</span></span>] <span class="pl-k">=</span> <span class="pl-c1">1</span>, <span class="pl-c1">0</span></td>1041 </tr>1042 <tr>1043 <td id="L156" class="blob-num js-line-number" data-line-number="156"></td>1044 <td id="LC156" class="blob-code blob-code-inner js-file-line">1045 </td>1046 </tr>1047 </table>1048 1049 </div>1050 1051 </div>1052 1053 <a href="#jump-to-line" rel="facebox[.linejump]" data-hotkey="l" style="display:none">Jump to Line</a>1054 <div id="jump-to-line" style="display:none">1055 <!-- </textarea> --><!-- '"` --><form accept-charset="UTF-8" action="" class="js-jump-to-line-form" method="get"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /></div>1056 <input class="linejump-input js-jump-to-line-field" type="text" placeholder="Jump to line…" aria-label="Jump to line" autofocus>1057 <button type="submit" class="btn">Go</button>1058 </form></div>1059 1060 </div>1061 <div class="modal-backdrop"></div>1062 </div>1063 1064 </div>1065 </div>1066 1067 </div>1068 1069 <div class="container">1070 <div class="site-footer" role="contentinfo">1071 <ul class="site-footer-links right">1072 <li><a href="https://status.github.com/" data-ga-click="Footer, go to status, text:status">Status</a></li>1073 <li><a href="https://developer.github.com" data-ga-click="Footer, go to api, text:api">API</a></li>1074 <li><a href="https://training.github.com" data-ga-click="Footer, go to training, text:training">Training</a></li>1075 <li><a href="https://shop.github.com" data-ga-click="Footer, go to shop, text:shop">Shop</a></li>1076 <li><a href="https://github.com/blog" data-ga-click="Footer, go to blog, text:blog">Blog</a></li>1077 <li><a href="https://github.com/about" data-ga-click="Footer, go to about, text:about">About</a></li>1078 <li><a href="https://github.com/pricing" data-ga-click="Footer, go to pricing, text:pricing">Pricing</a></li>1079 1080 </ul>1081 1082 <a href="https://github.com" aria-label="Homepage">1083 <svg aria-hidden="true" class="octicon octicon-mark-github" height="24" role="img" title="GitHub " version="1.1" viewBox="0 0 16 16" width="24"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59 0.4 0.07 0.55-0.17 0.55-0.38 0-0.19-0.01-0.82-0.01-1.49-2.01 0.37-2.53-0.49-2.69-0.94-0.09-0.23-0.48-0.94-0.82-1.13-0.28-0.15-0.68-0.52-0.01-0.53 0.63-0.01 1.08 0.58 1.23 0.82 0.72 1.21 1.87 0.87 2.33 0.66 0.07-0.52 0.28-0.87 0.51-1.07-1.78-0.2-3.64-0.89-3.64-3.95 0-0.87 0.31-1.59 0.82-2.15-0.08-0.2-0.36-1.02 0.08-2.12 0 0 0.67-0.21 2.2 0.82 0.64-0.18 1.32-0.27 2-0.27 0.68 0 1.36 0.09 2 0.27 1.53-1.04 2.2-0.82 2.2-0.82 0.44 1.1 0.16 1.92 0.08 2.12 0.51 0.56 0.82 1.27 0.82 2.15 0 3.07-1.87 3.75-3.65 3.95 0.29 0.25 0.54 0.73 0.54 1.48 0 1.07-0.01 1.93-0.01 2.2 0 0.21 0.15 0.46 0.55 0.38C13.71 14.53 16 11.53 16 8 16 3.58 12.42 0 8 0z"></path></svg>1084 </a>1085 <ul class="site-footer-links">1086 <li>© 2016 <span title="0.05637s from github-fe127-cp1-prd.iad.github.net">GitHub</span>, Inc.</li>1087 <li><a href="https://github.com/site/terms" data-ga-click="Footer, go to terms, text:terms">Terms</a></li>1088 <li><a href="https://github.com/site/privacy" data-ga-click="Footer, go to privacy, text:privacy">Privacy</a></li>1089 <li><a href="https://github.com/security" data-ga-click="Footer, go to security, text:security">Security</a></li>1090 <li><a href="https://github.com/contact" data-ga-click="Footer, go to contact, text:contact">Contact</a></li>1091 <li><a href="https://help.github.com" data-ga-click="Footer, go to help, text:help">Help</a></li>1092 </ul>1093 </div>1094 </div>1095 1096 1097 1098 1099 1100 1101 1102 <div id="ajax-error-message" class="flash flash-error">1103 <svg aria-hidden="true" class="octicon octicon-alert" height="16" role="img" version="1.1" viewBox="0 0 16 16" width="16"><path d="M15.72 12.5l-6.85-11.98C8.69 0.21 8.36 0.02 8 0.02s-0.69 0.19-0.87 0.5l-6.85 11.98c-0.18 0.31-0.18 0.69 0 1C0.47 13.81 0.8 14 1.15 14h13.7c0.36 0 0.69-0.19 0.86-0.5S15.89 12.81 15.72 12.5zM9 12H7V10h2V12zM9 9H7V5h2V9z"></path></svg>1104 <button type="button" class="flash-close js-flash-close js-ajax-error-dismiss" aria-label="Dismiss error">1105 <svg aria-hidden="true" class="octicon octicon-x" height="16" role="img" version="1.1" viewBox="0 0 12 16" width="12"><path d="M7.48 8l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75-1.48-1.48 3.75-3.75L0.77 4.25l1.48-1.48 3.75 3.75 3.75-3.75 1.48 1.48-3.75 3.75z"></path></svg>1106 </button>1107 Something went wrong with that request. Please try again.1108 </div>1109 1110 1111 1112 <script crossorigin="anonymous" integrity="sha256-7lIbjp+srGj/J+k/w64PjtgR17+eQ06E9LnqIneAsIQ=" src="https://assets-cdn.github.com/assets/frameworks-ee521b8e9facac68ff27e93fc3ae0f8ed811d7bf9e434e84f4b9ea227780b084.js"></script>1113 <script async="async" crossorigin="anonymous" integrity="sha256-aWM2lkt8QuTG9N+68fjlf0Jc2anRihLz/m4910T9fRM=" src="https://assets-cdn.github.com/assets/github-696336964b7c42e4c6f4dfbaf1f8e57f425cd9a9d18a12f3fe6e3dd744fd7d13.js"></script>1114 1115 1116 1117 <div class="js-stale-session-flash stale-session-flash flash flash-warn flash-banner hidden">1118 <svg aria-hidden="true" class="octicon octicon-alert" height="16" role="img" version="1.1" viewBox="0 0 16 16" width="16"><path d="M15.72 12.5l-6.85-11.98C8.69 0.21 8.36 0.02 8 0.02s-0.69 0.19-0.87 0.5l-6.85 11.98c-0.18 0.31-0.18 0.69 0 1C0.47 13.81 0.8 14 1.15 14h13.7c0.36 0 0.69-0.19 0.86-0.5S15.89 12.81 15.72 12.5zM9 12H7V10h2V12zM9 9H7V5h2V9z"></path></svg>1119 <span class="signed-in-tab-flash">You signed in with another tab or window. <a href="">Reload</a> to refresh your session.</span>1120 <span class="signed-out-tab-flash">You signed out in another tab or window. <a href="">Reload</a> to refresh your session.</span>1121 </div>1122 <div class="facebox" id="facebox" style="display:none;">1123 <div class="facebox-popup">1124 <div class="facebox-content" role="dialog" aria-labelledby="facebox-header" aria-describedby="facebox-description">1125 </div>1126 <button type="button" class="facebox-close js-facebox-close" aria-label="Close modal">1127 <svg aria-hidden="true" class="octicon octicon-x" height="16" role="img" version="1.1" viewBox="0 0 12 16" width="12"><path d="M7.48 8l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75-1.48-1.48 3.75-3.75L0.77 4.25l1.48-1.48 3.75 3.75 3.75-3.75 1.48 1.48-3.75 3.75z"></path></svg>1128 </button>1129 </div>1130 </div>1131 1132 </body>1133 </html>1134
Note: See TracChangeset
for help on using the changeset viewer.