Commit 177e846
committed
Reimplement NonUniformImage, PcolorImage in Python, not C.
It's much shorter...
None of this has test coverage though :( -- probably
needed for the PR; but one can first check that
`examples/images_contours_and_fields/image_nonuniform.py` still works.
Perf check:
```python
from timeit import Timer
from matplotlib import pyplot as plt
from matplotlib.image import NonUniformImage, PcolorImage
import numpy as np
N = 100
fig, (ax_nn, ax_nb, ax_pc) = plt.subplots(3)
ax_nn.set(xlim=(-.5, .75), ylim=(-.5, .75))
nn = NonUniformImage(ax_nn)
nn.set_data(np.linspace(0, 1, 2 * N) ** 2, np.linspace(0, 1, N) ** 2,
np.arange(2 * N**2).reshape((N, 2 * N)))
ax_nn.images.append(nn)
ax_nb.set(xlim=(-.5, .75), ylim=(-.5, .75))
nb = NonUniformImage(ax_nb, interpolation="bilinear")
nb.set_data(np.linspace(0, 1, 2 * N) ** 2, np.linspace(0, 1, N) ** 2,
np.arange(2 * N**2).reshape((N, 2 * N)))
ax_nb.images.append(nb)
ax_pc.set(xlim=(-.5, .75), ylim=(-.5, .75))
pc = PcolorImage(ax_pc)
pc.set_data(np.linspace(0, 1, 2 * N + 1) ** 2, np.linspace(0, 1, N + 1) ** 2,
np.arange(2 * N**2).reshape((N, 2 * N)))
ax_pc.images.append(pc)
fig.canvas.draw()
n, t = Timer("nn.make_image(fig._cachedRenderer)", globals=globals()).autorange()
print(f"NN: {1000*t/n:.4f}ms")
n, t = Timer("nb.make_image(fig._cachedRenderer)", globals=globals()).autorange()
print(f"NB: {1000*t/n:.4f}ms")
n, t = Timer("pc.make_image(fig._cachedRenderer)", globals=globals()).autorange()
print(f"PC: {1000*t/n:.4f}ms")
plt.show()
```1 parent 3b1be53 commit 177e846
File tree
7 files changed
+82
-431
lines changed- lib/matplotlib
- tests
- baseline_images/test_image
- src
7 files changed
+82
-431
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1052 | 1052 | | |
1053 | 1053 | | |
1054 | 1054 | | |
1055 | | - | |
1056 | | - | |
1057 | | - | |
1058 | | - | |
1059 | | - | |
1060 | | - | |
1061 | | - | |
1062 | | - | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
1063 | 1100 | | |
1064 | 1101 | | |
1065 | 1102 | | |
| |||
1183 | 1220 | | |
1184 | 1221 | | |
1185 | 1222 | | |
1186 | | - | |
1187 | | - | |
1188 | | - | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
1189 | 1235 | | |
1190 | 1236 | | |
1191 | 1237 | | |
1192 | 1238 | | |
1193 | 1239 | | |
1194 | | - | |
1195 | | - | |
1196 | | - | |
1197 | | - | |
1198 | | - | |
1199 | | - | |
1200 | | - | |
1201 | 1240 | | |
1202 | | - | |
1203 | | - | |
1204 | | - | |
1205 | | - | |
1206 | | - | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
1207 | 1250 | | |
1208 | 1251 | | |
1209 | 1252 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1224 | 1224 | | |
1225 | 1225 | | |
1226 | 1226 | | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
380 | | - | |
381 | 380 | | |
382 | 381 | | |
383 | 382 | | |
| |||
This file was deleted.
0 commit comments