Skip to content

Commit

Permalink
[STYLE] Lint formatting of lifestyle factors
Browse files Browse the repository at this point in the history
  • Loading branch information
JGarciaCondado committed Nov 28, 2023
1 parent 9f1d85a commit c65d341
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/ageml/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import ageml.messages as messages
from ageml.visualizer import Visualizer
from ageml.utils import *
from ageml.utils import create_directory, feature_extractor, significant_markers, convert, log
from ageml.modelling import AgeML
from ageml.processing import find_correlations

Expand Down Expand Up @@ -259,9 +259,8 @@ def load_data(self, required=None):
non_shared_subjects = [s for s in dfs[i].index.to_list()
if s not in dfs[j].index.to_list()]
if non_shared_subjects.__len__() != 0:
warn_message = (
"Subjects in dataframe %s not in dataframe %s: %s" % (labels[i], labels[j], non_shared_subjects)
)
warn_message = ("Subjects in dataframe %s not in dataframe %s: %s"
% (labels[i], labels[j], non_shared_subjects))
print(warn_message)
warnings.warn(warn_message, category=UserWarning)
self.subjects_missing_data = (
Expand Down
2 changes: 2 additions & 0 deletions src/ageml/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def feature_extractor(df):

return X, y, feature_names


def significant_markers(bon, fdr):
"""Returns markers for significant features.
Expand All @@ -67,6 +68,7 @@ def significant_markers(bon, fdr):
markers.append("")
return markers


def log(func):
"""Decorator function to log stdout to log.txt."""

Expand Down
2 changes: 1 addition & 1 deletion src/ageml/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,4 @@ def deltas_by_groups(self, deltas, labels):
plt.xlabel("Gruop")
plt.ylabel("Delta")
plt.savefig(os.path.join(self.path_for_fig, "clinical_groups_box_plot.svg"))
plt.close()
plt.close()
1 change: 1 addition & 0 deletions tests/test_ageml/test_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def test_find_correlations():
assert np.array_equal(order, order_expected) is True
assert np.allclose(p_values, p_values_expected, atol=1e-7) is True


@pytest.mark.parametrize('X, Y, exception_msg', [
(np.array([[2, 4, np.nan], [4, 8, -12], [6, 12, -18], [8, 16, -24]]), np.array([1, 2, 3, 4]), "NaN entrie(s) found in X."),
(np.array([[2, 4, -6], [4, 8, -12], [6, 12, -18], [8, 16, -24]]), np.array([1, 2, 3, np.nan]), "NaN entrie(s) found in Y.")
Expand Down
2 changes: 2 additions & 0 deletions tests/test_ageml/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ def test_run_age(dummy_interface, features):
]
)


def test_run_lifestyle(dummy_interface, ages, factors):
# Run the lifestyle pipeline
ages_path = create_csv(ages, dummy_interface.dir_path)
Expand All @@ -371,6 +372,7 @@ def test_run_lifestyle(dummy_interface, ages, factors):
log_path = os.path.join(dummy_interface.dir_path, "log.txt")
assert os.path.exists(log_path)


def test_run_clinical(dummy_interface, ages, clinical):
# Run the clinical pipeline
ages_path = create_csv(ages, dummy_interface.dir_path)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_ageml/test_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def test_age_bias_correction(dummy_viz, np_test_data, dummy_ml):
# Cleanup
shutil.rmtree(os.path.dirname(svg_path))


def test_factors_vs_deltas(dummy_viz):
# Create dummy data
corrs = [[0.5, 0.6, 0.7, 0.8, 0.9]]
Expand All @@ -104,6 +105,7 @@ def test_factors_vs_deltas(dummy_viz):
# Cleanup
shutil.rmtree(os.path.dirname(svg_path))


def test_deltas_by_groups(dummy_viz, np_test_data, dummy_ml):
# Separate data in X and Y
X = np_test_data[:, :3]
Expand Down

0 comments on commit c65d341

Please sign in to comment.