Skip to content

Commit

Permalink
🐛 make all imports explicit w.r.t. to pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry committed Jun 4, 2024
1 parent 6c0be11 commit 54fe142
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 24 deletions.
3 changes: 0 additions & 3 deletions vaep/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
from importlib import metadata

import njab
import pandas as pd
import pandas.io.formats.format as pf

# from . import logging, nb, pandas, plotting
import vaep.logging
import vaep.nb
import vaep.pandas
Expand Down
2 changes: 1 addition & 1 deletion vaep/analyzers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
from types import SimpleNamespace

from . import compare_predictions, diff_analysis
from vaep.analyzers import compare_predictions, diff_analysis

__all__ = ['diff_analysis', 'compare_predictions', 'Analysis']

Expand Down
2 changes: 0 additions & 2 deletions vaep/data_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import numpy as np
import pandas as pd

# coverage


def coverage(X: pd.DataFrame, coverage_col: float, coverage_row: float):
"""Select proteins by column depending on their coverage.
Expand Down
2 changes: 0 additions & 2 deletions vaep/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

logger = logging.getLogger(__name__)

# ! use in data selection and tutorial


def select_features(df: pd.DataFrame,
feat_prevalence: float = .2,
Expand Down
3 changes: 1 addition & 2 deletions vaep/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
from fastcore.foundation import L

import vaep

from . import ae, analysis, collab, vae
from vaep.models import ae, analysis, collab, vae

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion vaep/models/ae.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import vaep.models
import vaep.transform

from . import analysis
from vaep.models import analysis

logger = logging.getLogger(__name__)

Expand Down
3 changes: 1 addition & 2 deletions vaep/models/collab.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

import vaep.io.dataloaders
import vaep.io.datasplits

from . import analysis
from vaep.models import analysis

logger = logging.getLogger(__name__)

Expand Down
34 changes: 28 additions & 6 deletions vaep/pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,30 @@
import omegaconf
import pandas as pd

from .calc_errors import calc_errors_per_feat, get_absolute_error
from vaep.pandas.calc_errors import calc_errors_per_feat, get_absolute_error

__all__ = [
'calc_errors_per_feat',
'get_absolute_error',
'unique_cols',
'get_unique_non_unique_columns',
'prop_unique_index',
'replace_with',
'index_to_dict',
'get_columns_accessor',
'get_columns_accessor_from_iterable',
'select_max_by',
'get_columns_namedtuple',
'highlight_min',
'_add_indices',
'interpolate',
'flatten_dict_of_dicts',
'key_map',
'parse_query_expression',
'length',
'get_last_index_matching_proportion',
'get_lower_whiskers',
'get_counts_per_bin']


def unique_cols(s: pd.Series) -> bool:
Expand Down Expand Up @@ -285,16 +308,15 @@ def get_lower_whiskers(df: pd.DataFrame, factor: float = 1.5) -> pd.Series:
return ret


def get_counts_per_bin(df: pd.DataFrame, bins: range, columns: Optional[List[str]] = None) -> pd.DataFrame:
def get_counts_per_bin(df: pd.DataFrame,
bins: range,
columns: Optional[List[str]] = None) -> pd.DataFrame:
"""Return counts per bin for selected columns in DataFrame."""
counts_per_bin = dict()
if columns is None:
columns = df.columns.to_list()
for col in columns:
_series = (pd.cut(df[col], bins=bins)
.to_frame()
.groupby(col)
.size())
_series = (pd.cut(df[col], bins=bins).to_frame().groupby(col).size())
_series.index.name = 'bin'
counts_per_bin[col] = _series
counts_per_bin = pd.DataFrame(counts_per_bin)
Expand Down
7 changes: 2 additions & 5 deletions vaep/plotting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@
import seaborn

import vaep.pandas

from . import data, defaults, errors, plotly
from .errors import plot_rolling_error

# from . defaults import order_categories, labels_dict, IDX_ORDER
from vaep.plotting import data, defaults, errors, plotly
from vaep.plotting.errors import plot_rolling_error

seaborn.set_style("whitegrid")
# seaborn.set_theme()
Expand Down

0 comments on commit 54fe142

Please sign in to comment.