|
130 | 130 | "\u001b[31m---------------------------------------------------------------------------\u001b[39m", |
131 | 131 | "\u001b[31mValueError\u001b[39m Traceback (most recent call last)", |
132 | 132 | "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[4]\u001b[39m\u001b[32m, line 2\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m khisto \u001b[38;5;28;01mimport\u001b[39;00m matplotlib\n\u001b[32m----> \u001b[39m\u001b[32m2\u001b[39m matplotlib.hist([data, [\u001b[32m1\u001b[39m, \u001b[32m2\u001b[39m, \u001b[32m3\u001b[39m], [\u001b[32m2\u001b[39m,\u001b[32m2\u001b[39m,\u001b[32m2\u001b[39m,\u001b[32m2\u001b[39m]], max_bins=\u001b[32m20\u001b[39m, alpha=\u001b[32m0.5\u001b[39m)\n", |
133 | | - "\u001b[36mFile \u001b[39m\u001b[32m~/python/khisto-python/src/khisto/matplotlib/hist.py:122\u001b[39m, in \u001b[36mhist\u001b[39m\u001b[34m(x, range, max_bins, density, cumulative, histtype, orientation, log, color, label, ax, edgecolor, linewidth, alpha, **kwargs)\u001b[39m\n\u001b[32m 119\u001b[39m ax = plt.gca()\n\u001b[32m 121\u001b[39m \u001b[38;5;66;03m# Compute histogram using khisto\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m122\u001b[39m hist_values, bin_edges = \u001b[30;43mkhisto_histogram\u001b[39;49m\u001b[30;43m(\u001b[39;49m\n\u001b[32m 123\u001b[39m \u001b[30;43m \u001b[39;49m\u001b[30;43mx\u001b[39;49m\u001b[30;43m,\u001b[39;49m\u001b[30;43m \u001b[39;49m\u001b[30;43mrange\u001b[39;49m\u001b[30;43m=\u001b[39;49m\u001b[30;43mrange\u001b[39;49m\u001b[30;43m,\u001b[39;49m\u001b[30;43m \u001b[39;49m\u001b[30;43mmax_bins\u001b[39;49m\u001b[30;43m=\u001b[39;49m\u001b[30;43mmax_bins\u001b[39;49m\u001b[30;43m,\u001b[39;49m\u001b[30;43m \u001b[39;49m\u001b[30;43mdensity\u001b[39;49m\u001b[30;43m=\u001b[39;49m\u001b[30;43mdensity\u001b[39;49m\n\u001b[32m 124\u001b[39m \u001b[30;43m\u001b[39;49m\u001b[30;43m)\u001b[39;49m\n\u001b[32m 125\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m cumulative_mode != \u001b[32m0\u001b[39m:\n\u001b[32m 126\u001b[39m hist_values = _apply_cumulative(\n\u001b[32m 127\u001b[39m hist_values,\n\u001b[32m 128\u001b[39m bin_edges,\n\u001b[32m 129\u001b[39m density=density,\n\u001b[32m 130\u001b[39m reverse=cumulative_mode < \u001b[32m0\u001b[39m,\n\u001b[32m 131\u001b[39m )\n", |
| 133 | + "\u001b[36mFile \u001b[39m\u001b[32m~/python/khisto-python/src/khisto/matplotlib/hist.py:122\u001b[39m, in \u001b[36mhist\u001b[39m\u001b[34m(x, range, max_bins, density, cumulative, histtype, orientation, log, color, label, ax, edgecolor, linewidth, alpha, **kwargs)\u001b[39m\n\u001b[32m 119\u001b[39m ax = plt.gca()\n\u001b[32m 121\u001b[39m \u001b[38;5;66;03m# Compute histogram using khisto\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m122\u001b[39m hist_values, bin_edges = \u001b[30;43mkhisto_histogram\u001b[39;49m\u001b[30;43m(\u001b[39;49m\u001b[30;43mx\u001b[39;49m\u001b[30;43m,\u001b[39;49m\u001b[30;43m \u001b[39;49m\u001b[30;43mrange\u001b[39;49m\u001b[30;43m=\u001b[39;49m\u001b[30;43mrange\u001b[39;49m\u001b[30;43m,\u001b[39;49m\u001b[30;43m \u001b[39;49m\u001b[30;43mmax_bins\u001b[39;49m\u001b[30;43m=\u001b[39;49m\u001b[30;43mmax_bins\u001b[39;49m\u001b[30;43m,\u001b[39;49m\u001b[30;43m \u001b[39;49m\u001b[30;43mdensity\u001b[39;49m\u001b[30;43m=\u001b[39;49m\u001b[30;43mdensity\u001b[39;49m\u001b[30;43m)\u001b[39;49m\n\u001b[32m 123\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m cumulative_mode != \u001b[32m0\u001b[39m:\n\u001b[32m 124\u001b[39m hist_values = _apply_cumulative(\n\u001b[32m 125\u001b[39m hist_values,\n\u001b[32m 126\u001b[39m bin_edges,\n\u001b[32m 127\u001b[39m density=density,\n\u001b[32m 128\u001b[39m reverse=cumulative_mode < \u001b[32m0\u001b[39m,\n\u001b[32m 129\u001b[39m )\n", |
134 | 134 | "\u001b[36mFile \u001b[39m\u001b[32m~/python/khisto-python/src/khisto/array/histogram/api.py:107\u001b[39m, in \u001b[36mhistogram\u001b[39m\u001b[34m(a, range, max_bins, density)\u001b[39m\n\u001b[32m 53\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mhistogram\u001b[39m(\n\u001b[32m 54\u001b[39m a: ArrayLike,\n\u001b[32m 55\u001b[39m \u001b[38;5;28mrange\u001b[39m: Optional[\u001b[38;5;28mtuple\u001b[39m[\u001b[38;5;28mfloat\u001b[39m, \u001b[38;5;28mfloat\u001b[39m]] = \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[32m 56\u001b[39m max_bins: Optional[\u001b[38;5;28mint\u001b[39m] = \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[32m 57\u001b[39m density: \u001b[38;5;28mbool\u001b[39m = \u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[32m 58\u001b[39m ) -> \u001b[38;5;28mtuple\u001b[39m[NDArray[np.float64], NDArray[np.float64]]:\n\u001b[32m 59\u001b[39m \u001b[38;5;250m \u001b[39m\u001b[33;03m\"\"\"Compute an optimal histogram using the Khiops binning algorithm.\u001b[39;00m\n\u001b[32m 60\u001b[39m \n\u001b[32m 61\u001b[39m \u001b[33;03m Parameters\u001b[39;00m\n\u001b[32m (...)\u001b[39m\u001b[32m 105\u001b[39m \u001b[33;03m Analysis, 180:0-0, 2023.\u001b[39;00m\n\u001b[32m 106\u001b[39m \u001b[33;03m \"\"\"\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m107\u001b[39m arr = \u001b[30;43mnp\u001b[39;49m\u001b[30;43m.\u001b[39;49m\u001b[30;43masarray\u001b[39;49m\u001b[30;43m(\u001b[39;49m\u001b[30;43ma\u001b[39;49m\u001b[30;43m,\u001b[39;49m\u001b[30;43m \u001b[39;49m\u001b[30;43mdtype\u001b[39;49m\u001b[30;43m=\u001b[39;49m\u001b[30;43mnp\u001b[39;49m\u001b[30;43m.\u001b[39;49m\u001b[30;43mfloat64\u001b[39;49m\u001b[30;43m)\u001b[39;49m\n\u001b[32m 109\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m arr.ndim != \u001b[32m1\u001b[39m:\n\u001b[32m 110\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[32m 111\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mExpected 1-D array, got \u001b[39m\u001b[38;5;132;01m{\u001b[39;00marr.ndim\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m-D array instead. \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 112\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mReshape your data or flatten it before calling histogram.\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 113\u001b[39m )\n", |
135 | 135 | "\u001b[31mValueError\u001b[39m: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (3,) + inhomogeneous part." |
136 | 136 | ] |
|
153 | 153 | }, |
154 | 154 | { |
155 | 155 | "cell_type": "code", |
156 | | - "execution_count": 5, |
| 156 | + "execution_count": null, |
157 | 157 | "id": "23c19584", |
158 | 158 | "metadata": {}, |
159 | 159 | "outputs": [ |
|
174 | 174 | " <a list of 3 BarContainer objects>)" |
175 | 175 | ] |
176 | 176 | }, |
177 | | - "execution_count": 5, |
| 177 | + "execution_count": 6, |
178 | 178 | "metadata": {}, |
179 | 179 | "output_type": "execute_result" |
180 | 180 | }, |
|
195 | 195 | }, |
196 | 196 | { |
197 | 197 | "cell_type": "code", |
198 | | - "execution_count": 6, |
| 198 | + "execution_count": null, |
199 | 199 | "id": "2749c664", |
200 | 200 | "metadata": {}, |
201 | 201 | "outputs": [ |
|
219 | 219 | }, |
220 | 220 | { |
221 | 221 | "cell_type": "code", |
222 | | - "execution_count": 7, |
| 222 | + "execution_count": null, |
223 | 223 | "id": "1cca2392", |
224 | 224 | "metadata": {}, |
225 | 225 | "outputs": [ |
|
241 | 241 | }, |
242 | 242 | { |
243 | 243 | "cell_type": "code", |
244 | | - "execution_count": 8, |
| 244 | + "execution_count": null, |
245 | 245 | "id": "2ad6d7e5", |
246 | 246 | "metadata": {}, |
247 | 247 | "outputs": [ |
|
273 | 273 | }, |
274 | 274 | { |
275 | 275 | "cell_type": "code", |
276 | | - "execution_count": 9, |
| 276 | + "execution_count": 5, |
277 | 277 | "id": "b6c4ea8c", |
278 | 278 | "metadata": {}, |
279 | 279 | "outputs": [ |
|
297 | 297 | ], |
298 | 298 | "source": [ |
299 | 299 | "from khisto.matplotlib import hist\n", |
| 300 | + "from khisto.matplotlib.hist import _hist\n", |
300 | 301 | "\n", |
301 | 302 | "# Basic histogram plot\n", |
302 | 303 | "fig, ax = plt.subplots(figsize=(8, 5))\n", |
|
311 | 312 | }, |
312 | 313 | { |
313 | 314 | "cell_type": "code", |
314 | | - "execution_count": 12, |
| 315 | + "execution_count": 6, |
315 | 316 | "id": "09479225", |
316 | 317 | "metadata": {}, |
317 | 318 | "outputs": [ |
|
339 | 340 | }, |
340 | 341 | { |
341 | 342 | "cell_type": "code", |
342 | | - "execution_count": 16, |
| 343 | + "execution_count": 8, |
343 | 344 | "id": "6c89bf07", |
344 | 345 | "metadata": {}, |
345 | 346 | "outputs": [ |
|
366 | 367 | }, |
367 | 368 | { |
368 | 369 | "cell_type": "code", |
369 | | - "execution_count": 17, |
| 370 | + "execution_count": 12, |
370 | 371 | "id": "25d8d0e5", |
371 | 372 | "metadata": {}, |
372 | 373 | "outputs": [ |
|
403 | 404 | }, |
404 | 405 | { |
405 | 406 | "cell_type": "code", |
406 | | - "execution_count": 18, |
| 407 | + "execution_count": 15, |
407 | 408 | "id": "d985437b", |
408 | 409 | "metadata": {}, |
409 | 410 | "outputs": [ |
|
487 | 488 | }, |
488 | 489 | { |
489 | 490 | "cell_type": "code", |
490 | | - "execution_count": 19, |
| 491 | + "execution_count": 18, |
491 | 492 | "id": "51179a02", |
492 | 493 | "metadata": {}, |
493 | 494 | "outputs": [ |
|
521 | 522 | }, |
522 | 523 | { |
523 | 524 | "cell_type": "code", |
524 | | - "execution_count": 20, |
| 525 | + "execution_count": 21, |
525 | 526 | "id": "e9bbabc9", |
526 | 527 | "metadata": {}, |
527 | 528 | "outputs": [ |
|
558 | 559 | }, |
559 | 560 | { |
560 | 561 | "cell_type": "code", |
561 | | - "execution_count": 21, |
| 562 | + "execution_count": 22, |
562 | 563 | "id": "1190f8aa", |
563 | 564 | "metadata": {}, |
564 | 565 | "outputs": [ |
|
594 | 595 | }, |
595 | 596 | { |
596 | 597 | "cell_type": "code", |
597 | | - "execution_count": 22, |
| 598 | + "execution_count": 23, |
598 | 599 | "id": "bf2ba150", |
599 | 600 | "metadata": {}, |
600 | 601 | "outputs": [ |
|
0 commit comments