From e75b83b306c43a06b021b9f76c7fade8a2d2e990 Mon Sep 17 00:00:00 2001 From: Dhruv N Date: Fri, 21 Feb 2025 22:47:26 +0530 Subject: [PATCH] Return labels instead of colors Returning the labels insead of the colors when using .data_as_X_y. Its more usefull imo. --- drawdata/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drawdata/__init__.py b/drawdata/__init__.py index 700ae14..fd17529 100644 --- a/drawdata/__init__.py +++ b/drawdata/__init__.py @@ -47,16 +47,16 @@ def data_as_polars(self): def data_as_X_y(self): import numpy as np - colors = [_['color'] for _ in self.data] + labels = [_['label'] for _ in self.data] # Updated to use 'label' instead of 'color' # Assume that we're dealing with regression in this case - if np.unique(colors).shape[0] == 1: + if np.unique(labels).shape[0] == 1: X = np.array([[_['x']] for _ in self.data]) y = np.array([_['y'] for _ in self.data]) return X, y X = np.array([[_['x'], _['y']] for _ in self.data]) - return X, colors + return X, labels class BarWidget(anywidget.AnyWidget):