Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: polars implementation of table #744

Merged
merged 40 commits into from
May 9, 2024
Merged
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
04629ab
refactor: make fields internal
lars-reimann May 7, 2024
2835bd4
test: store polars benchmark in polars table
lars-reimann May 7, 2024
5cd1229
style: add comma
lars-reimann May 7, 2024
9844d65
feat: implement some table operations
lars-reimann May 8, 2024
d4023ff
docs: minor changes
lars-reimann May 8, 2024
61e361f
feat: summarize_statistics
lars-reimann May 8, 2024
e7eeb86
feat: tabular dataset backed by polars
lars-reimann May 8, 2024
7b6cd5d
refactor: get polars `IntoExpr` for any cell implementation
lars-reimann May 8, 2024
f9c6264
feat: lazy `transform_column`
lars-reimann May 8, 2024
f9bcba0
feat: handle new data structures in models
lars-reimann May 8, 2024
a612198
feat: experimental table transformers (just buggy copies)
lars-reimann May 8, 2024
d53fd09
feat: `ExperimentalTable.transform` and `ExperimentalTable.inverse_tr…
lars-reimann May 8, 2024
e4dcd9d
refactor: move invertible transformer to own file
lars-reimann May 8, 2024
3ea43f2
refactor: data frame field as lazy property
lars-reimann May 8, 2024
f8b1f84
refactor: bring back `ExperimentalTable.remove_columns_except`
lars-reimann May 8, 2024
b8b975b
fix: errors in transformers
lars-reimann May 8, 2024
6e3843a
ci: ruff config in MegaLinter?
lars-reimann May 8, 2024
27f8495
feat: use ASCII to format tables
lars-reimann May 8, 2024
3eefe18
feat: `remove_rows_with_outliers`
lars-reimann May 8, 2024
ae3ac76
feat: column plots
lars-reimann May 8, 2024
1ba620e
perf: faster lag plot
lars-reimann May 8, 2024
7a7037c
refactor: extract conversion of figure to image
lars-reimann May 8, 2024
4c79e6e
feat: finish column plotter
lars-reimann May 8, 2024
8b65aea
feat: named cell operations
lars-reimann May 9, 2024
31f9c11
feat: floor & ceil
lars-reimann May 9, 2024
dcd4c61
docs: document table operations
lars-reimann May 9, 2024
e7315c2
perf: lazy `replace_column`
lars-reimann May 9, 2024
1eaec6a
test: benchmark for remove_rows_with_outliers
lars-reimann May 9, 2024
69cda9d
docs: more documentation for table operations
lars-reimann May 9, 2024
caf1745
docs: more documentation for table operations
lars-reimann May 9, 2024
973db7f
docs: remainder of table
lars-reimann May 9, 2024
8971dd3
feat: scatter and line plot
lars-reimann May 9, 2024
5a15186
feat: histograms
lars-reimann May 9, 2024
565778d
feat: remaining table plots
lars-reimann May 9, 2024
76136f5
fix: import errors
lars-reimann May 9, 2024
3640b3b
build: update deps
lars-reimann May 9, 2024
cc2e094
ci: undo setting ruff config
lars-reimann May 9, 2024
f5a6238
style: apply automated linter fixes
megalinter-bot May 9, 2024
fb7ed01
fix: models not working with new containers
lars-reimann May 9, 2024
bf09f2c
style: apply automated linter fixes
megalinter-bot May 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: extract conversion of figure to image
lars-reimann committed May 8, 2024
commit 7a7037cce53479904a5105a6602e14722d2128d0
6 changes: 6 additions & 0 deletions src/safeds/_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -7,16 +7,22 @@
if TYPE_CHECKING:
from ._file_io import _check_and_normalize_file_path
from ._hashing import _structural_hash
from ._plotting import _figure_to_image
from ._random import _get_random_seed

apipkg.initpkg(
__name__,
{
"_check_and_normalize_file_path": "._file_io:_check_and_normalize_file_path",
"_structural_hash": "._hashing:_structural_hash",
"_figure_to_image": "._plotting:_figure_to_image",
"_get_random_seed": "._random:_get_random_seed",
},
)

__all__ = [
"_check_and_normalize_file_path",
"_structural_hash",
"_figure_to_image",
"_get_random_seed",
]
32 changes: 32 additions & 0 deletions src/safeds/_utils/_plotting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from __future__ import annotations

import io
from typing import TYPE_CHECKING

from safeds.data.image.containers import Image

if TYPE_CHECKING:
import matplotlib.pyplot as plt


def _figure_to_image(figure: plt.Figure) -> Image:
"""
Store the figure as an image and closes it.

Parameters
----------
figure:
The figure to store.

Returns
-------
image:
The figure as an image.
"""
import matplotlib.pyplot as plt

buffer = io.BytesIO()
figure.savefig(buffer, format="png")
plt.close(figure) # Prevents the figure from being displayed directly
buffer.seek(0)
return Image.from_bytes(buffer.read())
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import io
from typing import TYPE_CHECKING

from safeds._utils import _figure_to_image
from safeds.data.image.containers import Image
from safeds.exceptions import NonNumericColumnError

@@ -116,8 +117,4 @@ def lag_plot(self, lag: int) -> Image:
ylabel=f"y(t + {lag})",
)

buffer = io.BytesIO()
fig.savefig(buffer, format="png")
plt.close() # Prevents the figure from being displayed directly
buffer.seek(0)
return Image.from_bytes(buffer.read())
return _figure_to_image(fig)