Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dcaffa9

Browse filesBrowse files
committed
repr updates
1 parent 6221f0f commit dcaffa9
Copy full SHA for dcaffa9

File tree

Expand file treeCollapse file tree

2 files changed

+11
-13
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-13
lines changed

‎fastplotlib/graphics/_base.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/_base.py
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,8 @@ def update_data(self, data: Any):
6363
pass
6464

6565
def __repr__(self):
66-
title = "Fastplotlib " + self.__class__.__name__ + "\n"
6766
if self.name is not None:
68-
graph_name = "Name: " + self.name + "\n"
67+
return f"'{self.name}' fastplotlib.{self.__class__.__name__} @ {hex(id(self))}"
6968
else:
70-
graph_name = "Name: None\n"
71-
location = "Location: " + hex(id(self)) + "\n"
72-
return title + graph_name + location
69+
return f"fastplotlib.{self.__class__.__name__} @ {hex(id(self))}"
7370

‎fastplotlib/subplot.py

Copy file name to clipboardExpand all lines: fastplotlib/subplot.py
+9-8Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from wgpu.gui.auto import WgpuCanvas
66
from warnings import warn
77
from math import copysign
8+
from textwrap import indent
89

910

1011
class Subplot:
@@ -172,13 +173,13 @@ def __getitem__(self, name: str):
172173
raise IndexError(f"no graphic of given name, the current graphics are:\n {graphic_names}")
173174

174175
def __repr__(self):
175-
title = "Fastplotlib " + self.__class__.__name__ + "\n"
176+
newline = "\n "
176177
if self.name is not None:
177-
name = "Name: " + self.name + "\n"
178+
return f"'{self.name}' fastplotlib.{self.__class__.__name__} @ {hex(id(self))}\n" \
179+
f"Graphics: \n " \
180+
f"{newline.join(graphic.__repr__() for graphic in self.get_graphics())}"
178181
else:
179-
name = "Name: None\n"
180-
graphics = "Graphics:\n------------------------\n"
181-
for graphic in self.get_graphics():
182-
graphics += graphic.__repr__()
183-
graphics += "------------------------\n"
184-
return title + name + graphics
182+
return f"fastplotlib.{self.__class__.__name__} @ {hex(id(self))} \n" \
183+
f"Graphics: \n " \
184+
f"{newline.join(graphic.__repr__() for graphic in self.get_graphics())}"
185+

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.