Skip to content

Commit

Permalink
Fix pylint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fplazaonate committed May 2, 2024
1 parent a2c0b04 commit 56d681a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
5 changes: 1 addition & 4 deletions crocodeel/easy_wf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import Any
import crocodeel.ab_table_utils as ab_table_utils
from crocodeel import ab_table_utils
from crocodeel.search_conta import run_search_conta
from crocodeel.plot_conta import run_plot_conta, Defaults as plot_conta_defaults

Expand All @@ -16,6 +16,3 @@ def run_easy_wf(args: dict[str,Any]):
args["no_conta_line"] = False
args["color_conta_species"] = False
run_plot_conta(args)



6 changes: 3 additions & 3 deletions crocodeel/plot_conta.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from typing import BinaryIO, Any, Final
from functools import partial
import logging
from time import perf_counter
from matplotlib.backends.backend_pdf import PdfPages
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import tqdm
import logging
from time import perf_counter
from crocodeel.conta_event import ContaminationEvent, ContaminationEventIO
import crocodeel.ab_table_utils as ab_table_utils
from crocodeel import ab_table_utils


def run_plot_conta(args: dict[str, Any]):
Expand Down
2 changes: 1 addition & 1 deletion crocodeel/rf_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def get_path() -> Path:
Path(__file__).resolve().parent / "models" / "crocodeel_rf_Mar2023.joblib"
)
return model_path

@staticmethod
def load() -> RandomForestClassifier:
return joblib.load(RandomForestModel.get_path())
13 changes: 8 additions & 5 deletions crocodeel/search_conta.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from multiprocessing import Pool
from functools import partial
from itertools import product
import numpy as np
import pandas as pd
import tqdm
import logging
from time import perf_counter
from typing import Final, Any
import numpy as np
import pandas as pd
import tqdm
from sklearn.linear_model import RANSACRegressor, LinearRegression
from sklearn.metrics import mean_squared_error
from sklearn.neighbors import NearestNeighbors
from scipy.stats import spearmanr
import crocodeel.ab_table_utils as ab_table_utils
from crocodeel import ab_table_utils
from crocodeel.conta_event import ContaminationEvent, ContaminationEventIO
from crocodeel.rf_model import RandomForestModel

Expand Down Expand Up @@ -39,7 +39,10 @@ def run_search_conta(args: dict[str,Any]):

conta_events.sort(key=lambda e: e.rate, reverse=True)
ContaminationEventIO.write_tsv(conta_events, args['conta_events_fh'])
logging.info("Contamination events sorted by decreasing contamination rate saved in %s", args['conta_events_fh'].name)
logging.info(
"Contamination events sorted by decreasing contamination rate saved in %s",
args["conta_events_fh"].name,
)
if args["conta_events_fh"].mode == 'w':
args["conta_events_fh"].close()

Expand Down
14 changes: 11 additions & 3 deletions crocodeel/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ class TestData:

def run_test_install(keep_results: bool) -> None:
with (
open(TestData.SPECIES_ABUNDANCE_TABLE, "r") as species_ab_table_fh,
open(TestData.SPECIES_ABUNDANCE_TABLE, "r", encoding="utf-8") as species_ab_table_fh,
NamedTemporaryFile(
mode="w+", prefix="contamination_events_", suffix=".tsv", delete = not keep_results, delete_on_close=False
mode="w+",
prefix="contamination_events_",
suffix=".tsv",
delete=not keep_results,
delete_on_close=False,
) as conta_events_fh,
NamedTemporaryFile(
mode="wb", prefix="contamination_events_", suffix=".pdf", delete = not keep_results, delete_on_close=False
mode="wb",
prefix="contamination_events_",
suffix=".pdf",
delete=not keep_results,
delete_on_close=False,
) as pdf_report_fh,
):
easy_wf_args = {
Expand Down

0 comments on commit 56d681a

Please sign in to comment.