From 7014328209b40dc6ea0c472e9024aa5666b8a59d Mon Sep 17 00:00:00 2001 From: Jakub Novak Date: Sat, 12 Oct 2024 07:38:45 +0200 Subject: [PATCH] Filter out grid lines --- js/package.json | 2 +- python/pyproject.toml | 2 +- template/startup_scripts/0002_data.py | 34 ++++++++++++++------------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/js/package.json b/js/package.json index 16e0e7c..920794d 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "@e2b/code-interpreter", - "version": "0.0.9-beta.67", + "version": "0.0.9-beta.68", "description": "E2B Code Interpreter - Stateful code execution", "homepage": "https://e2b.dev", "license": "MIT", diff --git a/python/pyproject.toml b/python/pyproject.toml index 50c3781..4fe59ef 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "e2b-code-interpreter" -version = "0.0.11b42" +version = "0.0.11b43" description = "E2B Code Interpreter - Stateful code execution" authors = ["e2b "] license = "Apache-2.0" diff --git a/template/startup_scripts/0002_data.py b/template/startup_scripts/0002_data.py index 4b8a77f..a087964 100644 --- a/template/startup_scripts/0002_data.py +++ b/template/startup_scripts/0002_data.py @@ -1,7 +1,6 @@ from datetime import date import enum import re -from dateutil import parser from typing import Optional, List, Tuple, Literal, Any, Union, Sequence import matplotlib @@ -21,6 +20,21 @@ from traitlets.traitlets import Unicode, ObjectName +def _is_grid_line(line: Line2D) -> bool: + x_data = line.get_xdata() + if len(x_data) != 2: + return False + + y_data = line.get_ydata() + if len(y_data) != 2: + return False + + if x_data[0] == x_data[1] or y_data[0] == y_data[1]: + return True + + return False + + class GraphType(str, enum.Enum): LINE = "line" SCATTER = "scatter" @@ -187,6 +201,8 @@ def _extract_info(self, ax: Axes) -> None: super()._extract_info(ax) for line in ax.get_lines(): + if _is_grid_line(line): + continue label = line.get_label() if label.startswith("_child"): number = int(label[6:]) @@ -377,23 +393,9 @@ def _get_type_of_graph(ax: Axes) -> GraphType: if all(isinstance(box_or_path, (PathPatch, Line2D)) for box_or_path in objects): return GraphType.BOX_AND_WHISKER - def is_grid_line(line: Line2D) -> bool: - x_data = line.get_xdata() - if len(x_data) != 2: - return False - - y_data = line.get_ydata() - if len(y_data) != 2: - return False - - if x_data[0] == x_data[1] or y_data[0] == y_data[1]: - return True - - return False - filtered = [] for obj in objects: - if isinstance(obj, Line2D) and is_grid_line(obj): + if isinstance(obj, Line2D) and _is_grid_line(obj): continue filtered.append(obj)