diff options
author | Stefan van der Walt <stefan@sun.ac.za> | 2007-01-08 21:56:54 +0000 |
---|---|---|
committer | Stefan van der Walt <stefan@sun.ac.za> | 2007-01-08 21:56:54 +0000 |
commit | 1bd2d49ef378fb869d015cef32c3e44a4c03a8f0 (patch) | |
tree | 43335baf1da0b6e9de0ad806e721a077e3cbfa45 /numpy/f2py | |
parent | 98b6d48b07f4eadfb7d1fc41483debe7e07eecd6 (diff) | |
download | numpy-1bd2d49ef378fb869d015cef32c3e44a4c03a8f0.tar.gz |
Whitespace cleanup.
Diffstat (limited to 'numpy/f2py')
34 files changed, 155 insertions, 175 deletions
diff --git a/numpy/f2py/capi_maps.py b/numpy/f2py/capi_maps.py index 8d7c156df..bc9fb28c1 100644 --- a/numpy/f2py/capi_maps.py +++ b/numpy/f2py/capi_maps.py @@ -85,7 +85,7 @@ if using_newcore: 'complex_long_double':'PyArray_CDOUBLE', 'string':'PyArray_CHAR', # f2py 2e is not ready for PyArray_STRING (must set itemisize etc) #'string':'PyArray_STRING' - + } c2pycode_map={'double':'d', 'float':'f', diff --git a/numpy/f2py/f2py_testing.py b/numpy/f2py/f2py_testing.py index f94712105..03085c28e 100644 --- a/numpy/f2py/f2py_testing.py +++ b/numpy/f2py/f2py_testing.py @@ -1,4 +1,3 @@ - import os,sys,re,time def cmdline(): diff --git a/numpy/f2py/lib/main.py b/numpy/f2py/lib/main.py index 45fd09946..911576d7d 100644 --- a/numpy/f2py/lib/main.py +++ b/numpy/f2py/lib/main.py @@ -159,7 +159,7 @@ def get_signature_output(sys_argv): def parse_files(sys_argv): flag = 'file' - file_names = [] + file_names = [] only_names = [] skip_names = [] options = [] @@ -206,7 +206,7 @@ def dump_signature(sys_argv): output_stream = open(signature_output,'w') flag = 'file' - file_names = [] + file_names = [] only_names = [] skip_names = [] options = [] @@ -245,7 +245,7 @@ def dump_signature(sys_argv): output_stream.write(block.topyf(' ')+'\n') output_stream.write(' END INTERFACE\n') output_stream.write('END PYTHON MODULE %s\n' % (modulename)) - + if signature_output not in ['stdout','stderr']: output_stream.close() return diff --git a/numpy/f2py/lib/parser/Fortran2003.py b/numpy/f2py/lib/parser/Fortran2003.py index e655ab5d2..bfdb8cbba 100644 --- a/numpy/f2py/lib/parser/Fortran2003.py +++ b/numpy/f2py/lib/parser/Fortran2003.py @@ -254,7 +254,7 @@ class SequenceBase(Base): def torepr(self): return '%s(%r, %r)' % (self.__class__.__name__, self.separator, self.items) def compare(self, other): return cmp((self.separator,self.items),(other.separator,self.items)) - + class UnaryOpBase(Base): """ <unary-op-base> = <unary-op> <rhs> @@ -265,7 +265,7 @@ class UnaryOpBase(Base): m = op_pattern.match(string) if not m: return #if not m: return rhs_cls(string) - rhs = string[m.end():].lstrip() + rhs = string[m.end():].lstrip() if not rhs: return op = string[:m.end()].rstrip().upper() return op, rhs_cls(rhs) @@ -779,7 +779,7 @@ class Executable_Construct(Base):# R213 class Executable_Construct_C201(Base): subclass_names = Executable_Construct.subclass_names[:] subclass_names[subclass_names.index('Action_Stmt')] = 'Action_Stmt_C201' - + class Action_Stmt(Base):# R214 """ @@ -966,7 +966,7 @@ class Intrinsic_Type_Spec(WORDClsBase): # R403 """ subclass_names = [] use_names = ['Kind_Selector','Char_Selector'] - + def match(string): for w,cls in [('INTEGER',Kind_Selector), ('REAL',Kind_Selector), @@ -1243,7 +1243,7 @@ class Logical_Literal_Constant(NumberBase): # R428 """ subclass_names = [] def match(string): - return NumberBase.match(pattern.abs_logical_literal_constant_named, string) + return NumberBase.match(pattern.abs_logical_literal_constant_named, string) match = staticmethod(match) class Derived_Type_Def(Base): # R429 @@ -1394,7 +1394,7 @@ class Type_Param_Decl(BinaryOpBase): # R436 if not lhs or not rhs: return return Type_Param_Name(lhs),'=',Scalar_Int_Initialization_Expr(rhs) match = staticmethod(match) - + class Type_Param_Attr_Spec(STRINGBase): # R437 """ <type-param-attr-spec> = KIND @@ -1814,7 +1814,7 @@ class Ac_Implied_Do(Base): # R470 <ac-implied-do> = ( <ac-value-list> , <ac-implied-do-control> ) """ subclass_names = [] - use_names = ['Ac_Value_List','Ac_Implied_Do_Control'] + use_names = ['Ac_Value_List','Ac_Implied_Do_Control'] def match(string): if string[0]+string[-1] != '()': return line, repmap = string_replace_map(string[1:-1].strip()) @@ -1830,7 +1830,7 @@ class Ac_Implied_Do(Base): # R470 class Ac_Implied_Do_Control(Base): # R471 """ - <ac-implied-do-control> = <ac-do-variable> = <scalar-int-expr> , <scalar-int-expr> [ , <scalar-int-expr> ] + <ac-implied-do-control> = <ac-do-variable> = <scalar-int-expr> , <scalar-int-expr> [ , <scalar-int-expr> ] """ subclass_names = [] use_names = ['Ac_Do_Variable','Scalar_Int_Expr'] @@ -1849,7 +1849,7 @@ class Ac_Implied_Do_Control(Base): # R471 class Ac_Do_Variable(Base): # R472 """ <ac-do-variable> = <scalar-int-variable> - <ac-do-variable> shall be a named variable + <ac-do-variable> shall be a named variable """ subclass_names = ['Scalar_Int_Variable'] @@ -2021,7 +2021,7 @@ class Entity_Decl(Base): # R504 if self.items[3] is not None: s += ' ' + str(self.items[3]) return s - + class Object_Name(Base): # R505 """ <object-name> = <name> @@ -2031,7 +2031,7 @@ class Object_Name(Base): # R505 class Initialization(Base): # R506 """ <initialization> = = <initialization-expr> - | => <null-init> + | => <null-init> """ subclass_names = [] use_names = ['Initialization_Expr', 'Null_Init'] @@ -2122,7 +2122,7 @@ class Explicit_Shape_Spec(SeparatorBase): # R511 def tostr(self): if self.items[0] is None: return str(self.items[1]) return SeparatorBase.tostr(self) - + class Lower_Bound(Base): # R512 """ <lower-bound> = <specification-expr> @@ -2182,7 +2182,7 @@ class Assumed_Size_Spec(Base): # R516 s += str(self.items[1]) + ' : ' s += '*' return s - + class Intent_Spec(STRINGBase): # R517 """ <intent-spec> = IN @@ -2218,7 +2218,7 @@ class Object_Name_Deferred_Shape_Spec_List_Item(CallBase): use_names = ['Deferred_Shape_Spec_List'] def match(string): return CallBase.match(Object_Name, Deferred_Shape_Spec_List, string, require_rhs=True) match = staticmethod(match) - + class Allocatable_Stmt(StmtBase, WORDClsBase): # R520 """ <allocateble-stmt> = ALLOCATABLE [ :: ] <object-name> [ ( <deferred-shape-spec-list> ) ] [ , <object-name> [ ( <deferred-shape-spec-list> ) ] ]... @@ -2229,7 +2229,7 @@ class Allocatable_Stmt(StmtBase, WORDClsBase): # R520 return WORDClsBase.match('ALLOCATABLE', Object_Name_Deferred_Shape_Spec_List_Item_List, string, check_colons=True, require_cls=True) match = staticmethod(match) - + class Asynchronous_Stmt(StmtBase, WORDClsBase): # R521 """ <asynchronous-stmt> = ASYNCHRONOUS [ :: ] <object-name-list> @@ -2331,7 +2331,7 @@ class Data_Stmt_Value(Base): # R530 return Data_Stmt_Repeat(lhs), Data_Stmt_Constant(rhs) match = staticmethod(match) def tostr(self): - return '%s * %s' % self.items + return '%s * %s' % self.items class Data_Stmt_Repeat(Base): # R531 """ @@ -2420,7 +2420,7 @@ class Optional_Stmt(StmtBase, WORDClsBase): # R537 def match(string): return WORDClsBase.match('OPTIONAL',Dummy_Arg_Name_List,string,check_colons=True, require_cls=True) match = staticmethod(match) tostr = WORDClsBase.tostr_a - + class Parameter_Stmt(StmtBase, CALLBase): # R538 """ <parameter-stmt> = PARAMETER ( <named-constant-def-list> ) @@ -2438,7 +2438,7 @@ class Named_Constant_Def(KeywordValueBase): # R539 use_names = ['Named_Constant', 'Initialization_Expr'] def match(string): return KeywordValueBase.match(Named_Constant, Initialization_Expr, string) match = staticmethod(match) - + class Pointer_Stmt(StmtBase, WORDClsBase): # R540 """ <pointer-stmt> = POINTER [ :: ] <pointer-decl-list> @@ -2448,7 +2448,7 @@ class Pointer_Stmt(StmtBase, WORDClsBase): # R540 def match(string): return WORDClsBase.match('POINTER',Pointer_Decl_List,string,check_colons=True, require_cls=True) match = staticmethod(match) tostr = WORDClsBase.tostr_a - + class Pointer_Decl(CallBase): # R541 """ <pointer-decl> = <object-name> [ ( <deferred-shape-spec-list> ) ] @@ -2522,7 +2522,7 @@ class Volatile_Stmt(StmtBase, WORDClsBase): # R548 def match(string): return WORDClsBase.match('VOLATILE',Object_Name_List,string,check_colons=True, require_cls=True) match = staticmethod(match) tostr = WORDClsBase.tostr_a - + class Implicit_Stmt(StmtBase, WORDClsBase): # R549 """ <implicit-stmt> = IMPLICIT <implicit-spec-list> @@ -2783,7 +2783,7 @@ class Parent_String(Base): # R610 <parent-string> = <scalar-variable-name> | <array-element> | <scalar-structure-component> - | <scalar-constant> + | <scalar-constant> """ subclass_names = ['Scalar_Variable_Name', 'Array_Element', 'Scalar_Structure_Component', 'Scalar_Constant'] @@ -2915,7 +2915,7 @@ class Allocate_Stmt(StmtBase): # R623 """ subclass_names = [] use_names = ['Type_Spec', 'Allocation_List', 'Alloc_Opt_List'] - + class Alloc_Opt(KeywordValueBase):# R624 """ <alloc-opt> = STAT = <stat-variable> @@ -2966,7 +2966,7 @@ class Allocation(CallBase):# R628 def match(string): return CallBase.match(Allocate_Object, Allocate_Shape_Spec_List, string, require_rhs = True) match = staticmethod(match) - + class Allocate_Object(Base): # R629 """ <allocate-object> = <variable-name> @@ -3015,7 +3015,7 @@ class Nullify_Stmt(StmtBase, CALLBase): # R633 use_names = ['Pointer_Object_List'] def match(string): return CALLBase.match('NULLIFY', Pointer_Object_List, string, require_rhs=True) match = staticmethod(match) - + class Pointer_Object(Base): # R634 """ <pointer-object> = <variable-name> @@ -3070,7 +3070,7 @@ class Primary(Base): # R701 """ subclass_names = ['Constant', 'Parenthesis', 'Designator','Array_Constructor', 'Structure_Constructor', - 'Function_Reference', 'Type_Param_Inquiry', 'Type_Param_Name', + 'Function_Reference', 'Type_Param_Inquiry', 'Type_Param_Name', ] class Parenthesis(BracketBase): # R701.h @@ -3098,14 +3098,14 @@ class Level_1_Expr(UnaryOpBase): # R702 class Defined_Unary_Op(STRINGBase): # R703 """ - <defined-unary-op> = . <letter> [ <letter> ]... . + <defined-unary-op> = . <letter> [ <letter> ]... . """ subclass_names = ['Defined_Op'] class Defined_Op(STRINGBase): # R703, 723 """ - <defined-op> = . <letter> [ <letter> ]... . + <defined-op> = . <letter> [ <letter> ]... . """ subclass_names = [] def match(string): @@ -3208,7 +3208,7 @@ class And_Operand(UnaryOpBase): # R714 class Or_Operand(BinaryOpBase): # R715 """ - <or-operand> = [ <or-operand> <and-op> ] <and-operand> + <or-operand> = [ <or-operand> <and-op> ] <and-operand> <and-op> = .AND. """ subclass_names = ['And_Operand'] @@ -3264,7 +3264,7 @@ class Expr(BinaryOpBase): # R722 class Defined_Unary_Op(STRINGBase): # R723 """ - <defined-unary-op> = . <letter> [ <letter> ]... . + <defined-unary-op> = . <letter> [ <letter> ]... . """ subclass_names = ['Defined_Op'] @@ -3337,7 +3337,7 @@ class Assignment_Stmt(StmtBase, BinaryOpBase): # R734 def match(string): return BinaryOpBase.match(Variable, '=', Expr, string, right=False) match = staticmethod(match) - + class Pointer_Assignment_Stmt(StmtBase): # R735 """ <pointer-assignment-stmt> = <data-pointer-object> [ ( <bounds-spec-list> ) ] => <data-target> @@ -3356,7 +3356,7 @@ class Data_Pointer_Object(BinaryOpBase): # R736 subclass_names = ['Variable_Name'] use_names = ['Variable', 'Data_Pointer_Component_Name'] def match(string): - return BinaryOpBase.match(Variable, r'%', Data_Pointer_Component_Name, string) + return BinaryOpBase.match(Variable, r'%', Data_Pointer_Component_Name, string) match = staticmethod(match) class Bounds_Spec(SeparatorBase): # R737 @@ -3398,7 +3398,7 @@ class Proc_Component_Ref(BinaryOpBase): # R741 subclass_names = [] use_names = ['Variable','Procedure_Component_Name'] def match(string): - return BinaryOpBase.match(Variable, r'%', Procedure_Component_Name, string) + return BinaryOpBase.match(Variable, r'%', Procedure_Component_Name, string) match = staticmethod(match) class Proc_Target(Base): # R742 @@ -3429,7 +3429,7 @@ class Where_Stmt(StmtBase): # R743 return Mask_Expr(expr), Where_Assignment_Stmt(stmt) match = staticmethod(match) def tostr(self): return 'WHERE (%s) %s' % tuple(self.items) - + class Where_Construct(Base): # R744 """ @@ -3507,7 +3507,7 @@ class Masked_Elsewhere_Stmt(StmtBase): # R749 def tostr(self): if self.items[1] is None: return 'ELSEWHERE(%s)' % (self.items[0]) return 'ELSEWHERE(%s) %s' % self.items - + class Elsewhere_Stmt(StmtBase, WORDClsBase): # R750 """ <elsewhere-stmt> = ELSEWHERE [ <where-construct-name> ] @@ -3957,7 +3957,7 @@ class Type_Guard_Stmt(StmtBase): # R823 if self.items[2] is not None: s += ' %s' % (self.items[2]) return s - + class End_Select_Type_Stmt(EndStmtBase): # R824 """ <end-select-type-stmt> = END SELECT [ <select-construct-name> ] @@ -4051,7 +4051,7 @@ class Label_Do_Stmt(StmtBase): # R828 def tostr(self): if self.itens[1] is None: return 'DO %s' % (self.items[0]) return 'DO %s %s' % self.items - + class Nonlabel_Do_Stmt(StmtBase, WORDClsBase): # R829 """ <nonlabel-do-stmt> = [ <do-construct-name> : ] DO [ <loop-control> ] @@ -4087,7 +4087,7 @@ class Loop_Control(Base): # R830 def tostr(self): if len(self.items)==1: return ', WHILE (%s)' % (self.items[0]) return ', %s = %s' % (self.items[0], ', '.join(map(str,self.items[1]))) - + class Do_Variable(Base): # R831 """ <do-variable> = <scalar-int-variable> @@ -4348,7 +4348,7 @@ class Open_Stmt(StmtBase, CALLBase): # R904 use_names = ['Connect_Spec_List'] def match(string): CALLBase.match('OPEN', Connect_Spec_List, string, require_rhs=True) match = staticmethod(match) - + class Connect_Spec(KeywordValueBase): # R905 """ <connect-spec> = [ UNIT = ] <file-unit-number> @@ -4473,7 +4473,7 @@ class Write_Stmt(StmtBase): # R911 def tostr(self): if self.items[1] is None: return 'WRITE(%s)' % (self.items[0]) return 'WRITE(%s) %s' % tuple(self.items) - + class Print_Stmt(StmtBase): # R912 """ <print-stmt> = PRINT <format> [ , <output-item-list> ] @@ -4496,7 +4496,7 @@ class Print_Stmt(StmtBase): # R912 def tostr(self): if self.items[1] is None: return 'PRINT %s' % (self.items[0]) return 'PRINT %s, %s' % tuple(self.items) - + class Io_Control_Spec_List(SequenceBase): # R913-list """ <io-control-spec-list> is a list taking into account C910, C917, C918 @@ -5049,7 +5049,7 @@ class Sign_Edit_Desc(STRINGBase): # R1015 subclass_names = [] def match(string): return STRINGBase.match(['SS','SP','S'], string) match = staticmethod(match) - + class Blank_Interp_Edit_Desc(STRINGBase): # R1016 """ <blank-interp-edit-desc> = BN @@ -5210,7 +5210,7 @@ class Use_Stmt(StmtBase): # R1109 if self.items[3] is not None: s += ' %s' % (self.items[3]) return s - + class Module_Nature(STRINGBase): # R1110 """ <module-nature> = INTRINSIC @@ -5397,7 +5397,7 @@ class Import_Stmt(StmtBase, WORDClsBase): # R1209 def match(string): return WORDClsBase.match('IMPORT',Import_Name_List,string,check_colons=True, require_cls=True) match = staticmethod(match) tostr = WORDClsBase.tostr_a - + class External_Stmt(StmtBase, WORDClsBase): # R1210 """ <external-stmt> = EXTERNAL [ :: ] <external-name-list> @@ -5407,7 +5407,7 @@ class External_Stmt(StmtBase, WORDClsBase): # R1210 def match(string): return WORDClsBase.match('EXTERNAL',External_Name_List,string,check_colons=True, require_cls=True) match = staticmethod(match) tostr = WORDClsBase.tostr_a - + class Procedure_Declaration_Stmt(StmtBase): # R1211 """ <procedure-declaration-stmt> = PROCEDURE ( [ <proc-interface> ] ) [ [ , <proc-attr-spec> ]... :: ] <proc-decl-list> @@ -5441,7 +5441,7 @@ class Proc_Decl(BinaryOpBase): # R1214 use_names = ['Null_Init'] def match(string): return BinaryOpBase.match(Procedure_Entity_Name,'=>', Null_Init, string) match = staticmethod(match) - + class Interface_Name(Base): # R1215 """ <interface-name> = <name> @@ -5457,7 +5457,7 @@ class Intrinsic_Stmt(StmtBase, WORDClsBase): # R1216 def match(string): return WORDClsBase.match('INTRINSIC',Intrinsic_Procedure_Name_List,string,check_colons=True, require_cls=True) match = staticmethod(match) tostr = WORDClsBase.tostr_a - + class Function_Reference(CallBase): # R1217 """ <function-reference> = <procedure-designator> ( [ <actual-arg-spec-list> ] ) @@ -5730,7 +5730,7 @@ class Return_Stmt(StmtBase): # R1236 if len(string)==6: return None, return Scalar_Int_Expr(string[6:].lstrip()), match = staticmethod(match) - def tostr(self): + def tostr(self): if self.items[0] is None: return 'RETURN' return 'RETURN %s' % self.items @@ -5833,11 +5833,11 @@ if 1: # Optimize subclass tree: l = [] for n in getattr(cls,'subclass_names',[]): l1 = _rpl_list(n) - for n1 in l1: + for n1 in l1: if n1 not in l: l.append(n1) return l - + for cls in Base_classes.values(): if not hasattr(cls, 'subclass_names'): continue opt_subclass_names = [] @@ -5881,7 +5881,7 @@ if 1: break if n not in subclasses_names: print '%s needs to be added to %s subclass_name list' % (n,cls.__name__) - for n in use_names + subclass_names: + for n in use_names + subclass_names: if not Base_classes.has_key(n): print '%s not defined used by %s' % (n, cls.__name__) diff --git a/numpy/f2py/lib/parser/base_classes.py b/numpy/f2py/lib/parser/base_classes.py index b2fa3511c..68ea9c24a 100644 --- a/numpy/f2py/lib/parser/base_classes.py +++ b/numpy/f2py/lib/parser/base_classes.py @@ -95,7 +95,7 @@ def get_base_classes(cls): bases = () for c in cls.__bases__: bases += get_base_classes(c) - return bases + cls.__bases__ + (cls,) + return bases + cls.__bases__ + (cls,) class Variable: """ @@ -391,7 +391,7 @@ class Variable: def is_array_pointer(self): return self.is_array() and self.is_pointer() - + def analyze(self): typedecl = self.get_typedecl() if self.is_array(): @@ -406,7 +406,7 @@ class Variable: shape.append(spec[0]) else: shape.append(spec[1]-spec[0]) - self.shape = shape + self.shape = shape return class ProgramBlock: @@ -528,7 +528,7 @@ class Statement: lines.append(line+'\n') else: lines.append(line+'\n') return ''.join(lines).replace('\n &\n','\n') - + def format_message(self, kind, message): if self.item is not None: message = self.reader.format_message(kind, message, @@ -613,7 +613,7 @@ class BeginStatement(Statement): self.blocktype = self.__class__.__name__.lower() if not hasattr(self, 'name'): # process_item may change this - self.name = '__'+self.blocktype.upper()+'__' + self.name = '__'+self.blocktype.upper()+'__' Statement.__init__(self, parent, item) return @@ -701,7 +701,7 @@ class BeginStatement(Statement): return False # item may be cloned that changes the items line: line = item.get_line() - + # Check if f77 code contains inline comments or other f90 # constructs that got undetected by get_source_info. if item.reader.isfix77: @@ -734,10 +734,10 @@ class BeginStatement(Statement): % (item.get_line(),self.__class__.__name__), item.span[0], item.span[1]) self.show_message(message) - + item.reader.set_mode(False, False) self.classes = classes - + r = BeginStatement.process_subitem(self, item) if r is None: # restore f77 fix mode @@ -817,4 +817,3 @@ class EndStatement(Statement): def tofortran(self, isfix=None): return self.get_indent_tab(isfix=isfix) + 'END %s %s'\ % (self.blocktype.upper(),self.name or '') - diff --git a/numpy/f2py/lib/parser/block_statements.py b/numpy/f2py/lib/parser/block_statements.py index 7e3f41d86..b3d29c911 100644 --- a/numpy/f2py/lib/parser/block_statements.py +++ b/numpy/f2py/lib/parser/block_statements.py @@ -391,7 +391,7 @@ class Program(BeginStatement, ProgramBlock, class EndBlockData(EndStatement): """ - END [ BLOCK DATA [ <block-data-name> ] ] + END [ BLOCK DATA [ <block-data-name> ] ] """ match = re.compile(r'end(\s*block\s*data\s*\w*|)\Z', re.I).match blocktype = 'blockdata' @@ -410,7 +410,7 @@ class BlockData(BeginStatement, HasImplicitStmt, HasUseStmt, def get_classes(self): return specification_part - + # Interface class EndInterface(EndStatement): @@ -432,7 +432,7 @@ class Interface(BeginStatement, HasImplicitStmt, HasUseStmt, | READ ( UNFORMATTED ) | WRITE ( FORMATTED ) | WRITE ( UNFORMATTED ) - + """ modes = ['free90', 'fix90', 'pyf'] match = re.compile(r'(interface\s*(\w+\s*\(.*\)|\w*)|abstract\s*interface)\Z',re.I).match @@ -444,7 +444,7 @@ class Interface(BeginStatement, HasImplicitStmt, HasUseStmt, def get_classes(self): l = intrinsic_type_spec + interface_specification if self.reader.mode=='pyf': - return [Subroutine, Function] + l + return [Subroutine, Function] + l return l def process_item(self): @@ -498,7 +498,7 @@ class Interface(BeginStatement, HasImplicitStmt, HasUseStmt, s += HasAttributes.topyf(self, tab=tab+' ') s += HasUseStmt.topyf(self, tab=tab+' ') s += tab + 'END' + self.tostr() + '\n' - return s + return s # Subroutine @@ -729,7 +729,7 @@ class EndSelect(EndStatement): class Select(BeginStatement): """ [ <case-construct-name> : ] SELECT CASE ( <case-expr> ) - + """ match = re.compile(r'select\s*case\s*\(.*\)\Z',re.I).match end_stmt_cls = EndSelect @@ -738,7 +738,7 @@ class Select(BeginStatement): return 'SELECT CASE ( %s )' % (self.expr) def process_item(self): self.expr = self.item.get_line()[6:].lstrip()[4:].lstrip()[1:-1].strip() - self.name = self.item.label + self.name = self.item.label return BeginStatement.process_item(self) def get_classes(self): @@ -751,7 +751,7 @@ class EndWhere(EndStatement): END WHERE [ <where-construct-name> ] """ match = re.compile(r'end\s*\where\s*\w*\Z',re.I).match - + class Where(BeginStatement): """ @@ -782,7 +782,7 @@ class EndForall(EndStatement): END FORALL [ <forall-construct-name> ] """ match = re.compile(r'end\s*forall\s*\w*\Z',re.I).match - + class Forall(BeginStatement): """ [ <forall-construct-name> : ] FORALL <forall-header> @@ -842,7 +842,7 @@ class IfThen(BeginStatement): self.expr = line[1:-1].strip() self.name = item.label return BeginStatement.process_item(self) - + def get_classes(self): return [Else, ElseIf] + execution_part_construct @@ -883,7 +883,7 @@ class If(BeginStatement): self.put_item(newitem) self.isvalid = False return - + def tostr(self): assert len(self.content)==1,`self.content` return 'IF (%s) %s' % (self.expr, str(self.content[0]).lstrip()) @@ -959,7 +959,7 @@ class Associate(BeginStatement): """ match = re.compile(r'associate\s*\(.*\)\Z',re.I).match end_stmt_cls = EndAssociate - + def process_item(self): line = self.item.get_line()[9:].lstrip() self.associations = line[1:-1].strip() @@ -1090,7 +1090,7 @@ class Type(BeginStatement, HasVariables, HasAttributes, AccessSpecs): def topyf(self, tab=''): s = tab + 'TYPE' if self.a.extends is not None: - s += ', EXTENDS(%s) ::' % (self.a.extends) + s += ', EXTENDS(%s) ::' % (self.a.extends) s += ' ' + self.name if self.a.parameters: s += ' (%s)' % (', '.join(self.a.parameters)) @@ -1171,7 +1171,7 @@ intrinsic_type_spec = [ SubprogramPrefix, Integer , Real, derived_type_spec = [ ] type_spec = intrinsic_type_spec + derived_type_spec declaration_type_spec = intrinsic_type_spec + [ TypeStmt, Class ] - + type_declaration_stmt = declaration_type_spec private_or_sequence = [ Private, Sequence ] diff --git a/numpy/f2py/lib/parser/parsefortran.py b/numpy/f2py/lib/parser/parsefortran.py index 71b019122..08716e7c8 100644 --- a/numpy/f2py/lib/parser/parsefortran.py +++ b/numpy/f2py/lib/parser/parsefortran.py @@ -79,7 +79,7 @@ class FortranParser: if self.block is None: self.reader.show_message('Nothing to analyze.') return - + try: self.block.analyze() except AnalyzeError: @@ -129,9 +129,9 @@ module foo hey = 1 end subroutine bar abstract interface - + end interface - + end module foo """ reader = FortranStringReader(string, True, False) @@ -195,4 +195,3 @@ if __name__ == "__main__": simple_main() #profile_main() #parse_all_f() - diff --git a/numpy/f2py/lib/parser/readfortran.py b/numpy/f2py/lib/parser/readfortran.py index dfe64b4f1..e3acffa36 100644 --- a/numpy/f2py/lib/parser/readfortran.py +++ b/numpy/f2py/lib/parser/readfortran.py @@ -52,9 +52,9 @@ class FortranReaderError: # TODO: may be derive it from Exception class Line: """ Holds a Fortran source line. """ - + f2py_strmap_findall = re.compile(r'(_F2PY_STRING_CONSTANT_\d+_|F2PY_EXPR_TUPLE_\d+)').findall - + def __init__(self, line, linenospan, label, reader): self.line = line.strip() self.span = linenospan @@ -87,7 +87,7 @@ class Line: self.line = self.apply_map(line) self.strline = None return - + def __repr__(self): return self.__class__.__name__+'(%r,%s,%r)' \ % (self.line, self.span, self.label) @@ -182,7 +182,7 @@ class FortranReaderBase: used to retrive a line. source may contain - Fortran 77 code - - fixed format Fortran 90 code + - fixed format Fortran 90 code - free format Fortran 90 code - .pyf signatures - extended free format Fortran 90 syntax """ @@ -277,7 +277,7 @@ class FortranReaderBase: return self def next(self, ignore_comments = False): - + try: if self.reader is not None: try: @@ -402,7 +402,7 @@ class FortranReaderBase: break linenostr = '%5d:' % (i) if i==endlineno: - sourceline = self.source_lines[i-1] + sourceline = self.source_lines[i-1] l0 = linenostr+sourceline[:startcolno] if endcolno==-1: l1 = sourceline[startcolno:] @@ -414,7 +414,7 @@ class FortranReaderBase: else: r.append(linenostr+ self.source_lines[i-1]) return '\n'.join(r) - + def format_error_message(self, message, startlineno, endlineno, startcolno=0, endcolno=-1): return self.format_message('ERROR',message, startlineno, @@ -555,7 +555,7 @@ class FortranReaderBase: # XXX: should we do line.replace('\\'+mlstr[0],mlstr[0]) # for line in multilines? return self.multiline_item(prefix,multilines,suffix, - startlineno, self.linecount) + startlineno, self.linecount) # The main method of interpreting raw source lines within # the following contexts: f77, fixed f90, free f90, pyf. @@ -565,7 +565,7 @@ class FortranReaderBase: a source item is .. - a fortran line - a list of continued fortran lines - - a multiline - lines inside triple-qoutes, only when in ispyf mode + - a multiline - lines inside triple-qoutes, only when in ispyf mode """ get_single_line = self.get_single_line line = get_single_line() @@ -613,7 +613,7 @@ class FortranReaderBase: return self.line_item(''.join(lines),startlineno,self.linecount,label) handle_inline_comment = self.handle_inline_comment - + if self.isfix90 and not is_f2py_directive: # handle inline comment newline,qc = handle_inline_comment(line[6:], startlineno) @@ -739,7 +739,7 @@ class FortranFileReader(FortranReaderBase): self.file.close() class FortranStringReader(FortranReaderBase): - + def __init__(self, string, isfree, isstrict, include_dirs = None): self.id = 'string-'+str(id(string)) source = StringIO(string) @@ -765,7 +765,7 @@ cf2py call me ! hey reader = FortranStringReader(string_f77,False,True) for item in reader: print item - + filename = tempfile.mktemp()+'.f' f = open(filename,'w') f.write(string_f77) @@ -823,7 +823,7 @@ cComment obj%bin_wid,' VEL_DMO = ', obj%vel_dmo end subroutine foo subroutine - + & foo end """ diff --git a/numpy/f2py/lib/parser/sourceinfo.py b/numpy/f2py/lib/parser/sourceinfo.py index 2f5aab603..7eb980251 100644 --- a/numpy/f2py/lib/parser/sourceinfo.py +++ b/numpy/f2py/lib/parser/sourceinfo.py @@ -76,6 +76,6 @@ def simple_main(): for filename in sys.argv[1:]: isfree, isstrict = get_source_info(filename) print '%s: isfree=%s, isstrict=%s' % (filename, isfree, isstrict) - + if __name__ == '__main__': simple_main() diff --git a/numpy/f2py/lib/parser/splitline.py b/numpy/f2py/lib/parser/splitline.py index b933602d4..9d4a40fc5 100644 --- a/numpy/f2py/lib/parser/splitline.py +++ b/numpy/f2py/lib/parser/splitline.py @@ -209,7 +209,7 @@ class LineSplitter(LineSplitterBase): quotechar = self.quotechar l = [] l_append = l.append - + nofslashes = 0 if quotechar is None: # search for string start @@ -323,7 +323,7 @@ class LineSplitterParen(LineSplitterBase): self.startchar = paren[0] self.endchar = paren[1] self.stopchar = None - + def get_item(self): fifo_pop = self.fifo_line.pop try: @@ -336,7 +336,7 @@ class LineSplitterParen(LineSplitterBase): stopchar = self.stopchar l = [] l_append = l.append - + nofslashes = 0 if stopchar is None: # search for parenthesis start @@ -377,7 +377,7 @@ class LineSplitterParen(LineSplitterBase): except IndexError: break return ParenString(''.join(l)) - + def test(): splitter = LineSplitter('abc\\\' def"12\\"3""56"dfad\'a d\'') l = [item for item in splitter] @@ -394,7 +394,7 @@ def test(): l,stopchar = splitquote('"abc123&') assert l==['"abc123&'],`l` assert stopchar=='"' - + splitter = LineSplitter(' &abc"123','"') l = [item for item in splitter] assert l==[' &abc"','123'] @@ -402,7 +402,7 @@ def test(): l,stopchar = splitquote(' &abc"123','"') assert l==[' &abc"','123'] assert stopchar is None - + l = split2('') assert l==('',''),`l` l = split2('12') @@ -424,4 +424,3 @@ def test(): if __name__ == '__main__': test() - diff --git a/numpy/f2py/lib/parser/statements.py b/numpy/f2py/lib/parser/statements.py index efbbca37f..b37948faf 100644 --- a/numpy/f2py/lib/parser/statements.py +++ b/numpy/f2py/lib/parser/statements.py @@ -95,7 +95,7 @@ class GeneralAssignment(Statement): if sign=='=>': self.__class__ = PointerAssignment else: - self.__class__ = Assignment + self.__class__ = Assignment apply_map = self.item.apply_map self.variable = apply_map(m.group('variable').replace(' ','')) self.expr = apply_map(m.group('expr')) @@ -247,7 +247,7 @@ class AssignedGoto(Statement): tab = self.get_indent_tab(isfix=isfix) if self.items: return tab + 'GO TO %s (%s)' \ - % (self.varname, ', '.join(self.items)) + % (self.varname, ', '.join(self.items)) return tab + 'GO TO %s' % (self.varname) def analyze(self): return @@ -339,7 +339,7 @@ Read0: READ ( <io-control-spec-list> ) [ <input-item-list> ] | [ NML = ] <namelist-group-name> | ADVANCE = <scalar-default-char-expr> ... - + Read1: READ <format> [, <input-item-list>] <format> == <default-char-expr> | <label> | * """ @@ -525,7 +525,7 @@ class Deallocate(Statement): def tofortran(self, isfix=None): return self.get_indent_tab(isfix=isfix) \ + 'DEALLOCATE (%s)' % (', '.join(self.items)) def analyze(self): return - + class ModuleProcedure(Statement): """ [ MODULE ] PROCEDURE <procedure-name-list> @@ -704,7 +704,7 @@ class Format(Statement): ... <sign-edit-descr> = SS | SP | S ... - + """ match = re.compile(r'format\s*\(.*\)\Z', re.I).match def process_item(self): @@ -775,7 +775,7 @@ class Data(Statement): | <substring> <array-element> = <data-ref> <array-section> = <data-ref> [ ( <substring-range> ) ] - + """ match = re.compile(r'data\b',re.I).match @@ -903,7 +903,7 @@ class Use(Statement): module = modules[self.name] use_provides = self.parent.a.use_provides print use - + return class Exit(Statement): @@ -966,7 +966,7 @@ class Equivalence(Statement): class Dimension(Statement): """ DIMENSION [ :: ] <array-name> ( <array-spec> ) [ , <array-name> ( <array-spec> ) ]... - + """ match = re.compile(r'dimension\b', re.I).match def process_item(self): @@ -990,7 +990,7 @@ class Dimension(Statement): class Target(Statement): """ TARGET [ :: ] <object-name> ( <array-spec> ) [ , <object-name> ( <array-spec> ) ]... - + """ match = re.compile(r'target\b', re.I).match def process_item(self): @@ -1018,7 +1018,7 @@ class Pointer(Statement): POINTER [ :: ] <pointer-decl-list> <pointer-decl> = <object-name> [ ( <deferred-shape-spec-list> ) ] | <proc-entity-name> - + """ match = re.compile(r'pointer\b',re.I).match def process_item(self): @@ -1111,7 +1111,7 @@ class Inquire(Statement): """ INQUIRE ( <inquire-spec-list> ) INQUIRE ( IOLENGTH = <scalar-int-variable> ) <output-item-list> - + <inquire-spec> = [ UNIT = ] <file-unit-number> | FILE = <file-name-expr> ... @@ -1495,7 +1495,7 @@ class GenericBinding(Statement): s += ' :: ' + self.spec + ' => ' + ', '.join(self.items) return tab + s - + class FinalBinding(StatementWithNamelist): """ FINAL [ :: ] <final-subroutine-name-list> @@ -1515,7 +1515,7 @@ class Allocatable(Statement): self.items = split_comma(line, self.item) return def tofortran(self, isfix=None): - return self.get_indent_tab(isfix=isfix) + 'ALLOCATABLE ' + ', '.join(self.items) + return self.get_indent_tab(isfix=isfix) + 'ALLOCATABLE ' + ', '.join(self.items) def analyze(self): for line in self.items: i = line.find('(') @@ -1583,7 +1583,7 @@ class Else(Statement): if self.name and self.name!=parent_name: self.warning('expected if-construct-name %r but got %r, skipping.'\ % (parent_name, self.name)) - self.isvalid = False + self.isvalid = False return def tofortran(self, isfix=None): @@ -1610,9 +1610,9 @@ class ElseIf(Statement): if self.name and self.name!=parent_name: self.warning('expected if-construct-name %r but got %r, skipping.'\ % (parent_name, self.name)) - self.isvalid = False + self.isvalid = False return - + def tofortran(self, isfix=None): s = '' if self.name: @@ -1658,7 +1658,7 @@ class Case(Statement): if self.name and self.name!=parent_name: self.warning('expected case-construct-name %r but got %r, skipping.'\ % (parent_name, self.name)) - self.isvalid = False + self.isvalid = False return def tofortran(self, isfix=None): @@ -1854,4 +1854,3 @@ class Pause(Statement): return self.get_indent_tab(isfix=isfix) + 'PAUSE ' + self.value return self.get_indent_tab(isfix=isfix) + 'PAUSE' def analyze(self): return - diff --git a/numpy/f2py/lib/parser/test_Fortran2003.py b/numpy/f2py/lib/parser/test_Fortran2003.py index 99fbcc955..a8aae6081 100644 --- a/numpy/f2py/lib/parser/test_Fortran2003.py +++ b/numpy/f2py/lib/parser/test_Fortran2003.py @@ -325,7 +325,7 @@ class test_Real_Literal_Constant(NumpyTestCase): # R417 a = cls('0.0D+0') assert isinstance(a,cls),`a` assert_equal(str(a),'0.0D+0') - + class test_Char_Selector(NumpyTestCase): # R424 def check_char_selector(self): @@ -343,7 +343,7 @@ class test_Char_Selector(NumpyTestCase): # R424 a = cls('(2, 8)') assert isinstance(a,cls),`a` assert_equal(str(a),'(LEN = 2, KIND = 8)') - + a = cls('(kind=8)') assert isinstance(a,cls),`a` assert_equal(str(a),'(KIND = 8)') @@ -728,7 +728,7 @@ class test_Structure_Constructor(NumpyTestCase): # R457 a = cls('a') assert isinstance(a,Name),`a` assert_equal(str(a),'a') - + class test_Component_Spec(NumpyTestCase): # R458 def check_simple(self): @@ -820,7 +820,7 @@ class test_Ac_Value_List(NumpyTestCase): # R469-list assert_equal(str(a),'a') class test_Ac_Implied_Do(NumpyTestCase): # R470 - + def check_ac_implied_do(self): cls = Ac_Implied_Do a = cls('( a, b, n = 1, 5 )') @@ -876,7 +876,7 @@ class test_Declaration_Type_Spec(NumpyTestCase): # R502 a = cls('Integer*2') assert isinstance(a, Intrinsic_Type_Spec),`a` assert_equal(str(a), 'INTEGER*2') - + a = cls('type(foo)') assert isinstance(a, cls),`a` assert_equal(str(a), 'TYPE(foo)') @@ -969,7 +969,7 @@ class test_Explicit_Shape_Spec(NumpyTestCase): # R511 assert_equal(str(a),'a') class test_Upper_Bound(NumpyTestCase): # R513 - + def check_simple(self): cls = Upper_Bound a = cls('a') @@ -1055,7 +1055,7 @@ class test_Parameter_Stmt(NumpyTestCase): # R538 a = cls('PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )') assert isinstance(a, cls),`a` assert_equal(str(a),'PARAMETER(ONE = 1.0D+0, ZERO = 0.0D+0)') - + class test_Named_Constant_Def(NumpyTestCase): # R539 def check_simple(self): @@ -1170,7 +1170,7 @@ class test_Common_Block_Object(NumpyTestCase): # R558 ############################################################################### class test_Substring(NumpyTestCase): # R609 - + def check_simple(self): cls = Substring a = cls('a(:)') @@ -1185,7 +1185,7 @@ class test_Substring(NumpyTestCase): # R609 class test_Substring_Range(NumpyTestCase): # R611 - + def check_simple(self): cls = Substring_Range a = cls(':') @@ -1237,7 +1237,7 @@ class test_Part_Ref(NumpyTestCase): # R613 assert_equal(str(a),'a') class test_Type_Param_Inquiry(NumpyTestCase): # R615 - + def check_simple(self): cls = Type_Param_Inquiry a = cls('a % b') @@ -1272,7 +1272,7 @@ class test_Section_Subscript(NumpyTestCase): # R619 a = cls('zzz') assert isinstance(a, Name),`a` assert_equal(str(a),'zzz') - + class test_Section_Subscript_List(NumpyTestCase): # R619-list def check_simple(self): @@ -1320,7 +1320,7 @@ class test_Subscript_Triplet(NumpyTestCase): # R620 assert_equal(str(a),'a + 1 :') class test_Alloc_Opt(NumpyTestCase): # R624 - + def check_simple(self): cls = Alloc_Opt a = cls('stat=a') @@ -1329,7 +1329,7 @@ class test_Alloc_Opt(NumpyTestCase): # R624 assert_equal(repr(a),"Alloc_Opt('STAT', Name('a'))") class test_Nullify_Stmt(NumpyTestCase): # R633 - + def check_simple(self): cls = Nullify_Stmt a = cls('nullify (a)') @@ -1662,7 +1662,7 @@ class test_Expr(NumpyTestCase): # R722 self.assertRaises(NoMatchError,Scalar_Int_Expr,'a,b') class test_Assignment_Stmt(NumpyTestCase): # R734 - + def check_simple(self): cls = Assignment_Stmt a = cls('a = b') @@ -1792,7 +1792,7 @@ class test_Io_Control_Spec_List(NumpyTestCase): # R913-list a = cls('123,a') assert isinstance(a, cls),`a` assert_equal(str(a),'UNIT = 123, NML = a') - + class test_Format(NumpyTestCase): # R914 def check_simple(self): @@ -2096,6 +2096,6 @@ if 1: print 'Nof tests needs:',nof_needed_tests,'out of',total_needs print 'Total number of classes:',total_classes print '-----' - + if __name__ == "__main__": NumpyTest().run() diff --git a/numpy/f2py/lib/parser/test_parser.py b/numpy/f2py/lib/parser/test_parser.py index 3921e93a3..9f1767a1a 100644 --- a/numpy/f2py/lib/parser/test_parser.py +++ b/numpy/f2py/lib/parser/test_parser.py @@ -97,7 +97,7 @@ class test_Statements(NumpyTestCase): assert_equal(parse(Read, 'read "hey a" , a'),'READ "hey a", a') assert_equal(parse(Read, 'read * , a , b'),'READ *, a, b') assert_equal(parse(Read, 'read ( unit =10 )'),'READ (UNIT = 10)') - + def check_write(self): assert_equal(parse(Write, 'write ( 10 )'),'WRITE (10)') assert_equal(parse(Write, 'write ( 10 , a )'),'WRITE (10, a)') @@ -207,7 +207,7 @@ class test_Statements(NumpyTestCase): def check_exit(self): assert_equal(parse(Exit,'exit'),'EXIT') - assert_equal(parse(Exit,'exit ab'),'EXIT ab') + assert_equal(parse(Exit,'exit ab'),'EXIT ab') def check_parameter(self): assert_equal(parse(Parameter,'parameter (a = b(1,2))'), @@ -481,7 +481,7 @@ class test_Statements(NumpyTestCase): 'CHARACTER(LEN=3, KIND=fA(1,2))') assert_equal(parse(Character,'character(len=3,kind=fA(1,2))'), 'CHARACTER(LEN=3, KIND=fa(1,2))') - + def check_implicit(self): assert_equal(parse(Implicit,'implicit none'),'IMPLICIT NONE') assert_equal(parse(Implicit,'implicit'),'IMPLICIT NONE') diff --git a/numpy/f2py/lib/parser/typedecl_statements.py b/numpy/f2py/lib/parser/typedecl_statements.py index 6aaa370fa..7414a6d2d 100644 --- a/numpy/f2py/lib/parser/typedecl_statements.py +++ b/numpy/f2py/lib/parser/typedecl_statements.py @@ -47,7 +47,7 @@ class TypeDeclarationStatement(Statement): EXTENSION: <kind-selector> = ( [ KIND = ] <scalar-int-initialization-expr> ) | * <length> - + <char-selector> = <length-selector> | ( LEN = <type-param-value>, KIND = <scalar-int-initialization-expr> ) | ( <type-param-value>, [ KIND = ] <scalar-int-initialization-expr> ) @@ -218,7 +218,7 @@ class TypeDeclarationStatement(Statement): kind = l[4:].lstrip()[1:].lstrip() l = '' else: - kind = '' + kind = '' else: assert len(l)==2 if l[0].lower().startswith('len'): @@ -257,7 +257,7 @@ class TypeDeclarationStatement(Statement): s += '*%s' % (length) if kind: s += '(KIND=%s)' % (kind) - + return clsname + s def tofortran(self,isfix=None): @@ -270,7 +270,7 @@ class TypeDeclarationStatement(Statement): if self.entity_decls: s += ' ' + ', '.join(self.entity_decls) return tab + s - + def __str__(self): return self.tofortran() @@ -415,7 +415,7 @@ class Complex(TypeDeclarationStatement): def get_part_typedecl(self): bz = self.get_byte_size()/2 return Real(self.parent, self.item.copy('REAL*%s' % (bz))) - + class DoubleComplex(TypeDeclarationStatement): # not in standard match = re.compile(r'double\s*complex\b',re.I).match @@ -474,7 +474,7 @@ class Type(TypeDeclarationStatement): def get_bit_size(self): return self.get_type_decl(self.name).get_bit_size() - + TypeStmt = Type class Class(TypeDeclarationStatement): diff --git a/numpy/f2py/lib/py_wrap.py b/numpy/f2py/lib/py_wrap.py index e8734ec08..47c8437ad 100644 --- a/numpy/f2py/lib/py_wrap.py +++ b/numpy/f2py/lib/py_wrap.py @@ -76,7 +76,7 @@ capi_err: self.defined_types = [] self.defined_capi_codes = [] - + self.header_list = [] self.typedef_list = [] self.extern_list = [] @@ -121,7 +121,7 @@ capi_err: else: raise NotImplementedError,`block.__class__.__name__` return - + def c_code(self): return self.apply_attributes(self.main_template) def fortran_code(self): diff --git a/numpy/f2py/lib/py_wrap_subprogram.py b/numpy/f2py/lib/py_wrap_subprogram.py index 70affbedb..8dd0c3efb 100644 --- a/numpy/f2py/lib/py_wrap_subprogram.py +++ b/numpy/f2py/lib/py_wrap_subprogram.py @@ -1,4 +1,3 @@ - __all__ = ['PythonCAPISubProgram'] import sys @@ -88,7 +87,7 @@ static void %(init_func)s_c(%(name)s_functype func_ptr) { if cname in defined: return defined.append(cname) - + self.info('Generating interface for %s %s: %s' % (parent.modulename, block.__class__.__name__, cname)) self.parent = parent @@ -105,7 +104,7 @@ static void %(init_func)s_c(%(name)s_functype func_ptr) { self.fortran_code_template = '' WrapperCPPMacro(parent, 'F_FUNC') - + if isinstance(block.parent, Module): self.mname = block.parent.name self.init_func = '%s_init' % (name) @@ -199,7 +198,7 @@ static void %(init_func)s_c(%(name)s_functype func_ptr) { self.ctype_args_f_list = ctype_args_f + extra_ctype_args_f if not self.ctype_args_f_list: self.ctype_args_f_list.append('void') - + self.clean_pyobjfrom_list.reverse() self.clean_call_list.reverse() diff --git a/numpy/f2py/lib/py_wrap_type.py b/numpy/f2py/lib/py_wrap_type.py index 4c50029ad..7b90e7ed1 100644 --- a/numpy/f2py/lib/py_wrap_type.py +++ b/numpy/f2py/lib/py_wrap_type.py @@ -1,4 +1,3 @@ - __all__ = ['PythonCAPIType', 'PyTypeInterface'] from wrapper_base import * @@ -331,7 +330,7 @@ static int pyobj_to_%(ctype)s(PyObject *obj, %(ctype)s* value) { #endif return return_value; } -''' +''' def __init__(self, parent, typedecl): WrapperBase.__init__(self) self.name = name = typedecl.name @@ -342,7 +341,7 @@ static int pyobj_to_%(ctype)s(PyObject *obj, %(ctype)s* value) { if ctype in defined: return defined.append(ctype) - + self.info('Generating interface for %s: %s' % (typedecl.__class__.__name__, ctype)) self.parent = parent if isinstance(typedecl, (Integer,Byte,Real,DoublePrecision)): @@ -601,7 +600,7 @@ static int %(otype)s_init(%(otype)s *self, if (!PyArg_ParseTuple(capi_args,"%(attr_format_elist)s" %(attr_init_clist)s)) return_value = -1; - + #if defined(F2PY_DEBUG_PYOBJ_TOFROM) fprintf(stderr,"%(otype)s_init: return_value=%%d, PyErr_Occurred()=%%p\\n", return_value, PyErr_Occurred()); #endif @@ -656,7 +655,7 @@ static PyObject * %(otype)s_repr(PyObject * self) { self.wrappermodulename = typedecl.parent.name else: self.info('Generating interface for %s.%s: %s' % (parent.modulename, typedecl.name, ctype)) - + parent.isf90 = True self.parent = parent self.name = name = typedecl.name diff --git a/numpy/f2py/lib/test_derived_scalar.py b/numpy/f2py/lib/test_derived_scalar.py index e85f067d6..5e6ff249f 100644 --- a/numpy/f2py/lib/test_derived_scalar.py +++ b/numpy/f2py/lib/test_derived_scalar.py @@ -94,6 +94,6 @@ class test_m(NumpyTestCase): assert_equal(a.flag,2) assert_equal(r.flag,4) - + if __name__ == "__main__": NumpyTest().run() diff --git a/numpy/f2py/lib/test_scalar_function_in.py b/numpy/f2py/lib/test_scalar_function_in.py index df6d2cee7..7c2539fe5 100644 --- a/numpy/f2py/lib/test_scalar_function_in.py +++ b/numpy/f2py/lib/test_scalar_function_in.py @@ -549,6 +549,6 @@ class test_m(NumpyTestCase): assert_equal(r,'1bcde') r = func('') assert_equal(r,'') - + if __name__ == "__main__": NumpyTest().run() diff --git a/numpy/f2py/lib/test_scalar_in_out.py b/numpy/f2py/lib/test_scalar_in_out.py index 13f3e333d..37cf4d8d9 100644 --- a/numpy/f2py/lib/test_scalar_in_out.py +++ b/numpy/f2py/lib/test_scalar_in_out.py @@ -547,6 +547,6 @@ class test_m(NumpyTestCase): assert_equal(r,'1bcde') r = func('') assert_equal(r,'') - + if __name__ == "__main__": NumpyTest().run() diff --git a/numpy/f2py/lib/wrapper_base.py b/numpy/f2py/lib/wrapper_base.py index ccda6401e..3164e817f 100644 --- a/numpy/f2py/lib/wrapper_base.py +++ b/numpy/f2py/lib/wrapper_base.py @@ -1,4 +1,3 @@ - import os import sys import re @@ -57,7 +56,7 @@ class WrapperBase: elif d.endswith('.c'): WrapperCCode(parent, d[:-2]) else: - self.warning('Unknown dependence: %r.' % (d)) + self.warning('Unknown dependence: %r.' % (d)) return def apply_attributes(self, template): diff --git a/numpy/f2py/rules.py b/numpy/f2py/rules.py index 55e86284f..d1eb4016e 100644 --- a/numpy/f2py/rules.py +++ b/numpy/f2py/rules.py @@ -173,7 +173,7 @@ PyMODINIT_FUNC init#modulename#(void) { \tm = #modulename#_module = Py_InitModule(\"#modulename#\", f2py_module_methods); \tPyFortran_Type.ob_type = &PyType_Type; \timport_array(); -\tif (PyErr_Occurred()) +\tif (PyErr_Occurred()) \t\t{PyErr_SetString(PyExc_ImportError, \"can't initialize module #modulename# (failed to import numpy)\"); return;} \td = PyModule_GetDict(m); \ts = PyString_FromString(\"$R"""+"""evision: $\"); diff --git a/numpy/f2py/tests/array_from_pyobj/setup.py b/numpy/f2py/tests/array_from_pyobj/setup.py index f449117a7..bcb083180 100644 --- a/numpy/f2py/tests/array_from_pyobj/setup.py +++ b/numpy/f2py/tests/array_from_pyobj/setup.py @@ -1,4 +1,3 @@ - import os def configuration(parent_name='',top_path=None): from numpy.distutils.misc_util import Configuration diff --git a/numpy/f2py/tests/c/return_real.py b/numpy/f2py/tests/c/return_real.py index 27e0843f1..62dbd2f74 100644 --- a/numpy/f2py/tests/c/return_real.py +++ b/numpy/f2py/tests/c/return_real.py @@ -6,7 +6,6 @@ Examples: python return_real.py --quiet """ - import f2py2e from Numeric import array diff --git a/numpy/f2py/tests/f77/callback.py b/numpy/f2py/tests/f77/callback.py index 672504bc7..bfe4eb547 100644 --- a/numpy/f2py/tests/f77/callback.py +++ b/numpy/f2py/tests/f77/callback.py @@ -1,4 +1,3 @@ - __usage__ = """ Run: python callback.py [<f2py options>] diff --git a/numpy/f2py/tests/f77/return_character.py b/numpy/f2py/tests/f77/return_character.py index 3361c11f5..b44b6ee70 100644 --- a/numpy/f2py/tests/f77/return_character.py +++ b/numpy/f2py/tests/f77/return_character.py @@ -1,4 +1,3 @@ - __usage__ = """ Run: python return_character.py [<f2py options>] diff --git a/numpy/f2py/tests/f77/return_complex.py b/numpy/f2py/tests/f77/return_complex.py index 9993bb6eb..e182902b3 100644 --- a/numpy/f2py/tests/f77/return_complex.py +++ b/numpy/f2py/tests/f77/return_complex.py @@ -6,7 +6,6 @@ Examples: python return_complex.py --quiet """ - import f2py2e from Numeric import array diff --git a/numpy/f2py/tests/f77/return_integer.py b/numpy/f2py/tests/f77/return_integer.py index 5bd7ae1ab..fe9e70fda 100644 --- a/numpy/f2py/tests/f77/return_integer.py +++ b/numpy/f2py/tests/f77/return_integer.py @@ -1,4 +1,3 @@ - __usage__ = """ Run: python return_integer.py [<f2py options>] diff --git a/numpy/f2py/tests/f77/return_logical.py b/numpy/f2py/tests/f77/return_logical.py index ac807b5be..cc5f9cb05 100644 --- a/numpy/f2py/tests/f77/return_logical.py +++ b/numpy/f2py/tests/f77/return_logical.py @@ -1,4 +1,3 @@ - __usage__ = """ Run: python return_logical.py [<f2py options>] diff --git a/numpy/f2py/tests/f77/return_real.py b/numpy/f2py/tests/f77/return_real.py index 29e720a85..a751743e9 100644 --- a/numpy/f2py/tests/f77/return_real.py +++ b/numpy/f2py/tests/f77/return_real.py @@ -6,7 +6,6 @@ Examples: python return_real.py --quiet """ - import numpy.f2py as f2py2e from numpy import array diff --git a/numpy/f2py/tests/f90/return_character.py b/numpy/f2py/tests/f90/return_character.py index 45174630a..1b5515f4d 100644 --- a/numpy/f2py/tests/f90/return_character.py +++ b/numpy/f2py/tests/f90/return_character.py @@ -1,4 +1,3 @@ - __usage__ = """ Run: python return_character.py [<f2py options>] diff --git a/numpy/f2py/tests/f90/return_complex.py b/numpy/f2py/tests/f90/return_complex.py index 71179e1f2..e615de218 100644 --- a/numpy/f2py/tests/f90/return_complex.py +++ b/numpy/f2py/tests/f90/return_complex.py @@ -5,7 +5,6 @@ Examples: python return_complex.py --quiet """ - import f2py2e from Numeric import array diff --git a/numpy/f2py/tests/f90/return_integer.py b/numpy/f2py/tests/f90/return_integer.py index 3e96dfd5f..c0241eeaf 100644 --- a/numpy/f2py/tests/f90/return_integer.py +++ b/numpy/f2py/tests/f90/return_integer.py @@ -1,4 +1,3 @@ - # XXX: investigate cases that are disabled under win32 # diff --git a/numpy/f2py/tests/f90/return_logical.py b/numpy/f2py/tests/f90/return_logical.py index c9479edaf..71cfe162e 100644 --- a/numpy/f2py/tests/f90/return_logical.py +++ b/numpy/f2py/tests/f90/return_logical.py @@ -1,4 +1,3 @@ - __usage__ = """ Run: python return_logical.py [<f2py options>] |