Skip to content
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: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ lint: .venv ## Check linting
. $(VENV_BIN)/activate
$(VENV_BIN)/isort --check .
$(VENV_BIN)/black --check .
$(VENV_BIN)/blackdoc .
$(VENV_BIN)/ruff .
$(VENV_BIN)/ruff check .
$(VENV_BIN)/typos .
# $(VENV_BIN)/mypy ranx

Expand Down
2 changes: 2 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[default]
extend-ignore-identifiers-re = [
".*Hsi",
"relevants",
"Comput",
]
2 changes: 1 addition & 1 deletion docs/qrels.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ You can control the behavior of the underlying `pandas.read_parquet` function by

```python
qrels = Qrels.from_parquet(
path="/path/to/parquet/file""",
path="/path/to/parquet/file",
q_id_col="q_id",
doc_id_col="doc_id",
score_col="score",
Expand Down
2 changes: 1 addition & 1 deletion docs/report.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ report = compare(
qrels=qrels,
runs=[run_1, run_2, run_3, run_4, run_5],
metrics=["map@100", "mrr@100", "ndcg@10"],
max_p=0.01 # P-value threshold
max_p=0.01, # P-value threshold
)

print(report)
Expand Down
4 changes: 2 additions & 2 deletions docs/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ run = Run.from_file("path/to/run.json") # JSON file
run = Run.from_file("path/to/run.trec") # TREC-Style file
run = Run.from_file("path/to/run.txt") # TREC-Style file with txt extension
run = Run.from_file("path/to/run.gz") # Gzipped TREC-Style file
run = Run.from_file("path/to/run.lz4") # lz4 file produced by saving a ranx.Run as lz4
run = Run.from_file("path/to/run.lz4") # lz4 file produced by saving a ranx.Run as lz4
run = Run.from_file("path/to/run.custom", kind="json") # Loaded as JSON file
```

Expand Down Expand Up @@ -69,7 +69,7 @@ The argument `name` is used to set the name of the run. Default is `None`.

```python
run = Run.from_parquet(
path="/path/to/parquet/file""",
path="/path/to/parquet/file",
q_id_col="q_id",
doc_id_col="doc_id",
score_col="score",
Expand Down
4 changes: 2 additions & 2 deletions notebooks/2_qrels_and_run.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@
"os.makedirs(\"notebooks/data\", exist_ok=True)\n",
"\n",
"with open(\"notebooks/data/small_qrels.json\", \"w\") as f:\n",
" master = f\"https://raw.githubusercontent.com/AmenRa/ranx/master/notebooks/data/small_qrels.json\"\n",
" master = \"https://raw.githubusercontent.com/AmenRa/ranx/master/notebooks/data/small_qrels.json\"\n",

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

" f.write(requests.get(master).text)\n",
"\n",
"with open(\"notebooks/data/small_qrels.trec\", \"w\") as f:\n",
" master = f\"https://raw.githubusercontent.com/AmenRa/ranx/master/notebooks/data/small_qrels.trec\"\n",
" master = \"https://raw.githubusercontent.com/AmenRa/ranx/master/notebooks/data/small_qrels.trec\"\n",

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

" f.write(requests.get(master).text)"
]
},
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
[tool.ruff]
# E501 ignore long comment lines (black should take care of that)
# E712 ignore == False, needed for numba checks.
[tool.ruff.lint]
ignore = ["E501", "E712"]

[tool.black]
extend-exclude = '''
\.md$|\.markdown$
'''

[tool.isort]
profile = "black"
4 changes: 2 additions & 2 deletions ranx/data_structures/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Report(object):
qrels=qrels,
runs=[run_1, run_2, run_3, run_4, run_5],
metrics=["map@100", "mrr@100", "ndcg@10"],
max_p=0.01 # P-value threshold
max_p=0.01, # P-value threshold
)

print(report)
Expand Down Expand Up @@ -253,7 +253,7 @@ def to_latex(self) -> str:
def to_dict(self) -> Dict:
"""Returns the Report data as a Python dictionary.

```python
```
{
"stat_test": "fisher"
# metrics and model_names allows to read the report without
Expand Down
2 changes: 1 addition & 1 deletion ranx/fusion/isr.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def isr(runs: List[Run], name: str = "isr") -> Run:
Fl{\'{a}}vio Martins and
Jo{\~{a}}o Magalh{\~{a}}es},
title = {Multimodal medical information retrieval with unsupervised rank fusion},
journal = {Comput. Medical Imaging Graph.},
journal = {Computerized Medical Imaging and Graphics},

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

volume = {39},
pages = {35--45},
year = {2015},
Expand Down
2 changes: 1 addition & 1 deletion ranx/fusion/log_isr.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def log_isr(runs: List[Run], name: str = "log_isr") -> Run:
Fl{\'{a}}vio Martins and
Jo{\~{a}}o Magalh{\~{a}}es},
title = {Multimodal medical information retrieval with unsupervised rank fusion},
journal = {Comput. Medical Imaging Graph.},
journal = {Computerized Medical Imaging and Graphics},

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

volume = {39},
pages = {35--45},
year = {2015},
Expand Down
2 changes: 1 addition & 1 deletion ranx/fusion/logn_isr.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def logn_isr(runs: List[Run], sigma: float = 0.01, name: str = "logn_isr") -> Ru
Fl{\'{a}}vio Martins and
Jo{\~{a}}o Magalh{\~{a}}es},
title = {Multimodal medical information retrieval with unsupervised rank fusion},
journal = {Comput. Medical Imaging Graph.},
journal = {Computerized Medical Imaging and Graphics},

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

volume = {39},
pages = {35--45},
year = {2015},
Expand Down
2 changes: 1 addition & 1 deletion ranx/meta/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def compare(
qrels=qrels,
runs=[run_1, run_2, run_3, run_4, run_5],
metrics=["map@100", "mrr@100", "ndcg@10"],
max_p=0.01 # P-value threshold
max_p=0.01, # P-value threshold
)

print(report)
Expand Down
10 changes: 5 additions & 5 deletions ranx/meta/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ def extract_metric_and_params(metric):


def convert_qrels(qrels):
if type(qrels) == Qrels:
if isinstance(qrels, Qrels):
return qrels.to_typed_list()
elif isinstance(qrels, dict):
return python_dict_to_typed_list(qrels, sort=True)
return qrels


def convert_run(run):
if type(run) == Run:
if isinstance(run, Run):
return run.to_typed_list()
elif isinstance(run, dict):
return python_dict_to_typed_list(run, sort=True)
Expand Down Expand Up @@ -128,10 +128,10 @@ def evaluate(
if not return_mean:
return_std = False

if make_comparable and type(qrels) == Qrels and type(run) == Run:
if make_comparable and isinstance(qrels, Qrels) and isinstance(run, Run):
run = run.make_comparable(qrels)

if type(qrels) in [Qrels, dict] and type(run) in [Run, dict]:
if isinstance(qrels, (Qrels, dict)) and isinstance(run, (Run, dict)):
check_keys(qrels, run)

_qrels = convert_qrels(qrels)
Expand All @@ -146,7 +146,7 @@ def evaluate(
metric_scores_dict[metric] = metric_switch(m)(_qrels, _run, k, rel_lvl)

# Save results in Run ------------------------------------------------------
if type(run) == Run and save_results_in_run:
if isinstance(run, Run) and save_results_in_run:
for m, scores in metric_scores_dict.items():
run.mean_scores[m] = np.mean(scores)
if return_std:
Expand Down