Skip to content

Commit

Permalink
changed filter function in payment to generator
Browse files Browse the repository at this point in the history
  • Loading branch information
sebulino committed Jun 22, 2022
1 parent 3c850fe commit 111a691
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion pickhardtpayments/Payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ def filter_attempts(self, flag: AttemptStatus) -> list[Attempt]:
:return: A list of successful Attempts of this Payment, which could be settled.
:rtype: list[Attempt]
"""
return [attempt for attempt in self._attempts if attempt.status.value == flag.value]
for attempt in self._attempts:
if attempt.status.value == flag.value:
yield attempt

@property
def successful(self) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions pickhardtpayments/SyncSimulatedPaymentSession.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,9 @@ def pickhardt_pay(self, src, dest, amt, mu=1, base=DEFAULT_BASE_THRESHOLD):
print("========")
print("Rounds of mcf-computations:\t", cnt)
print("Number of attempts made:\t", len(payment.attempts))
print("Number of failed attempts:\t", len(payment.filter_attempts(AttemptStatus.FAILED)))
print("Number of failed attempts:\t", len(list(payment.filter_attempts(AttemptStatus.FAILED))))
print("Failure rate: {:4.2f}% ".format(
len(payment.filter_attempts(AttemptStatus.FAILED)) * 100. / len(payment.attempts)))
len(list(payment.filter_attempts(AttemptStatus.FAILED))) * 100. / len(payment.attempts)))
print("total Payment lifetime (including inefficient memory management): {:4.3f} sec".format(
payment.end_time - payment.start_time))
print("Learnt entropy: {:5.2f} bits".format(entropy_start - entropy_end))
Expand Down

0 comments on commit 111a691

Please sign in to comment.