Skip to content

Commit

Permalink
feat(sdk): fix test_chart notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
dvalleri committed Dec 11, 2024
1 parent 9a817bd commit f3082bf
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions sdk/tests/chart/test_chart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -124,28 +124,31 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"id": "09407640-2a3d-45db-841d-1d21e63ef6a0",
"metadata": {},
"outputs": [
{
"ename": "AssertionError",
"evalue": "axis_label count and matrix item count are not compatibile",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[1], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mradicalbit_platform_sdk\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mcharts\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m ConfusionMatrixChartData, Chart\n\u001b[0;32m----> 3\u001b[0m \u001b[43mChart\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mconfusion_matrix_chart\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdata\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mConfusionMatrixChartData\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 4\u001b[0m \u001b[43m \u001b[49m\u001b[43maxis_label\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m0\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m1\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5\u001b[0m \u001b[43m \u001b[49m\u001b[43mmatrix\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m4\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m131\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m3\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m115\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m4\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m102\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m3\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 6\u001b[0m \u001b[43m \u001b[49m\u001b[43mcolor\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m#FFFFFF\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m#3695d9\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m~/radicalbit/radicalbit-ai-monitoring/sdk/radicalbit_platform_sdk/charts/chart.py:110\u001b[0m, in \u001b[0;36mChart.confusion_matrix_chart\u001b[0;34m(self, data)\u001b[0m\n\u001b[1;32m 109\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mconfusion_matrix_chart\u001b[39m(\u001b[38;5;28mself\u001b[39m, data: ConfusionMatrixChartData) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m EChartsRawWidget:\n\u001b[0;32m--> 110\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(data\u001b[38;5;241m.\u001b[39mmatrix) \u001b[38;5;241m==\u001b[39m \u001b[38;5;28mlen\u001b[39m(data\u001b[38;5;241m.\u001b[39maxis_label) \u001b[38;5;241m*\u001b[39m \u001b[38;5;28mlen\u001b[39m(data\u001b[38;5;241m.\u001b[39maxis_label) , \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124maxis_label count and matrix item count are not compatibile\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 112\u001b[0m np_matrix \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39mmatrix(data\u001b[38;5;241m.\u001b[39mmatrix)\n\u001b[1;32m 114\u001b[0m options \u001b[38;5;241m=\u001b[39m {\n\u001b[1;32m 115\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124myAxis\u001b[39m\u001b[38;5;124m\"\u001b[39m: {\n\u001b[1;32m 116\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtype\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcategory\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 190\u001b[0m }\n\u001b[1;32m 191\u001b[0m }\n",
"\u001b[0;31mAssertionError\u001b[0m: axis_label count and matrix item count are not compatibile"
]
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "9ee56331ee4a4c268ff1bdf3276f1f0f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"EChartsRawWidget(option={'yAxis': {'type': 'category', 'axisTick': {'show': False}, 'axisLine': {'show': False…"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from radicalbit_platform_sdk.charts import ConfusionMatrixChartData, Chart\n",
"\n",
"Chart().confusion_matrix_chart(data=ConfusionMatrixChartData(\n",
" axis_label=[\"0\",\"1\"],\n",
" axis_label=[\"0\",\"1\",\"2\"],\n",
" matrix=[[0,0,2],[1,0,4],[2,0,131],[0,1,3],[1,1,115],[2,1,4],[0,2,102],[1,2,3],[2,2,0]],\n",
" color=['#FFFFFF','#3695d9']))"
]
Expand Down

0 comments on commit f3082bf

Please sign in to comment.