Skip to content

Commit

Permalink
fix flake code checks
Browse files Browse the repository at this point in the history
  • Loading branch information
mam10eks committed Dec 12, 2024
1 parent 652dc93 commit 26aa756
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 3 additions & 1 deletion ir_axioms/backend/pyterrier/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ def _index(self) -> Index:
)

def __str__(self):
return f'TerrierIndexContext({str(self.index_location).split("/")[-1].split(" ")[0]})'
ret = str(self.index_location)
ret = ret.split("/")[-1].split(" ")[0]
return f'TerrierIndexContext({ret})'

@cached_property
def _meta_index(self) -> MetaIndex:
Expand Down
7 changes: 5 additions & 2 deletions ir_axioms/modules/similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
from ir_axioms import logger
from ir_axioms.utils.nltk import download_nltk_dependencies

import os
DIR_PATH = os.path.dirname(os.path.realpath(__file__))


@lru_cache(None)
def synonym_set(
Expand Down Expand Up @@ -199,5 +202,5 @@ def similarity(self, term1: str, term2: str):


class FastTextWikiNewsTermSimilarityMixin(MagnitudeTermSimilarityMixin):
# wget via: https://files.webis.de/data-in-production/data-research/ir-axioms/wiki-news-300d-1M.magnitude
embeddings_path: Final[str] = "/workspaces/ecir25-gpt-axioms/wiki-news-300d-1M.magnitude"
# wget via: https://files.webis.de/data-in-production/data-research/ir-axioms/wiki-news-300d-1M.magnitude # noqa: E501
embeddings_path: Final[str] = f"{DIR_PATH}/wiki-news-300d-1M.magnitude"
11 changes: 7 additions & 4 deletions tests/unit/test_string_representations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,23 @@ class TestStringRepresentations(unittest.TestCase):
def test_string_representation_of_terrier_index_context_01(self):
# Needed for caching
expected = 'TerrierIndexContext(index_location)'
actual = str(TerrierIndexContext('index_location'))
index_location = 'index_location'
actual = str(TerrierIndexContext(index_location))

self.assertEqual(expected, actual)

def test_string_representation_of_terrier_index_context_02(self):
# Needed for caching
expected = 'TerrierIndexContext(index_location)'
actual = str(TerrierIndexContext('ignore/absolute/path/index_location'))
index_location = 'ignore/absolute/path/index_location'
actual = str(TerrierIndexContext(index_location))

self.assertEqual(expected, actual)

def test_string_representation_of_terrier_index_context_03(self):
# Needed for caching
expected = 'TerrierIndexContext(index_location)'
actual = str(TerrierIndexContext('ignore/absolute/path/index_location ignore suffix'))
index_location = 'ignore/absolute/path/index_location ignore suffix'
actual = str(TerrierIndexContext(index_location))

self.assertEqual(expected, actual)
self.assertEqual(expected, actual)

0 comments on commit 26aa756

Please sign in to comment.