Skip to content

Commit c5ec080

Browse files
committed
refactor bounds_init logic to make intent clearer, add comment, remove unused variables
1 parent 5ae771e commit c5ec080

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

fastplotlib/graphics/_positions_base.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ def add_rectangle_selector(
282282
initial (xmin, xmax, ymin, ymax) of the selection
283283
"""
284284
# computes args to create selectors
285-
n_datapoints = self.data.value.shape[0]
286285

287286
# remove any nans
288287
data = self.data.value[~np.any(np.isnan(self.data.value), axis=1)]
@@ -318,7 +317,6 @@ def _get_linear_selector_init_args(
318317
self, axis: str, padding
319318
) -> tuple[tuple[float, float], tuple[float, float], float, float]:
320319
# computes args to create selectors
321-
n_datapoints = self.data.value.shape[0]
322320

323321
# remove any nans
324322
data = self.data.value[~np.any(np.isnan(self.data.value), axis=1)]
@@ -335,10 +333,10 @@ def _get_linear_selector_init_args(
335333

336334
axis_vals_min = np.floor(axis_vals.min()).astype(int)
337335
axis_vals_max = np.floor(axis_vals.max()).astype(int)
336+
axis_vals_25p = axis_vals_min + 0.25 * (axis_vals_max - axis_vals_min)
338337

339-
bounds_init = axis_vals_min, axis_vals_min + 0.25 * (
340-
axis_vals_max - axis_vals_min
341-
)
338+
# default selection is 25% of the image
339+
bounds_init = axis_vals_min, axis_vals_25p
342340
limits = axis_vals_min, axis_vals_max
343341

344342
# width or height of selector

0 commit comments

Comments
 (0)