Skip to content

Commit 207b18d

Browse files
Ruff Format
1 parent f394f2a commit 207b18d

File tree

15 files changed

+67
-69
lines changed

15 files changed

+67
-69
lines changed

deploy_hf_space.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
from huggingface_hub import HfApi
32

43
api = HfApi()

src/impatient/app/dashapp/callbacks.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ def color_to_class(ontology, color_hex):
7676

7777

7878
def make_default_figure(
79-
images=None,
80-
stroke_color="",
81-
stroke_width=3,
82-
shapes=[],
83-
source_img=None,
79+
images=None,
80+
stroke_color="",
81+
stroke_width=3,
82+
shapes=[],
83+
source_img=None,
8484
):
8585
fig = plot_common.dummy_fig()
8686
plot_common.add_layout_images_to_fig(fig, images)
@@ -113,12 +113,12 @@ def save_img_classifier(clf, label_to_colors_args, segmenter_args):
113113

114114

115115
def show_segmentation(
116-
image_path,
117-
mask_shapes,
118-
features,
119-
segmenter_args,
120-
class_label_colormap,
121-
onto_tree_imgannot,
116+
image_path,
117+
mask_shapes,
118+
features,
119+
segmenter_args,
120+
class_label_colormap,
121+
onto_tree_imgannot,
122122
):
123123
"""adds an image showing segmentations to a figure's layout"""
124124
# add 1 because classifier takes 0 to mean no mask
@@ -176,14 +176,14 @@ def register_callbacks(dashapp):
176176
],
177177
)
178178
def annotation_react(
179-
href,
180-
graph_relayoutData,
181-
any_label_class_button_value,
182-
stroke_width_value,
183-
show_segmentation_value,
184-
download_button_n_clicks,
185-
sigma_range_slider_value,
186-
masks_data,
179+
href,
180+
graph_relayoutData,
181+
any_label_class_button_value,
182+
stroke_width_value,
183+
show_segmentation_value,
184+
download_button_n_clicks,
185+
sigma_range_slider_value,
186+
masks_data,
187187
):
188188
classified_image_store_data = dash.no_update
189189
classifier_store_data = dash.no_update
@@ -216,8 +216,8 @@ def annotation_react(
216216
]
217217

218218
if cbcontext in ["sigma-range-slider.value"] or (
219-
("Show segmentation" in show_segmentation_value)
220-
and (len(masks_data["shapes"]) > 0)
219+
("Show segmentation" in show_segmentation_value)
220+
and (len(masks_data["shapes"]) > 0)
221221
):
222222
segmentation_features_dict = {
223223
"intensity": True,
@@ -257,7 +257,7 @@ def annotation_react(
257257

258258
# We want the segmentation to be computed
259259
if ("Show segmentation" in show_segmentation_value) and (
260-
len(masks_data["shapes"]) > 0
260+
len(masks_data["shapes"]) > 0
261261
):
262262
segimgpng = None
263263
try:

src/impatient/app/dashapp/common_func.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
def load_onto():
66
with open(
7-
os.path.join("/home/impatient/data/ontology/", "ontology.json"), "r"
7+
os.path.join("/home/impatient/data/ontology/", "ontology.json"), "r"
88
) as fp:
99
onto_tree = json.load(fp)
1010
onto_tree_imgannot = [i for i in onto_tree if i["data"]["image_annotation"] == True]

src/impatient/app/dashapp/shapes_to_segmentations.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def fromhex(n):
2828

2929

3030
def label_to_colors(
31-
img, colormap=px.colors.qualitative.Light24, alpha=128, color_class_offset=0
31+
img, colormap=px.colors.qualitative.Light24, alpha=128, color_class_offset=0
3232
):
3333
"""
3434
Take MxN matrix containing integers representing labels and return an MxNx4
@@ -44,7 +44,7 @@ def label_to_colors(
4444
for key, value in colormap.items():
4545
hex_value = value.replace("#", "")
4646
colormap_converted[key] = tuple(
47-
[fromhex(hex_value[s: s + 2]) for s in range(0, len(hex_value), 2)]
47+
[fromhex(hex_value[s : s + 2]) for s in range(0, len(hex_value), 2)]
4848
)
4949
cimg = np.zeros(img.shape[:2] + (3,), dtype="uint8")
5050
label_on_img = np.unique(img).tolist()
@@ -69,11 +69,11 @@ def grey_labels(img):
6969

7070

7171
def compute_segmentations(
72-
shapes,
73-
img_path=None,
74-
features=None,
75-
shape_layers=None,
76-
label_to_colors_args={},
72+
shapes,
73+
img_path=None,
74+
features=None,
75+
shape_layers=None,
76+
label_to_colors_args={},
7777
):
7878
# load original image
7979
img = img_to_ubyte_array(img_path)

src/impatient/app/dashapp/trainable_segmentation.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def _texture_filter(gaussian_filtered):
2727

2828

2929
def _mutiscale_basic_features_singlechannel(
30-
img, intensity=True, edges=True, texture=True, sigma_min=0.5, sigma_max=16
30+
img, intensity=True, edges=True, texture=True, sigma_min=0.5, sigma_max=16
3131
):
3232
"""Features for a single channel nd image.
3333
@@ -63,13 +63,13 @@ def _mutiscale_basic_features_singlechannel(
6363

6464

6565
def multiscale_basic_features(
66-
image,
67-
multichannel=True,
68-
intensity=True,
69-
edges=True,
70-
texture=True,
71-
sigma_min=0.5,
72-
sigma_max=16,
66+
image,
67+
multichannel=True,
68+
intensity=True,
69+
edges=True,
70+
texture=True,
71+
sigma_min=0.5,
72+
sigma_max=16,
7373
):
7474
"""Local features for a single- or multi-channel nd image.
7575

src/impatient/app/dashapp/use_ml_image_segmentation_classifier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def getenv(e):
3838

3939

4040
def use_img_classifier_in_mem(
41-
clf, segmenter_args, label_to_colors_args, img_path, out_img
41+
clf, segmenter_args, label_to_colors_args, img_path, out_img
4242
):
4343
img = skimage.io.imread(img_path)
4444

src/impatient/app/historeport/boqa.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ def boqa(alpha, beta, query, items_stat):
3535
# Cardinality calculation of terms between H and Q
3636
m = matrix_m(query, hidden)
3737
a[disease] = (
38-
pow(beta, m[0, 1])
39-
* pow(1 - beta, m[1, 1])
40-
* pow(1 - alpha, m[0, 0])
41-
* pow(alpha, m[1, 0])
38+
pow(beta, m[0, 1])
39+
* pow(1 - beta, m[1, 1])
40+
* pow(1 - alpha, m[0, 0])
41+
* pow(alpha, m[1, 0])
4242
)
4343
a_init += a[disease]
4444
for disease in items_stat:

src/impatient/app/historeport/onto_func.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ def update_ontology(self, dest_onto: object) -> list:
165165
updated_jstree_as_list.append(i)
166166
elif i["id"] in dest_onto.jstree_as_dict.keys():
167167
if (
168-
i["text"] != dest_onto.jstree_as_dict[i["id"]]["text"]
169-
or i["data"] != dest_onto.jstree_as_dict[i["id"]]["data"]
168+
i["text"] != dest_onto.jstree_as_dict[i["id"]]["text"]
169+
or i["data"] != dest_onto.jstree_as_dict[i["id"]]["data"]
170170
):
171171
# If destination has modified data or name: update
172172
i["text"] = dest_onto.jstree_as_dict[i["id"]]["text"]
@@ -213,8 +213,8 @@ def update_ontology(self, dest_onto: object) -> list:
213213
# If destination has different parent ID: change it.
214214
for i in dest_onto.jstree_as_dict.keys():
215215
if (
216-
dest_onto.jstree_as_dict[i]["parent"]
217-
!= self.jstree_as_dict[i]["parent"]
216+
dest_onto.jstree_as_dict[i]["parent"]
217+
!= self.jstree_as_dict[i]["parent"]
218218
):
219219
self.jstree_as_dict[i]["parent"] = dest_onto.jstree_as_dict[i]["parent"]
220220

src/impatient/app/historeport/routes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def repredict_reports():
5454
redirect: Redirect to the historeports index HTML page
5555
"""
5656
with open(
57-
os.path.join("/home/impatient/data/ontology/", "ontology.json"), "r"
57+
os.path.join("/home/impatient/data/ontology/", "ontology.json"), "r"
5858
) as fp:
5959
onto_tree = json.load(fp)
6060
df = db_to_df()
@@ -81,7 +81,7 @@ def repredict_reports():
8181
@bp.route("/historeport/download", methods=["GET"])
8282
def histo_download():
8383
with open(
84-
os.path.join("/home/impatient/data/ontology/", "ontology.json"), "r"
84+
os.path.join("/home/impatient/data/ontology/", "ontology.json"), "r"
8585
) as fp:
8686
onto_tree = json.load(fp)
8787
df = db_to_df()
@@ -126,7 +126,7 @@ def historeport():
126126
# If no args: empty form
127127
else:
128128
with open(
129-
os.path.join(current_app.config["ONTOLOGY_FOLDER"], "ontology.json")
129+
os.path.join(current_app.config["ONTOLOGY_FOLDER"], "ontology.json")
130130
) as f:
131131
empty_json_tree = json.load(f)
132132
form = ReportForm(ontology_tree=empty_json_tree)

src/impatient/app/histostats/routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def statsindex():
1313
"""
1414
# Up to stat_per_diag to move in the historeport part to not always regenerate
1515
with open(
16-
os.path.join("/home/impatient/data/ontology/", "ontology.json"), "r"
16+
os.path.join("/home/impatient/data/ontology/", "ontology.json"), "r"
1717
) as fp:
1818
onto_tree = json.load(fp)
1919
df = db_to_df()

0 commit comments

Comments
 (0)