Skip to content

Commit

Permalink
Misc refactor and add type hints.
Browse files Browse the repository at this point in the history
  • Loading branch information
li-zhi committed Aug 13, 2023
1 parent c21132a commit 4c08f00
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
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

0 comments on commit 4c08f00

Please sign in to comment.