Changeset 190fc2b in sasmodels for sasmodels/generate.py
- Timestamp:
- Jan 29, 2016 12:35:57 AM (8 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:
- 3a45c2c
- Parents:
- d4666ca
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/generate.py
re66c9f9 r190fc2b 197 197 # TODO: identify model files which have changed since loading and reload them. 198 198 199 __all__ = ["make", "doc", "sources", "convert_type"]200 201 199 import sys 202 200 from os.path import abspath, dirname, join as joinpath, exists, basename, \ … … 206 204 207 205 import numpy as np 206 207 __all__ = ["make", "doc", "sources", "convert_type"] 208 208 209 C_KERNEL_TEMPLATE_PATH = joinpath(dirname(__file__), 'kernel_template.c') 209 210 … … 216 217 F128 = None 217 218 218 219 219 # Scale and background, which are parameters common to every form factor 220 220 COMMON_PARAMETERS = [ … … 222 222 ["background", "1/cm", 0, [0, np.inf], "", "Source background"], 223 223 ] 224 225 224 226 225 # Conversion from units defined in the parameter table for each model … … 266 265 267 266 def format_units(units): 267 """ 268 Convert units into ReStructured Text format. 269 """ 268 270 return "string" if isinstance(units, list) else RST_UNITS.get(units, units) 269 271 … … 335 337 """ 336 338 Convert code from double precision to the desired type. 339 340 Floating point constants are tagged with 'f' for single precision or 'L' 341 for long double precision. 337 342 """ 338 343 if dtype == F16: … … 350 355 351 356 def _convert_type(source, type_name, constant_flag): 357 """ 358 Replace 'double' with *type_name* in *source*, tagging floating point 359 constants with *constant_flag*. 360 """ 352 361 # Convert double keyword to float/long double/half. 353 362 # Accept an 'n' # parameter for vector # values, where n is 2, 4, 8 or 16. … … 625 634 %re.escape(string.punctuation)) 626 635 def _convert_section_titles_to_boldface(lines): 636 """ 637 Do the actual work of identifying and converting section headings. 638 """ 627 639 prior = None 628 640 for line in lines: … … 642 654 yield prior 643 655 644 def convert_section_titles_to_boldface(string): 645 return "\n".join(_convert_section_titles_to_boldface(string.split('\n'))) 656 def convert_section_titles_to_boldface(s): 657 """ 658 Use explicit bold-face rather than section headings so that the table of 659 contents is not polluted with section names from the model documentation. 660 661 Sections are identified as the title line followed by a line of punctuation 662 at least as long as the title line. 663 """ 664 return "\n".join(_convert_section_titles_to_boldface(s.split('\n'))) 646 665 647 666 def doc(kernel_module): … … 666 685 667 686 def demo_time(): 687 """ 688 Show how long it takes to process a model. 689 """ 668 690 from .models import cylinder 669 691 import datetime … … 674 696 675 697 def main(): 698 """ 699 Program which prints the source produced by the model. 700 """ 676 701 if len(sys.argv) <= 1: 677 702 print("usage: python -m sasmodels.generate modelname")
Note: See TracChangeset
for help on using the changeset viewer.