Skip to content

Commit

Permalink
removed six and cleanup prettyprint, generate_symbol is running on py3k
Browse files Browse the repository at this point in the history
  • Loading branch information
dpinte committed Sep 26, 2014
1 parent ac0a6b0 commit fc76454
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
14 changes: 5 additions & 9 deletions quantlib/util/prettyprint.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import six
import re
import numpy
from math import floor, log10
import operator

TupleType = six.types.TupleType
ListType = six.types.ListType

def abswithnone(x):
if x is None:
return 0
Expand Down Expand Up @@ -37,7 +33,7 @@ def prettyprint(cLab, cTyp, cTmp):
data: array of column vectors
"""

if type(cLab) in (TupleType, ListType):
if isinstance(cLab, (tuple, list)):
cLabels = cLab
else:
p = re.compile(r'\W+')
Expand All @@ -50,7 +46,7 @@ def prettyprint(cLab, cTyp, cTmp):
'dimension mismatch: %d labels, %d types.' % (nbColumns, len(cTyp))
)

if type(cTyp) is (TupleType, ListType):
if isinstance(cTyp, (tuple, list)):
cTypes = cTyp
else:
cTypes = []
Expand Down Expand Up @@ -135,7 +131,7 @@ def prettyprint(cLab, cTyp, cTmp):
s2 += fmt % (dash*int(width))

# dates in scalar form must be translated back into normal dates
if fcode == 'd' and type(values[0]) == int:
if fcode == 'd' and isinstance(values[0], int):
for i in range(min(len(values), nbRows)):
rows[i+2] += sFormat % normalDateFromScalar(values[i])
else:
Expand Down Expand Up @@ -173,7 +169,7 @@ def prettyprinttranspose(cLab, cTyp, cTmp):
data: array of column vectors
"""

if type(cLab) in (TupleType, ListType):
if isinstance(cLab, (tuple, list)):
cLabels = cLab
else:
p = re.compile(r'\W+')
Expand All @@ -184,7 +180,7 @@ def prettyprinttranspose(cLab, cTyp, cTmp):
if len(cTyp) != nbColumns:
raise ValueError('dimension mismatch: %d labels, %d types.' % (nbColumns, len(cTyp)))

if type(cTyp) is (TupleType, ListType):
if isinstance(cTyp, (tuple, list)):
cTypes = cTyp
else:
cTypes = []
Expand Down
11 changes: 6 additions & 5 deletions scripts/generate_symbols.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
""" Symbol management to generate .def file. """
import glob
import os
import six
import subprocess

def symbol_generator_from_obj_file(object_file):
Expand Down Expand Up @@ -34,8 +35,8 @@ def _is_ql_symbols(symb):

def _is_boost_assertion(symb):
return '?assertion_failed@boost' in mangled_symbol
for line in nm_result.split('\n'):

for line in six.text_type(nm_result, 'ascii').split('\n'):
# Example line:
# 0000000000000000 R ?value@?$integral_constant@_N$00@tr1@std@@2_NB
# Find the symbol location in the line
Expand Down Expand Up @@ -76,11 +77,11 @@ def generate_deffile_from_dir(input_directory, output_file):
fh.write(' {}\n'.format(symbol))

def main():
input_directory = r"C:\dev\QuantLib-1.4\build\vc90\Win32\Release"
output_file = r'C:\dev\pyql\symbols_win32.def'
input_directory = r"C:\dev\QuantLib-1.4\build\vc100\Win32\Release"
output_file = r'C:\dev\pyql\symbols_win32_vc100.def'

generate_deffile_from_dir(input_directory, output_file)
print '{} generated'.format(output_file)
print ('{} generated'.format(output_file))

if __name__ == '__main__':
main()
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

SUPPORT_CODE_INCLUDE = './cpp_layer'

QL_LIBRARY = 'QuantLib'
QL_LIBRARY = 'QuantLib-vc100-mt'

# FIXME: would be good to be able to customize the path with environment
# variables in place of hardcoded paths ...
Expand All @@ -45,8 +45,8 @@
SUPPORT_CODE_INCLUDE
]
LIBRARY_DIRS = [
r"C:\dev\QuantLib-1.4\build\vc90\Win32\Release", # for the dll lib
r"C:\dev\QuantLib-1.4\lib", # for the static lib needed for two extensions
r"C:\dev\QuantLib-1.4\build\vc100\Win32\Release", # for the dll lib
r"C:\dev\QuantLib-1.4\lib",
'.',
r'.\dll',
]
Expand Down Expand Up @@ -236,6 +236,6 @@ def collect_extensions():
packages = find_packages(),
ext_modules = collect_extensions(),
cmdclass = {'build_ext': build_ext},
install_requires = ['distribute', 'six'],
install_requires = ['distribute', 'tabulate', 'pandas'],
zip_safe = False
)

0 comments on commit fc76454

Please sign in to comment.