Changes in / [3c567c6b:9f60c06] in sasmodels
- Location:
- sasmodels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/conversion_table.py
rc95dfc63 rcbf4604 363 363 } 364 364 ], 365 "hardsphere2": [ 366 "HardsphereStructure", 367 {} 368 ], 369 "hardsphere3": [ 370 "HardsphereStructure", 371 {} 372 ], 373 "hardsphere4": [ 374 "HardsphereStructure", 375 {} 376 ], 365 377 "hayter_msa": [ 366 378 "HayterMSAStructure", -
sasmodels/sasview_model.py
rfd19811 r9457498 18 18 19 19 import numpy as np # type: ignore 20 21 # Monkey patch sas.sascalc.fit as sas.models so that sas.models.pluginmodel 22 # is available to the plugin modules. 23 import sys 24 import sas 25 import sas.sascalc.fit 26 sys.modules['sas.models'] = sas.sascalc.fit 27 sas.models = sas.sascalc.fit 20 28 21 29 from . import core … … 38 46 pass 39 47 40 SUPPORT_OLD_STYLE_PLUGINS = True41 42 def _register_old_models():43 # type: () -> None44 """45 Place the new models into sasview under the old names.46 47 Monkey patch sas.sascalc.fit as sas.models so that sas.models.pluginmodel48 is available to the plugin modules.49 """50 import sys51 import sas52 import sas.sascalc.fit53 sys.modules['sas.models'] = sas.sascalc.fit54 sas.models = sas.sascalc.fit55 56 import sas.models57 from sasmodels.conversion_table import CONVERSION_TABLE58 for new_name, conversion in CONVERSION_TABLE.items():59 old_name = conversion[0]60 module_attrs = {old_name: find_model(new_name)}61 ConstructedModule = type(old_name, (), module_attrs)62 old_path = 'sas.models.' + old_name63 setattr(sas.models, old_path, ConstructedModule)64 sys.modules[old_path] = ConstructedModule65 66 48 67 49 # TODO: separate x_axis_label from multiplicity info … … 104 86 except Exception: 105 87 logging.error(traceback.format_exc()) 106 if SUPPORT_OLD_STYLE_PLUGINS:107 _register_old_models()108 109 88 return models 110 89 … … 697 676 raise 698 677 699 def test_old_name():700 # type: () -> None701 """702 Load and run cylinder model from sas.models.CylinderModel703 """704 if not SUPPORT_OLD_STYLE_PLUGINS:705 return706 try:707 # if sasview is not on the path then don't try to test it708 import sas709 except ImportError:710 return711 load_standard_models()712 from sas.models.CylinderModel import CylinderModel713 CylinderModel().evalDistribution([0.1, 0.1])714 715 678 if __name__ == "__main__": 716 679 print("cylinder(0.1,0.1)=%g"%test_model())
Note: See TracChangeset
for help on using the changeset viewer.