Skip to content

Instantly share code, notes, and snippets.

@cthoyt
Created September 13, 2016 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cthoyt/2077166fd57c4dd3583499f5ef40d5f7 to your computer and use it in GitHub Desktop.
Save cthoyt/2077166fd57c4dd3583499f5ef40d5f7 to your computer and use it in GitHub Desktop.
def parse_bertini_main_data(fl):
"""
Parses main_data output from Bertini 1.5.1
:param fl: file object for main_data
:type f1: file-like object
:return: list of solutions
"""
it = (line.strip() for line in fl)
number_variables = next(it)
solution_dimension = int(number_variables[21:])
print(solution_dimension)
variables = next(it)
rank = next(it)
_ = next(it)
dimension_title = next(it)
_ = next(it)
non_singular_title = next(it)
line = next(it)
solns = []
while line == '---------------':
path_number = next(it)
component_number = next(it)
estimated_condition_number = next(it)
components = []
for i in range(solution_dimension):
component = next(it)
re, im = component.split(' ')
component = float(re) + 1j * float(im)
components.append(component)
solns.append(components)
multiplicity = next(it)
deflations = next(it)
line = next(it)
return solns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment