本文整理汇总了Python中numpy.compat.open_latin1方法的典型用法代码示例。如果您正苦于以下问题:Python compat.open_latin1方法的具体用法?Python compat.open_latin1怎么用?Python compat.open_latin1使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numpy.compat
的用法示例。
在下文中一共展示了compat.open_latin1方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: is_free_format
# 需要导入模块: from numpy import compat [as 别名]
# 或者: from numpy.compat import open_latin1 [as 别名]
def is_free_format(file):
"""Check if file is in free format Fortran."""
# f90 allows both fixed and free format, assuming fixed unless
# signs of free format are detected.
result = 0
f = open_latin1(file, 'r')
line = f.readline()
n = 10000 # the number of non-comment lines to scan for hints
if _has_f_header(line):
n = 0
elif _has_f90_header(line):
n = 0
result = 1
while n>0 and line:
line = line.rstrip()
if line and line[0]!='!':
n -= 1
if (line[0]!='\t' and _free_f90_start(line[:5])) or line[-1:]=='&':
result = 1
break
line = f.readline()
f.close()
return result
示例2: get_f77flags
# 需要导入模块: from numpy import compat [as 别名]
# 或者: from numpy.compat import open_latin1 [as 别名]
def get_f77flags(src):
"""
Search the first 20 lines of fortran 77 code for line pattern
`CF77FLAGS(<fcompiler type>)=<f77 flags>`
Return a dictionary {<fcompiler type>:<f77 flags>}.
"""
flags = {}
f = open_latin1(src, 'r')
i = 0
for line in f:
i += 1
if i>20: break
m = _f77flags_re.match(line)
if not m: continue
fcname = m.group('fcname').strip()
fflags = m.group('fflags').strip()
flags[fcname] = split_quoted(fflags)
f.close()
return flags
# TODO: implement get_f90flags and use it in _compile similarly to get_f77flags