|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | | -from typing import TYPE_CHECKING |
| 3 | +from typing import TYPE_CHECKING, cast |
4 | 4 |
|
5 | 5 | import numpy as np |
6 | 6 | import pandas as pd |
@@ -92,17 +92,19 @@ def compute_group(self, data, scales): |
92 | 92 | group = data["group"].iloc[0] |
93 | 93 | range_x = scales.x.dimension() |
94 | 94 | range_y = scales.y.dimension() |
95 | | - x = np.linspace(range_x[0], range_x[1], params["n"]) |
96 | | - y = np.linspace(range_y[0], range_y[1], params["n"]) |
| 95 | + _x = np.linspace(range_x[0], range_x[1], params["n"]) |
| 96 | + _y = np.linspace(range_y[0], range_y[1], params["n"]) |
97 | 97 |
|
98 | 98 | # The grid must have a "similar" shape (n, p) to the var_data |
99 | | - X, Y = np.meshgrid(x, y) |
100 | | - var_data = np.array([data["x"].to_numpy(), data["y"].to_numpy()]).T |
| 99 | + X, Y = np.meshgrid(_x, _y) |
| 100 | + x = cast("FloatArrayLike", data["x"].to_numpy()) |
| 101 | + y = cast("FloatArrayLike", data["y"].to_numpy()) |
| 102 | + var_data = np.array([x, y]).T |
101 | 103 | grid = np.array([X.flatten(), Y.flatten()]).T |
102 | 104 | density = kde(var_data, grid, package, **kde_params) |
103 | 105 |
|
104 | 106 | if params["contour"]: |
105 | | - Z = density.reshape(len(x), len(y)) |
| 107 | + Z = density.reshape(len(_x), len(_y)) |
106 | 108 | data = contour_lines(X, Y, Z, params["levels"]) |
107 | 109 | # Each piece should have a distinct group |
108 | 110 | groups = str(group) + "-00" + data["piece"].astype(str) |
|
0 commit comments