Skip to content

Commit

Permalink
Add: __hash__ and tolist methods for Evaluate class.
Browse files Browse the repository at this point in the history
  • Loading branch information
Labbeti committed Jun 22, 2023
1 parent 8d3e299 commit 3383d2c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
All notable changes to this project will be documented in this file.

## [0.4.4] UNRELEASED
### Changed
- TODO
### Added
- `Evaluate` class now implements a __hash__ and tolist() methods.

## [0.4.3] 2023-06-15
### Changed
Expand Down
10 changes: 10 additions & 0 deletions src/aac_metrics/classes/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# -*- coding: utf-8 -*-

import logging
import pickle
import zlib

from typing import Callable, Iterable, Union

Expand Down Expand Up @@ -93,6 +95,14 @@ def update(
self._candidates += candidates
self._mult_references += mult_references

def tolist(self) -> list[AACMetric]:
return list(self)

def __hash__(self) -> int:
data = pickle.dumps(self)
data = zlib.adler32(data)
return data


class AACEvaluate(Evaluate):
"""Evaluate candidates with multiple references with all Audio Captioning metrics.
Expand Down

0 comments on commit 3383d2c

Please sign in to comment.