Skip to content

Commit

Permalink
correction
Browse files Browse the repository at this point in the history
  • Loading branch information
kdomino committed Oct 3, 2023
1 parent 855a579 commit 5f50512
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/process_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import pickle
from typing import Any
import dimod

from dimod import SampleSet
from src import LinearProg


def get_objective(lp , sample: dict) -> float:
def get_objective(lp: LinearProg, sample: dict) -> float:
"""computes objective value for sample
:param lp: the integer program with the relevant objective function
Expand All @@ -21,7 +21,7 @@ def get_objective(lp , sample: dict) -> float:
)


def get_results(sampleset: dimod.SampleSet, prob) -> list[dict[str, Any]]:
def get_results(sampleset: SampleSet, prob: LinearProg) -> list[dict[str, Any]]:
"""Check samples one by one, and computes it statistics.
Statistics includes energy (as provided by D'Wave), objective function
Expand All @@ -48,7 +48,7 @@ def get_results(sampleset: dimod.SampleSet, prob) -> list[dict[str, Any]]:
return sorted(dict_list, key=lambda d: d["energy"])


def store_result(input_name: str, file_name: str, sampleset: dimod.SampleSet):
def store_result(input_name: str, file_name: str, sampleset: SampleSet):
"""Save samples to the file
:param input_name: name of the input
Expand All @@ -68,7 +68,7 @@ def store_result(input_name: str, file_name: str, sampleset: dimod.SampleSet):
pickle.dump(sdf, handle)


def load_results(file_name: str) -> dimod.SampleSet:
def load_results(file_name: str) -> SampleSet:
"""Load samples from the file
:param file_name: name of the file
Expand All @@ -77,11 +77,11 @@ def load_results(file_name: str) -> dimod.SampleSet:
:rtype: dimod.SampleSet
"""
file = pickle.load(open(file_name, "rb"))
return dimod.SampleSet.from_serializable(file)
return SampleSet.from_serializable(file)


def analyze_constraints(
lp , sample: dict[str, int]
lp: LinearProg, sample: dict[str, int]
) -> tuple[dict[str, bool], int]:
"""check which constraints were satisfied
Expand Down

0 comments on commit 5f50512

Please sign in to comment.