Skip to content

Commit

Permalink
Merge pull request #215 from jjcmoon/bugfix_dimacs
Browse files Browse the repository at this point in the history
Fix empty lines in dimacs
  • Loading branch information
jcmgray committed Dec 24, 2023
2 parents 9c93a76 + a7e2cef commit 9f7c300
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions quimb/tensor/tensor_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2758,6 +2758,10 @@ def cnf_file_parse(fname):
with open(fname, "r") as f:
for line in f:
args = line.split()

# ignore empty lines, other comments and info line
if (not args) or (args == ["0"]) or (args[0][0] in "c%"):
continue

# global info, just record
if args[0] == "p":
Expand Down Expand Up @@ -2790,10 +2794,6 @@ def cnf_file_parse(fname):
weights[int(sgn_var)] = float(w)
continue

# ignore empty lines, other comments and info line
if (not args) or (args == ["0"]) or (args[0][0] in "c%"):
continue

# clause tensor, drop last '0' (endline marker) and empty strings
if args[-1] != "0":
raise ValueError(f"Invalid clause: {line}")
Expand Down

0 comments on commit 9f7c300

Please sign in to comment.