Skip to content

Commit af16f8a

Browse files
committed
Add lint fixes
1 parent 7f75076 commit af16f8a

File tree

8 files changed

+34
-77
lines changed

8 files changed

+34
-77
lines changed

cyclops/evaluate/metrics/experimental/utils/types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# noqa: A005
2+
13
"""Utilities for array-API compatibility."""
24

35
import builtins

cyclops/monitor/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,12 @@ def get_args(obj: Any, kwargs: Dict[str, Any]) -> Dict[str, Any]:
258258
259259
"""
260260
args = {}
261-
for key in kwargs:
261+
for key, value in kwargs.items():
262262
if (inspect.isclass(obj) and key in inspect.signature(obj).parameters) or (
263263
(inspect.ismethod(obj) or inspect.isfunction(obj))
264264
and key in inspect.getfullargspec(obj).args
265265
):
266-
args[key] = kwargs[key]
266+
args[key] = value
267267
return args
268268

269269

cyclops/utils/profile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# noqa: A005
2+
13
"""Useful functions for timing, profiling."""
24

35
import logging

docs/source/examples/metrics.ipynb

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"metadata": {},
1616
"outputs": [],
1717
"source": [
18+
"\"\"\"Imports.\"\"\"\n",
19+
"\n",
1820
"import numpy as np\n",
1921
"import pandas as pd\n",
2022
"from datasets.arrow_dataset import Dataset\n",
@@ -57,7 +59,7 @@
5759
"outputs": [],
5860
"source": [
5961
"df = breast_cancer_data.frame\n",
60-
"df.describe().T"
62+
"print(df.describe().T)"
6163
]
6264
},
6365
{
@@ -222,7 +224,7 @@
222224
"outputs": [],
223225
"source": [
224226
"slice_spec = SliceSpec(spec_list, intersections=2)\n",
225-
"slice_spec"
227+
"print(slice_spec)"
226228
]
227229
},
228230
{
@@ -316,15 +318,8 @@
316318
" target_columns=\"target\",\n",
317319
" prediction_columns=\"preds_prob\",\n",
318320
")\n",
319-
"fairness_result"
321+
"print(fairness_result)"
320322
]
321-
},
322-
{
323-
"cell_type": "code",
324-
"execution_count": null,
325-
"metadata": {},
326-
"outputs": [],
327-
"source": []
328323
}
329324
],
330325
"metadata": {

docs/source/examples/report.ipynb

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Report Generation for Heart Failure Prediction\n",
8+
"Here's an example to demonstrate how we can generate a report as we proceed through all the steps to train and evaluate a model. For this purpose, we are going to use Kaggle's heart prediction failure dataset and gradually populate the report with information about dataset, model and results."
9+
]
10+
},
311
{
412
"cell_type": "code",
513
"execution_count": null,
614
"metadata": {},
715
"outputs": [],
816
"source": [
17+
"\"\"\"Imports.\"\"\"\n",
18+
"\n",
919
"import copy\n",
1020
"import inspect\n",
1121
"import os\n",
@@ -23,21 +33,14 @@
2333
"from tqdm import tqdm\n",
2434
"\n",
2535
"from cyclops.data.slicer import SliceSpec\n",
36+
"from cyclops.evaluate import evaluator\n",
2637
"from cyclops.evaluate.metrics import create_metric\n",
2738
"from cyclops.evaluate.metrics.experimental.metric_dict import MetricDict\n",
2839
"from cyclops.report import ModelCardReport\n",
2940
"from cyclops.report.plot.classification import ClassificationPlotter\n",
3041
"from cyclops.report.utils import flatten_results_dict"
3142
]
3243
},
33-
{
34-
"cell_type": "markdown",
35-
"metadata": {},
36-
"source": [
37-
"# Report Generation for Heart Failure Prediction\n",
38-
"Here's an example to demonstrate how we can generate a report as we proceed through all the steps to train and evaluate a model. For this purpose, we are going to use Kaggle's heart prediction failure dataset and gradually populate the report with information about dataset, model and results."
39-
]
40-
},
4144
{
4245
"cell_type": "markdown",
4346
"metadata": {},
@@ -105,7 +108,7 @@
105108
"metadata": {},
106109
"outputs": [],
107110
"source": [
108-
"df.describe().T"
111+
"print(df.describe().T)"
109112
]
110113
},
111114
{
@@ -531,9 +534,6 @@
531534
"metadata": {},
532535
"outputs": [],
533536
"source": [
534-
"from cyclops.evaluate import evaluator\n",
535-
"\n",
536-
"\n",
537537
"# Create Dataset object\n",
538538
"heart_failure_data = Dataset.from_pandas(df_test)\n",
539539
"\n",
@@ -557,24 +557,6 @@
557557
")"
558558
]
559559
},
560-
{
561-
"cell_type": "code",
562-
"execution_count": null,
563-
"metadata": {},
564-
"outputs": [],
565-
"source": [
566-
"result"
567-
]
568-
},
569-
{
570-
"cell_type": "code",
571-
"execution_count": null,
572-
"metadata": {},
573-
"outputs": [],
574-
"source": [
575-
"results_flat"
576-
]
577-
},
578560
{
579561
"cell_type": "markdown",
580562
"metadata": {},
@@ -878,7 +860,7 @@
878860
],
879861
"metadata": {
880862
"kernelspec": {
881-
"display_name": "cyclops",
863+
"display_name": "Python 3 (ipykernel)",
882864
"language": "python",
883865
"name": "python3"
884866
},
@@ -892,9 +874,9 @@
892874
"name": "python",
893875
"nbconvert_exporter": "python",
894876
"pygments_lexer": "ipython3",
895-
"version": "3.10.11"
877+
"version": "3.10.12"
896878
}
897879
},
898880
"nbformat": 4,
899-
"nbformat_minor": 2
881+
"nbformat_minor": 4
900882
}

docs/source/tutorials/diabetes_130/readmission_prediction.ipynb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,6 @@
152152
"variables = diabetes_130_data[\"variables\"]"
153153
]
154154
},
155-
{
156-
"cell_type": "code",
157-
"execution_count": null,
158-
"metadata": {
159-
"tags": []
160-
},
161-
"outputs": [],
162-
"source": [
163-
"metadata"
164-
]
165-
},
166155
{
167156
"cell_type": "code",
168157
"execution_count": null,

docs/source/tutorials/diabetes_130/readmission_prediction_detectron.ipynb

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,6 @@
115115
"variables = diabetes_130_data[\"variables\"]"
116116
]
117117
},
118-
{
119-
"cell_type": "code",
120-
"execution_count": null,
121-
"metadata": {
122-
"tags": []
123-
},
124-
"outputs": [],
125-
"source": [
126-
"metadata"
127-
]
128-
},
129118
{
130119
"cell_type": "code",
131120
"execution_count": null,
@@ -749,7 +738,7 @@
749738
"name": "python",
750739
"nbconvert_exporter": "python",
751740
"pygments_lexer": "ipython3",
752-
"version": "3.9.7"
741+
"version": "3.10.12"
753742
}
754743
},
755744
"nbformat": 4,

tests/cyclops/evaluate/metrics/experimental/utils/test_ops.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,19 +189,17 @@ def test_apply_to_nested_collections(self):
189189
},
190190
}
191191

192-
for k in expected_result:
192+
for k, v in expected_result.items():
193193
assert k in result
194194

195-
if isinstance(expected_result[k], dict):
196-
for kk in expected_result[k]:
195+
if isinstance(v, dict):
196+
for kk in v:
197197
assert kk in result[k]
198-
assert anp.all(expected_result[k][kk] == result[k][kk])
199-
elif isinstance(expected_result[k], (tuple, list)):
200-
assert all(
201-
anp.all(a == b) for a, b in zip(result[k], expected_result[k])
202-
)
198+
assert anp.all(v[kk] == result[k][kk])
199+
elif isinstance(v, (tuple, list)):
200+
assert all(anp.all(a == b) for a, b in zip(result[k], v))
203201
else:
204-
assert anp.all(expected_result[k] == result[k])
202+
assert anp.all(v == result[k])
205203

206204

207205
class TestBincount:

0 commit comments

Comments
 (0)