Changes in sasmodels/sasview_model.py [64614ad:749a7d4] in sasmodels
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/sasview_model.py
r64614ad r749a7d4 16 16 import logging 17 17 from os.path import basename, splitext 18 import thread 18 19 19 20 import numpy as np # type: ignore … … 39 40 pass 40 41 42 calculation_lock = thread.allocate_lock() 43 41 44 SUPPORT_OLD_STYLE_PLUGINS = True 42 45 … … 57 60 import sas.models 58 61 from sasmodels.conversion_table import CONVERSION_TABLE 59 for new_name, conversion in CONVERSION_TABLE. items():62 for new_name, conversion in CONVERSION_TABLE.get((3,1,2), {}).items(): 60 63 # CoreShellEllipsoidModel => core_shell_ellipsoid:1 61 64 new_name = new_name.split(':')[0] 62 old_name = conversion[0] 65 old_name = conversion[0] if len(conversion) < 3 else conversion[2] 63 66 module_attrs = {old_name: find_model(new_name)} 64 67 ConstructedModule = type(old_name, (), module_attrs) … … 605 608 to the card for each evaluation. 606 609 """ 610 ## uncomment the following when trying to debug the uncoordinated calls 611 ## to calculate_Iq 612 #if calculation_lock.locked(): 613 # logging.info("calculation waiting for another thread to complete") 614 # logging.info("\n".join(traceback.format_stack())) 615 616 with calculation_lock: 617 return self._calculate_Iq(qx, qy) 618 619 def _calculate_Iq(self, qx, qy=None): 607 620 #core.HAVE_OPENCL = False 608 621 if self._model is None: … … 721 734 return [self.params[par.name]], [1.0] 722 735 723 def test_ model():736 def test_cylinder(): 724 737 # type: () -> float 725 738 """ 726 Test that a sasview model (cylinder) can be run.739 Test that the cylinder model runs, returning the value at [0.1,0.1]. 727 740 """ 728 741 Cylinder = _make_standard_model('cylinder') … … 733 746 # type: () -> float 734 747 """ 735 Test that a sasview model (cylinder) can be run.748 Test that 2-D hardsphere model runs and doesn't produce NaN. 736 749 """ 737 750 Model = _make_standard_model('hardsphere') … … 744 757 # type: () -> float 745 758 """ 746 Test that a sasview model (cylinder) can be run.759 Test that the 2-D RPA model runs 747 760 """ 748 761 RPA = _make_standard_model('rpa') … … 750 763 return rpa.evalDistribution([0.1, 0.1]) 751 764 765 def test_empty_distribution(): 766 # type: () -> None 767 """ 768 Make sure that sasmodels returns NaN when there are no polydispersity points 769 """ 770 Cylinder = _make_standard_model('cylinder') 771 cylinder = Cylinder() 772 cylinder.setParam('radius', -1.0) 773 cylinder.setParam('background', 0.) 774 Iq = cylinder.evalDistribution(np.asarray([0.1])) 775 assert np.isnan(Iq[0]), "empty distribution fails" 752 776 753 777 def test_model_list(): 754 778 # type: () -> None 755 779 """ 756 Make sure that all models build as sasview models .780 Make sure that all models build as sasview models 757 781 """ 758 782 from .exception import annotate_exception … … 781 805 782 806 if __name__ == "__main__": 783 print("cylinder(0.1,0.1)=%g"%test_model()) 807 print("cylinder(0.1,0.1)=%g"%test_cylinder()) 808 #test_empty_distribution()
Note: See TracChangeset
for help on using the changeset viewer.