Skip to content

Commit

Permalink
Filter out grid lines
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubno committed Oct 12, 2024
1 parent 77efab2 commit 7014328
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <hello@e2b.dev>"]
license = "Apache-2.0"
Expand Down
34 changes: 18 additions & 16 deletions template/startup_scripts/0002_data.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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:])
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 7014328

Please sign in to comment.