Skip to content

Commit

Permalink
minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
szufix committed May 15, 2024
1 parent d4c601d commit 7e0a0d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def compute_swap_distance(election_1: OrdinalElection,
election_2: OrdinalElection) -> (int, list):
""" Compute swap distance between elections (using the C++ extension) """
if not utils.is_module_loaded("mapel.elections.distances.cppdistances"):
print("Using ILP instead of C++ BF")
return compute_swap_distance_ilp_py(election_1, election_2), None

if election_1.num_candidates < election_2.num_candidates:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ def import_real_new_soc_election(experiment_id: str = None,
file_name = f'{election_id}.soc'
path = os.path.join(os.getcwd(), "experiments", experiment_id, "elections", file_name)
file = open(path, 'r')

params = None
culture_id = None
votes = []
Expand All @@ -136,6 +135,16 @@ def import_real_new_soc_election(experiment_id: str = None,
if line[-1] == '\n':
line = line[:-1]
if line[0] != '#':
if from_file_data_type == 'soc':
process_soc_line(line, votes)
elif from_file_data_type == 'soi':
process_soi_line(line, votes)
elif from_file_data_type == 'toc':
process_toc_line(line, votes)
elif from_file_data_type == 'toi':
process_toi_line(line, votes)
else:
print("Unknown data format.")
break
elif re.search(regex_file_name, line):
from_file_file_name = line.split(':')[1][1:-file_ending]
Expand All @@ -158,8 +167,6 @@ def import_real_new_soc_election(experiment_id: str = None,
else:
params = ast.literal_eval(" ".join(line[2:]))

# label = from_file_title + "_" + from_file_file_name
# read votes
if from_file_data_type == 'soc':
for line in file:
process_soc_line(line, votes)
Expand Down

0 comments on commit 7e0a0d5

Please sign in to comment.