diff --git a/Makefile b/Makefile index 334e1b4..09f2dec 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/_typos.toml b/_typos.toml index 213636b..62e669f 100644 --- a/_typos.toml +++ b/_typos.toml @@ -1,4 +1,6 @@ [default] extend-ignore-identifiers-re = [ ".*Hsi", + "relevants", + "Comput", ] diff --git a/docs/qrels.md b/docs/qrels.md index 5825672..25e7562 100644 --- a/docs/qrels.md +++ b/docs/qrels.md @@ -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", diff --git a/docs/report.md b/docs/report.md index fcfdcc1..bdee714 100644 --- a/docs/report.md +++ b/docs/report.md @@ -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) diff --git a/docs/run.md b/docs/run.md index a684251..55f5527 100644 --- a/docs/run.md +++ b/docs/run.md @@ -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 ``` @@ -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", diff --git a/notebooks/2_qrels_and_run.ipynb b/notebooks/2_qrels_and_run.ipynb index c50319a..1d86e48 100644 --- a/notebooks/2_qrels_and_run.ipynb +++ b/notebooks/2_qrels_and_run.ipynb @@ -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", " 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", " f.write(requests.get(master).text)" ] }, diff --git a/pyproject.toml b/pyproject.toml index b0ab531..1b297d6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" \ No newline at end of file diff --git a/ranx/data_structures/report.py b/ranx/data_structures/report.py index edd6df4..bfb2a92 100644 --- a/ranx/data_structures/report.py +++ b/ranx/data_structures/report.py @@ -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) @@ -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 diff --git a/ranx/fusion/isr.py b/ranx/fusion/isr.py index 6d8ca50..5ca4b79 100644 --- a/ranx/fusion/isr.py +++ b/ranx/fusion/isr.py @@ -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}, volume = {39}, pages = {35--45}, year = {2015}, diff --git a/ranx/fusion/log_isr.py b/ranx/fusion/log_isr.py index cf76d2f..80a5f1b 100644 --- a/ranx/fusion/log_isr.py +++ b/ranx/fusion/log_isr.py @@ -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}, volume = {39}, pages = {35--45}, year = {2015}, diff --git a/ranx/fusion/logn_isr.py b/ranx/fusion/logn_isr.py index 4779824..317f285 100644 --- a/ranx/fusion/logn_isr.py +++ b/ranx/fusion/logn_isr.py @@ -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}, volume = {39}, pages = {35--45}, year = {2015}, diff --git a/ranx/meta/compare.py b/ranx/meta/compare.py index 5e93488..d374f24 100644 --- a/ranx/meta/compare.py +++ b/ranx/meta/compare.py @@ -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) diff --git a/ranx/meta/evaluate.py b/ranx/meta/evaluate.py index 99aa43f..0644a31 100644 --- a/ranx/meta/evaluate.py +++ b/ranx/meta/evaluate.py @@ -41,7 +41,7 @@ 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) @@ -49,7 +49,7 @@ def convert_qrels(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) @@ -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) @@ -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: