Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def extend(aggs, xr_ds, vt, bounds):
# Convert from bin centers to interval edges
x_breaks = infer_interval_breaks(xr_ds[x_name].values)
y_breaks = infer_interval_breaks(xr_ds[y_name].values)
x0, x1, y0, y1 = bounds
xspan = x1 - x0
yspan = y1 - y0
xscaled = (x_mapper(x_breaks) - x0) / xspan
yscaled = (y_mapper(y_breaks) - y0) / yspan
xmask = np.where((xscaled >= 0) & (xscaled <= 1))
ymask = np.where((yscaled >= 0) & (yscaled <= 1))
xm0, xm1 = max(xmask[0].min() - 1, 0), xmask[0].max() + 1
ym0, ym1 = max(ymask[0].min() - 1, 0), ymask[0].max() + 1
plot_height, plot_width = aggs[0].shape[:2]
# Downselect xs and ys and convert to int
def compute_x_bounds(self, xr_ds):
xs = xr_ds[self.x].values
xs = infer_interval_breaks(xs, axis=1)
xs = infer_interval_breaks(xs, axis=0)
bounds = Glyph._compute_bounds_2d(xs)
return self.maybe_expand_bounds(bounds)
def compute_x_bounds(self, xr_ds):
xs = xr_ds[self.x].values
xs = infer_interval_breaks(xs, axis=1)
xs = infer_interval_breaks(xs, axis=0)
bounds = Glyph._compute_bounds_2d(xs)
return self.maybe_expand_bounds(bounds)
def extend(aggs, xr_ds, vt, bounds):
# Convert from bin centers to interval edges
x_breaks = infer_interval_breaks(xr_ds[x_name].values)
y_breaks = infer_interval_breaks(xr_ds[y_name].values)
x0, x1, y0, y1 = bounds
xspan = x1 - x0
yspan = y1 - y0
xscaled = (x_mapper(x_breaks) - x0) / xspan
yscaled = (y_mapper(y_breaks) - y0) / yspan
xmask = np.where((xscaled >= 0) & (xscaled <= 1))
ymask = np.where((yscaled >= 0) & (yscaled <= 1))
xm0, xm1 = max(xmask[0].min() - 1, 0), xmask[0].max() + 1
ym0, ym1 = max(ymask[0].min() - 1, 0), ymask[0].max() + 1
plot_height, plot_width = aggs[0].shape[:2]
# Downselect xs and ys and convert to int
xs = (xscaled[xm0:xm1 + 1] * plot_width).astype(int).clip(0, plot_width)
def extend(aggs, xr_ds, vt, bounds):
# Convert from bin centers to interval edges
x_breaks = xr_ds[x_name].values
x_breaks = infer_interval_breaks(x_breaks, axis=1)
x_breaks = infer_interval_breaks(x_breaks, axis=0)
y_breaks = xr_ds[y_name].values
y_breaks = infer_interval_breaks(y_breaks, axis=1)
y_breaks = infer_interval_breaks(y_breaks, axis=0)
# Scale x and y vertices into integer canvas coordinates
x0, x1, y0, y1 = bounds
xspan = x1 - x0
yspan = y1 - y0
xscaled = (x_mapper(x_breaks) - x0) / xspan
yscaled = (y_mapper(y_breaks) - y0) / yspan
plot_height, plot_width = aggs[0].shape[:2]
xs = (xscaled * plot_width).astype(int)
def extend(aggs, xr_ds, vt, bounds):
# Convert from bin centers to interval edges
x_breaks = xr_ds[x_name].values
x_breaks = infer_interval_breaks(x_breaks, axis=1)
x_breaks = infer_interval_breaks(x_breaks, axis=0)
y_breaks = xr_ds[y_name].values
y_breaks = infer_interval_breaks(y_breaks, axis=1)
y_breaks = infer_interval_breaks(y_breaks, axis=0)
# Scale x and y vertices into integer canvas coordinates
x0, x1, y0, y1 = bounds
xspan = x1 - x0
yspan = y1 - y0
xscaled = (x_mapper(x_breaks) - x0) / xspan
yscaled = (y_mapper(y_breaks) - y0) / yspan
plot_height, plot_width = aggs[0].shape[:2]
xs = (xscaled * plot_width).astype(int)
ys = (yscaled * plot_height).astype(int)
def compute_y_bounds(self, xr_ds):
ys = xr_ds[self.y].values
ys = infer_interval_breaks(ys, axis=1)
ys = infer_interval_breaks(ys, axis=0)
bounds = Glyph._compute_bounds_2d(ys)
return self.maybe_expand_bounds(bounds)
def extend(aggs, xr_ds, vt, bounds):
# Convert from bin centers to interval edges
x_breaks = xr_ds[x_name].values
x_breaks = infer_interval_breaks(x_breaks, axis=1)
x_breaks = infer_interval_breaks(x_breaks, axis=0)
y_breaks = xr_ds[y_name].values
y_breaks = infer_interval_breaks(y_breaks, axis=1)
y_breaks = infer_interval_breaks(y_breaks, axis=0)
# Scale x and y vertices into integer canvas coordinates
x0, x1, y0, y1 = bounds
xspan = x1 - x0
yspan = y1 - y0
xscaled = (x_mapper(x_breaks) - x0) / xspan
yscaled = (y_mapper(y_breaks) - y0) / yspan
plot_height, plot_width = aggs[0].shape[:2]
xs = (xscaled * plot_width).astype(int)
ys = (yscaled * plot_height).astype(int)
coord_dims = xr_ds.coords[x_name].dims
aggs_and_cols = aggs + info(xr_ds.transpose(*coord_dims))
def extend(aggs, xr_ds, vt, bounds):
# Convert from bin centers to interval edges
x_breaks = xr_ds[x_name].values
x_breaks = infer_interval_breaks(x_breaks, axis=1)
x_breaks = infer_interval_breaks(x_breaks, axis=0)
y_breaks = xr_ds[y_name].values
y_breaks = infer_interval_breaks(y_breaks, axis=1)
y_breaks = infer_interval_breaks(y_breaks, axis=0)
# Scale x and y vertices into integer canvas coordinates
x0, x1, y0, y1 = bounds
xspan = x1 - x0
yspan = y1 - y0
xscaled = (x_mapper(x_breaks) - x0) / xspan
yscaled = (y_mapper(y_breaks) - y0) / yspan
plot_height, plot_width = aggs[0].shape[:2]
xs = (xscaled * plot_width).astype(int)
ys = (yscaled * plot_height).astype(int)
coord_dims = xr_ds.coords[x_name].dims
aggs_and_cols = aggs + info(xr_ds.transpose(*coord_dims))
_extend(plot_height, plot_width, xs, ys, *aggs_and_cols)
def compute_y_bounds(self, xr_ds):
ys = xr_ds[self.y].values
ys = infer_interval_breaks(ys, axis=1)
ys = infer_interval_breaks(ys, axis=0)
bounds = Glyph._compute_bounds_2d(ys)
return self.maybe_expand_bounds(bounds)