Changeset b297ba9 in sasmodels for sasmodels/generate.py
- Timestamp:
- Mar 20, 2019 5:03:50 PM (5 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 4e28511
- Parents:
- 0d362b7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/generate.py
ra8a1d48 rb297ba9 190 190 191 191 def get_data_path(external_dir, target_file): 192 """ 193 Search for the target file relative in the installed application. 194 195 Search first in the location of the generate module in case we are 196 running directly from the distribution. Search next to the python 197 executable for windows installs. Search in the ../Resources directory 198 next to the executable for Mac OS/X installs. 199 """ 192 200 path = abspath(dirname(__file__)) 193 201 if exists(joinpath(path, target_file)): … … 225 233 # 226 234 # NOTE: there is an RST_PROLOG at the end of this file which is NOT 227 # used for the bundled documentation. Still as long as we are defining the macros228 # in two places any new addition should define the macro in both places.235 # used for the bundled documentation. Still as long as we are defining the 236 # macros in two places any new addition should define the macro in both places. 229 237 RST_UNITS = { 230 238 "Ang": "|Ang|", … … 530 538 531 539 def test_tag_float(): 532 """ check that floating point constants are properlyidentified and tagged with 'f'"""540 """Check that floating point constants are identified and tagged with 'f'""" 533 541 534 542 cases = """ … … 707 715 return False 708 716 709 _SHELL_VOLUME_PATTERN = re.compile(r"(^|\s)double\s+shell_volume[(]", flags=re.MULTILINE) 717 _SHELL_VOLUME_PATTERN = re.compile(r"(^|\s)double\s+shell_volume[(]", 718 flags=re.MULTILINE) 710 719 def contains_shell_volume(source): 711 720 # type: (List[str]) -> bool … … 801 810 logger.warn("oriented shapes should define Iqac or Iqabc") 802 811 else: 803 raise ValueError("Expected functionIqac or Iqabc for oriented shape")812 raise ValueError("Expected Iqac or Iqabc for oriented shape") 804 813 805 814 # Define the parameter table … … 815 824 refs = _call_pars("_v.", partable.form_volume_parameters) 816 825 if is_hollow: 817 call_volume = "#define CALL_VOLUME(_form, _shell, _v) do { _form = form_volume(%s); _shell = shell_volume(%s); } while (0)"%((",".join(refs),)*2) 826 call_volume = ( 827 "#define CALL_VOLUME(_form, _shell, _v) " 828 "do { _form = form_volume(%s); _shell = shell_volume(%s); } " 829 "while (0)") % ((",".join(refs),)*2) 818 830 else: 819 call_volume = "#define CALL_VOLUME(_form, _shell, _v) do { _form = _shell = form_volume(%s); } while (0)"%(",".join(refs)) 831 call_volume = ( 832 "#define CALL_VOLUME(_form, _shell, _v) " 833 "do { _form = _shell = form_volume(%s); } " 834 "while (0)") % (",".join(refs)) 820 835 if model_info.effective_radius_type: 821 call_effective_radius = "#define CALL_EFFECTIVE_RADIUS(_mode, _v) effective_radius(_mode, %s)"%(",".join(refs)) 836 call_effective_radius = ( 837 "#define CALL_EFFECTIVE_RADIUS(_mode, _v) " 838 "effective_radius(_mode, %s)") % (",".join(refs)) 822 839 else: 823 840 # Model doesn't have volume. We could make the kernel run a little 824 841 # faster by not using/transferring the volume normalizations, but 825 842 # the ifdef's reduce readability more than is worthwhile. 826 call_volume = "#define CALL_VOLUME(_form, _shell, _v) do { _form = _shell = 1.0; } while (0)" 843 call_volume = ( 844 "#define CALL_VOLUME(_form, _shell, _v) " 845 "do { _form = _shell = 1.0; } while (0)") 827 846 source.append(call_volume) 828 847 source.append(call_effective_radius) … … 879 898 source.append("#define MAGNETIC_PARS %s"%",".join(str(k) for k in magpars)) 880 899 source.append("#define PROJECTION %d"%PROJECTION) 881 # TODO: allow mixed python/opencl kernels? 882 ocl = _kernels(kernel_code, call_iq, clear_iq, call_iqxy, clear_iqxy, model_info.name) 883 dll = _kernels(kernel_code, call_iq, clear_iq, call_iqxy, clear_iqxy, model_info.name) 884 885 result = { 886 'dll': '\n'.join(source+dll[0]+dll[1]+dll[2]), 887 'opencl': '\n'.join(source+ocl[0]+ocl[1]+ocl[2]), 888 } 900 wrappers = _kernels(kernel_code, call_iq, clear_iq, 901 call_iqxy, clear_iqxy, model_info.name) 902 code = '\n'.join(source + wrappers[0] + wrappers[1] + wrappers[2]) 903 904 # Note: Identical code for dll and opencl. This may not always be the case 905 # so leave them as separate entries in the returned value. 906 result = {'dll': code, 'opencl': code} 889 907 return result 890 908
Note: See TracChangeset
for help on using the changeset viewer.