Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#787)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.5.5 → v0.5.7](astral-sh/ruff-pre-commit@v0.5.5...v0.5.7)
- [github.com/pre-commit/mirrors-mypy: v1.11.0 → v1.11.1](pre-commit/mirrors-mypy@v1.11.0...v1.11.1)

* use types-setuptools instead of types-pkg-resources

* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.5.7 → v0.6.1](astral-sh/ruff-pre-commit@v0.5.7...v0.6.1)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add seed to rng

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Eljas Roellin <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and eroell authored Aug 20, 2024
1 parent 0ee5c21 commit fd600ad
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
hooks:
- id: prettier
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.7
rev: v0.6.1
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --unsafe-fixes]
Expand Down
21 changes: 10 additions & 11 deletions tests/_scripts/catplot_create_expected_plots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,46 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"\n",
"import ehrapy as ep"
],
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2"
],
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"current_notebook_dir = %pwd\n",
"\n",
"_TEST_DATA_PATH = f\"{current_notebook_dir}/../test_data/dataset1.csv\"\n",
"_TEST_IMAGE_PATH = f\"{current_notebook_dir}/../plot/_images\"\n",
"adata_mini = ep.io.read_csv(\n",
" _TEST_DATA_PATH, columns_obs_only=[\"glucose\", \"weight\", \"disease\", \"station\"]\n",
")"
],
"outputs": []
"adata_mini = ep.io.read_csv(_TEST_DATA_PATH, columns_obs_only=[\"glucose\", \"weight\", \"disease\", \"station\"])"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"fig1 = ep.pl.catplot(adata_mini, jitter=False)\n",
"\n",
"fig1.savefig(f\"{_TEST_IMAGE_PATH}/catplot_vanilla_expected.png\", dpi=80)"
],
"outputs": []
]
}
],
"metadata": {
Expand Down
41 changes: 22 additions & 19 deletions tests/_scripts/cohort_tracker_test_create_expected_plots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,48 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"\n",
"import ehrapy as ep"
],
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2"
],
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"current_notebook_dir = %pwd\n",
"\n",
"_TEST_DATA_PATH = f\"{current_notebook_dir}/../tools/ehrapy_data/dataset1.csv\"\n",
"_TEST_IMAGE_PATH = f\"{current_notebook_dir}/../tools/_images\"\n",
"adata_mini = ep.io.read_csv(_TEST_DATA_PATH, columns_obs_only=[\"glucose\", \"weight\", \"disease\", \"station\"])"
],
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"ct = ep.tl.CohortTracker(adata_mini)\n",
"\n",
"ct(adata_mini, label=\"First step\", operations_done=\"Some operations\")\n",
"fig1, ax1 = ct.plot_cohort_barplot(show=False, legend_labels={\"weight\": \"weight(kg)\",\"glucose\": \"glucose(mg/dL)\"})\n",
"fig1, ax1 = ct.plot_cohort_barplot(show=False, legend_labels={\"weight\": \"weight(kg)\", \"glucose\": \"glucose(mg/dL)\"})\n",
"ct(adata_mini, label=\"Second step\", operations_done=\"Some other operations\")\n",
"fig2, ax2 = ct.plot_cohort_barplot(show=False, legend_labels={\"weight\": \"weight(kg)\",\"glucose\": \"glucose(mg/dL)\"})\n",
"fig2, ax2 = ct.plot_cohort_barplot(show=False, legend_labels={\"weight\": \"weight(kg)\", \"glucose\": \"glucose(mg/dL)\"})\n",
"\n",
"fig1.savefig(\n",
" f\"{_TEST_IMAGE_PATH}/cohorttracker_adata_mini_step1_vanilla_expected.png\",\n",
Expand All @@ -61,13 +63,13 @@
" f\"{_TEST_IMAGE_PATH}/cohorttracker_adata_mini_step2_vanilla_expected.png\",\n",
" dpi=80,\n",
")"
],
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ct = ep.tl.CohortTracker(adata_mini)\n",
"ct(adata_mini, label=\"First step\", operations_done=\"Some operations\")\n",
Expand All @@ -81,13 +83,13 @@
" f\"{_TEST_IMAGE_PATH}/cohorttracker_adata_mini_step1_use_settings_expected.png\",\n",
" dpi=80,\n",
")"
],
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ct = ep.tl.CohortTracker(adata_mini)\n",
"ct(adata_mini, label=\"First step\", operations_done=\"Some operations\")\n",
Expand All @@ -103,13 +105,13 @@
" f\"{_TEST_IMAGE_PATH}/cohorttracker_adata_mini_step1_use_settings_big_expected.png\",\n",
" dpi=80,\n",
")"
],
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"adata_mini_loose_category = adata_mini.copy()\n",
"ct = ep.tl.CohortTracker(adata_mini_loose_category)\n",
Expand All @@ -118,19 +120,21 @@
"adata_mini_loose_category = adata_mini_loose_category[adata_mini_loose_category.obs.disease == \"A\", :]\n",
"ct(adata_mini_loose_category)\n",
"\n",
"fig_loose_category, _ = ct.plot_cohort_barplot(color_palette=\"colorblind\", legend_labels={\"weight\": \"weight(kg)\",\"glucose\": \"glucose(mg/dL)\"}, show=False)\n",
"fig_loose_category, _ = ct.plot_cohort_barplot(\n",
" color_palette=\"colorblind\", legend_labels={\"weight\": \"weight(kg)\", \"glucose\": \"glucose(mg/dL)\"}, show=False\n",
")\n",
"\n",
"fig_loose_category.savefig(\n",
" f\"{_TEST_IMAGE_PATH}/cohorttracker_adata_mini_step2_loose_category_expected.png\",\n",
" dpi=80,\n",
")"
],
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ct = ep.tl.CohortTracker(adata_mini)\n",
"\n",
Expand All @@ -145,8 +149,7 @@
" f\"{_TEST_IMAGE_PATH}/cohorttracker_adata_mini_flowchart_expected.png\",\n",
" dpi=80,\n",
")"
],
"outputs": []
]
}
],
"metadata": {
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def root_dir():

@pytest.fixture
def rng():
return np.random.default_rng()
return np.random.default_rng(seed=42)


@pytest.fixture
Expand Down

0 comments on commit fd600ad

Please sign in to comment.