Changeset 190fc2b in sasmodels for sasmodels/generate.py


Ignore:
Timestamp:
Jan 29, 2016 12:35:57 AM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
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
Message:

delint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/generate.py

    re66c9f9 r190fc2b  
    197197# TODO: identify model files which have changed since loading and reload them. 
    198198 
    199 __all__ = ["make", "doc", "sources", "convert_type"] 
    200  
    201199import sys 
    202200from os.path import abspath, dirname, join as joinpath, exists, basename, \ 
     
    206204 
    207205import numpy as np 
     206 
     207__all__ = ["make", "doc", "sources", "convert_type"] 
     208 
    208209C_KERNEL_TEMPLATE_PATH = joinpath(dirname(__file__), 'kernel_template.c') 
    209210 
     
    216217    F128 = None 
    217218 
    218  
    219219# Scale and background, which are parameters common to every form factor 
    220220COMMON_PARAMETERS = [ 
     
    222222    ["background", "1/cm", 0, [0, np.inf], "", "Source background"], 
    223223    ] 
    224  
    225224 
    226225# Conversion from units defined in the parameter table for each model 
     
    266265 
    267266def format_units(units): 
     267    """ 
     268    Convert units into ReStructured Text format. 
     269    """ 
    268270    return "string" if isinstance(units, list) else RST_UNITS.get(units, units) 
    269271 
     
    335337    """ 
    336338    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. 
    337342    """ 
    338343    if dtype == F16: 
     
    350355 
    351356def _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    """ 
    352361    # Convert double keyword to float/long double/half. 
    353362    # Accept an 'n' # parameter for vector # values, where n is 2, 4, 8 or 16. 
     
    625634                            %re.escape(string.punctuation)) 
    626635def _convert_section_titles_to_boldface(lines): 
     636    """ 
     637    Do the actual work of identifying and converting section headings. 
     638    """ 
    627639    prior = None 
    628640    for line in lines: 
     
    642654        yield prior 
    643655 
    644 def convert_section_titles_to_boldface(string): 
    645     return "\n".join(_convert_section_titles_to_boldface(string.split('\n'))) 
     656def 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'))) 
    646665 
    647666def doc(kernel_module): 
     
    666685 
    667686def demo_time(): 
     687    """ 
     688    Show how long it takes to process a model. 
     689    """ 
    668690    from .models import cylinder 
    669691    import datetime 
     
    674696 
    675697def main(): 
     698    """ 
     699    Program which prints the source produced by the model. 
     700    """ 
    676701    if len(sys.argv) <= 1: 
    677702        print("usage: python -m sasmodels.generate modelname") 
Note: See TracChangeset for help on using the changeset viewer.