Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc refactor and add type hints. #1224

Merged
merged 1 commit into from
Aug 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion python/vmaf/core/result.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from collections import OrderedDict
import json
import re
from typing import Optional, Callable

import numpy as np

Expand All @@ -21,7 +22,7 @@ def __init__(self, asset, result_dict):
self.result_dict = result_dict
self.score_aggregate_method = np.mean

def set_score_aggregate_method(self, score_aggregate_method):
def set_score_aggregate_method(self, score_aggregate_method: Optional[Callable]):
if score_aggregate_method is not None:
self.score_aggregate_method = score_aggregate_method
else:
Expand Down
7 changes: 1 addition & 6 deletions python/vmaf/core/result_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,7 @@ def clean_up(self):
shutil.rmtree(self.result_store_dir)

def _get_result_file_path(self, result):
str_to_hash = str(result.asset).encode("utf-8")
return "{dir}/{executor_id}/{dataset}/{content_id}/{str}".format(
dir=self.result_store_dir, executor_id=result.executor_id,
dataset=result.asset.dataset,
content_id=result.asset.content_id,
str=hashlib.sha1(str_to_hash).hexdigest())
return self._get_result_file_path2(result.asset, result.executor_id)

def _get_result_file_path2(self, asset, executor_id):
str_to_hash = str(asset).encode("utf-8")
Expand Down
Loading