Skip to content

Commit 649354f

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent c709932 commit 649354f

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

src/spatialdata_plot/pl/render.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def _render_shapes(
206206
if is_point.any():
207207
radius_values = shapes[is_point]["radius"]
208208
# Convert to numeric, replacing non-numeric values with NaN
209-
radius_numeric = pd.to_numeric(radius_values, errors='coerce')
209+
radius_numeric = pd.to_numeric(radius_values, errors="coerce")
210210
scale = radius_numeric * render_params.scale
211211
shapes.loc[is_point, "geometry"] = _geometry[is_point].buffer(scale.to_numpy())
212212

@@ -238,12 +238,12 @@ def _render_shapes(
238238
else:
239239
# If lengths don't match, pad or truncate to match
240240
if len(color_vector) > len(transformed_element):
241-
color_vector = color_vector[:len(transformed_element)]
241+
color_vector = color_vector[: len(transformed_element)]
242242
else:
243243
# Pad with the last color or na_color
244244
na_color = render_params.cmap_params.na_color.get_hex_with_alpha()
245245
color_vector = list(color_vector) + [na_color] * (len(transformed_element) - len(color_vector))
246-
246+
247247
transformed_element[col_for_color] = color_vector if color_source_vector is None else color_source_vector
248248
# Render shapes with datashader
249249
color_by_categorical = col_for_color is not None and color_source_vector is not None

src/spatialdata_plot/pl/utils.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,43 +96,43 @@
9696
def _extract_scalar_value(value: Any, default: float = 0.0) -> float:
9797
"""
9898
Extract a scalar float value from various data types.
99-
99+
100100
Handles pandas Series, arrays, lists, and other iterables by taking the first element.
101101
Converts non-numeric values to the default value.
102-
102+
103103
Parameters
104104
----------
105105
value : Any
106106
The value to extract a scalar from
107107
default : float, default 0.0
108108
Default value to return if conversion fails
109-
109+
110110
Returns
111111
-------
112112
float
113113
The extracted scalar value
114114
"""
115115
try:
116116
# Handle pandas Series or similar objects with iloc
117-
if hasattr(value, 'iloc'):
117+
if hasattr(value, "iloc"):
118118
if len(value) > 0:
119119
value = value.iloc[0]
120120
else:
121121
return default
122-
122+
123123
# Handle other array-like objects
124-
elif hasattr(value, '__len__') and not isinstance(value, (str, bytes)):
124+
elif hasattr(value, "__len__") and not isinstance(value, (str, bytes)):
125125
if len(value) > 0:
126126
value = value[0]
127127
else:
128128
return default
129-
129+
130130
# Convert to float, handling NaN values
131131
if pd.isna(value):
132132
return default
133-
133+
134134
return float(value)
135-
135+
136136
except (TypeError, ValueError, IndexError):
137137
return default
138138

@@ -481,7 +481,7 @@ def _process_point(row: pd.Series, scale: float) -> dict[str, Any]:
481481
radius_value = _extract_scalar_value(row["radius"], default=0.0)
482482
scale_value = _extract_scalar_value(scale, default=1.0)
483483
radius = radius_value * scale_value
484-
484+
485485
return {
486486
**row.to_dict(),
487487
"geometry": mpatches.Circle((row["geometry"].x, row["geometry"].y), radius=radius),

0 commit comments

Comments
 (0)