Skip to content

Commit 1661f17

Browse files
committed
further improvements
1 parent 9b2116f commit 1661f17

File tree

2 files changed

+13
-37
lines changed

2 files changed

+13
-37
lines changed

darts/timeseries.py

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
from darts.utils.formatting import (
6868
format_bytes,
6969
format_dict,
70-
format_list,
7170
make_collapsible_section,
7271
make_paragraph,
7372
)
@@ -5483,7 +5482,6 @@ def __str__(self):
54835482
)
54845483

54855484
freq_str = self._freq_str if self._freq_str is not None else str(self.freq)
5486-
time_index_name = self._time_index.name or "timesteps"
54875485

54885486
# indentation, first line needs to be manual
54895487
if self.static_covariates is not None:
@@ -5493,13 +5491,12 @@ def __str__(self):
54935491
static_cov_str = " <empty>"
54945492

54955493
return (
5496-
f"<TimeSeries shape({time_index_name}: {self.n_timesteps}, "
5494+
f"{values_str}\n\n"
5495+
f"Shape: (times: {self.n_timesteps}, "
54975496
f"components: {self.n_components}, "
5498-
f"samples: {self.n_samples})> \n"
5497+
f"samples: {self.n_samples}) \n"
5498+
f"Time frame: ({self._time_index.min()}, {self._time_index.max()}, {freq_str})\n"
54995499
f"Size: {format_bytes(self._values.nbytes)}\n\n"
5500-
f"{values_str}\n\n"
5501-
f"Time frame:\n ({self._time_index.min()}, {self._time_index.max()}, {freq_str})\n\n"
5502-
f"Components:\n {format_list(list(self.components))}\n\n"
55035500
f"Static covariates:\n{static_cov_str}\n\n"
55045501
f"Hierarchy:\n{format_dict(self.hierarchy)}\n"
55055502
f"Metadata:\n{format_dict(self.metadata)}\n"
@@ -5514,41 +5511,20 @@ def _repr_html_(self):
55145511
if self.n_samples == 1
55155512
else f"(displaying median of samples):\n{self.median().to_dataframe().to_html(max_rows=10, max_cols=15)}"
55165513
)
5517-
dataframe_html = make_paragraph(
5518-
values_str, bold=True, size="1.2em", margin_left="0"
5519-
)
5520-
5521-
time_index_name = self._time_index.name or "timesteps"
55225514
freq_str = self._freq_str if self._freq_str is not None else str(self.freq)
55235515

5524-
shape_info_content = (
5525-
f"({time_index_name}: {self.n_timesteps}, "
5526-
f"components: {self.n_components}, "
5527-
f"samples: {self.n_samples}) <br>\n"
5528-
f"Size: {format_bytes(self._values.nbytes)}\n"
5529-
)
5530-
shape_info_html = make_paragraph(
5531-
shape_info_content, bold=True, size="1.0em", margin_left="0"
5532-
)
5533-
5534-
# container div for top section with 2 columns
5535-
top_section_html = f"""
5536-
<div style="display: flex; align-items: center; gap: 2em; margin-left: 0.5em;">
5537-
<div>{dataframe_html}</div>
5538-
<div>{shape_info_html}</div>
5539-
</div>
5540-
"""
5541-
55425516
static_covs_empty = self.static_covariates is None
55435517
hierarchy_empty = self.hierarchy is None or len(self.hierarchy) == 0
55445518
metadata_empty = self.metadata is None or len(self.metadata) == 0
55455519

55465520
return (
5547-
top_section_html
5548-
+ make_collapsible_section(
5549-
"Details:",
5550-
f"Time frame: ({self._time_index.min()}, {self._time_index.max()}, {freq_str})\n"
5551-
f"Components: {format_list(list(self.components), render_html=True, max_items=10)}",
5521+
make_paragraph(values_str, bold=True, size="1.2em", margin_left="0")
5522+
+ make_paragraph(
5523+
f"Shape: (times: {self.n_timesteps}, "
5524+
f"components: {self.n_components}, "
5525+
f"samples: {self.n_samples})<br>"
5526+
f"Time frame: ({self._time_index.min()}, {self._time_index.max()}, {freq_str})<br>"
5527+
f"Size: {format_bytes(self._values.nbytes)}"
55525528
)
55535529
+ make_collapsible_section(
55545530
"Static covariates:",

darts/utils/formatting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def make_collapsible_section(
7979
return f"""
8080
<details{open_tag}>
8181
<summary style="font-size: 1.2em;">{title}</summary>
82-
<pre style="margin-left: 0.5em;">{content}</pre>
82+
<pre style="margin-left: 0.5em; font-family: inherit;">{content}</pre>
8383
</details>
8484
"""
8585

@@ -91,5 +91,5 @@ def make_paragraph(
9191
if bold:
9292
text = f"<strong>{text}</strong>"
9393
# Use margin_left parameter in the style
94-
style = f"margin-left: {margin_left}; font-size: {size}; text-align: center;"
94+
style = f"margin-left: {margin_left}; font-size: {size}; text-align: left;"
9595
return f"<p style='{style}'>{text}</p>"

0 commit comments

Comments
 (0)