Changeset 15be191 in sasmodels


Ignore:
Timestamp:
Jan 3, 2018 12:34:04 PM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
Children:
4c87de0
Parents:
c01ed3e
Message:

Fix line breaks so there is only one space between lines

Location:
sasmodels
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/autoc.py

    rc01ed3e r15be191  
    9393                constants[name] = obj 
    9494                # Claim all constants are declared on line 1 
    95                 snippets.append('#line 1 "%s"'%escaped_filename) 
     95                snippets.append('#line 1 "%s"\n'%escaped_filename) 
    9696                snippets.append(py2c.define_constant(name, obj)) 
    9797            elif isinstance(obj, special.Gauss): 
     
    9999                    var = "GAUSS_"+var 
    100100                    constants[var] = value 
    101                     snippets.append('#line 1 "%s"'%escaped_filename) 
     101                    snippets.append('#line 1 "%s"\n'%escaped_filename) 
    102102                    snippets.append(py2c.define_constant(var, value)) 
    103103                #libs.append('lib/gauss%d.c'%obj.n) 
     
    125125    # update model info 
    126126    info.source = unique_libs 
    127     info.c_code = "\n".join(snippets) 
     127    info.c_code = "".join(snippets) 
    128128    info.Iq = info.Iqac = info.Iqabc = info.Iqxy = info.form_volume = None 
  • sasmodels/py2c.py

    rc01ed3e r15be191  
    113113    generator = SourceGenerator(constants=constants, fname=fname, lineno=lineno) 
    114114    generator.visit(tree) 
    115     c_code = "\n".join(generator.c_proc) 
     115    c_code = "".join(generator.c_proc) 
    116116    return c_code 
    117117 
     
    199199        self.new_lines = max(self.new_lines, 1 + extra) 
    200200        if node is not None and self.add_line_information: 
    201             self.write_c('# line: %s' % node.lineno) 
     201            self.write_c('// line: %s' % node.lineno) 
    202202            self.new_lines = 1 
    203203        if self.current_statement: 
     
    220220        self.body(node.body) 
    221221        if node.orelse: 
     222            self.unsupported(node, "for...else/while...else not supported") 
     223 
    222224            self.newline() 
    223225            self.write_c('else:') 
     
    250252                    arg_name = arg.id 
    251253                w_str = ("Default Parameters are unknown to C: '%s = %s" 
    252                          % arg_name, str(default.n)) 
     254                         % (arg_name, str(default.n))) 
    253255                self.warnings.append(w_str) 
    254256 
     
    435437        self.insert_signature() 
    436438        self.insert_c_vars(start_vars) 
    437         self.c_pointers = [] 
     439        del self.c_pointers[:] 
    438440        self.current_function = "" 
    439441 
     
    554556            self.write_c(':') 
    555557            # report the error 
    556             self.unsupported("unsupported " + self.current_statement) 
     558            self.unsupported(node, "unsupported " + self.current_statement) 
    557559 
    558560    def visit_While(self, node): 
     561        self.unsupported(node) 
     562 
    559563        self.newline(node) 
    560564        self.write_c('while ') 
     
    565569    def visit_With(self, node): 
    566570        self.unsupported(node) 
     571 
    567572        self.newline(node) 
    568573        self.write_python('with ') 
     
    581586        # TODO: print support would be nice, though hard to do 
    582587        self.unsupported(node) 
     588 
    583589        # CRUFT: python 2.6 only 
    584590        self.newline(node) 
     
    599605    def visit_Delete(self, node): 
    600606        self.unsupported(node) 
     607 
    601608        self.newline(node) 
    602609        self.write_python('del ') 
     
    608615    def visit_TryExcept(self, node): 
    609616        self.unsupported(node) 
     617 
    610618        self.newline(node) 
    611619        self.write_python('try:') 
     
    616624    def visit_TryFinally(self, node): 
    617625        self.unsupported(node) 
     626 
    618627        self.newline(node) 
    619628        self.write_python('try:') 
     
    625634    def visit_Global(self, node): 
    626635        self.unsupported(node) 
     636 
    627637        self.newline(node) 
    628638        self.write_python('global ' + ', '.join(node.names)) 
     
    654664    def visit_Raise(self, node): 
    655665        self.unsupported(node) 
     666 
    656667        # CRUFT: Python 2.6 / 3.0 compatibility 
    657668        self.newline(node) 
     
    676687    def visit_Attribute(self, node): 
    677688        self.unsupported(node, "attribute reference a.b not supported") 
     689 
    678690        self.visit(node.value) 
    679691        self.write_python('.' + node.attr) 
     
    779791    def visit_Dict(self, node): 
    780792        self.unsupported(node) 
     793 
    781794        self.write_python('{') 
    782795        for idx, (key, value) in enumerate(zip(node.keys, node.values)): 
     
    908921    def visit_Yield(self, node): 
    909922        self.unsupported(node) 
     923 
    910924        self.write_python('yield ') 
    911925        self.visit(node.value) 
     
    913927    def visit_Lambda(self, node): 
    914928        self.unsupported(node) 
     929 
    915930        self.write_python('lambda ') 
    916931        self.visit(node.args) 
     
    920935    def visit_Ellipsis(self, node): 
    921936        self.unsupported(node) 
     937 
    922938        self.write_python('Ellipsis') 
    923939 
     
    940956    def visit_DictComp(self, node): 
    941957        self.unsupported(node) 
     958 
    942959        self.write_python('{') 
    943960        self.visit(node.key) 
     
    969986    def visit_alias(self, node): 
    970987        self.unsupported(node) 
     988 
    971989        self.write_python(node.name) 
    972990        if node.asname is not None: 
     
    10311049    const = "constant "  # OpenCL needs globals to be constant 
    10321050    if isinstance(value, int): 
    1033         parts = [const + "int ", name, " = ", "%d"%value, ";"] 
     1051        parts = [const + "int ", name, " = ", "%d"%value, ";\n"] 
    10341052    elif isinstance(value, float): 
    1035         parts = [const + "double ", name, " = ", "%.15g"%value, ";"] 
     1053        parts = [const + "double ", name, " = ", "%.15g"%value, ";\n"] 
    10361054    else: 
    10371055        try: 
     
    10471065        elements = ["%.15g"%v for v in value] 
    10481066        parts = [const + "double ", name, "[]", " = ", 
    1049                  "{\n   ", ", ".join(elements), "\n};"] 
     1067                 "{\n   ", ", ".join(elements), "\n};\n"] 
    10501068 
    10511069    return "".join(parts) 
     
    11001118    #snippets.append("") 
    11011119    for source, fname, lineno in functions: 
    1102         line_directive = '#line %d "%s"'%(lineno, fname.replace('\\', '\\\\')) 
     1120        line_directive = '#line %d "%s"\n'%(lineno, fname.replace('\\', '\\\\')) 
    11031121        snippets.append(line_directive) 
    11041122        tree = ast.parse(source) 
     
    11331151            .replace(name+'.w', 'GAUSS_W')) 
    11341152 
    1135     translation = translate([(code, fname_in, 1)])[0] 
     1153    translation = translate([(code, fname_in, 1)]) 
    11361154 
    11371155    with open(fname_out, "w") as file_out: 
    1138         file_out.write(translation) 
     1156        file_out.write("".join(translation)) 
    11391157    print("...Done") 
    11401158 
Note: See TracChangeset for help on using the changeset viewer.