From 462ec46240c25f47946f153866b518b6857f73f3 Mon Sep 17 00:00:00 2001 From: Lars Reimann Date: Sat, 22 Apr 2023 19:17:20 +0200 Subject: [PATCH] feat: compatibility with `safe-ds` v0.11.0 (#53) ### Summary of Changes Integrate API changes of [safe-ds v0.11.0](https://github.com/Safe-DS/Stdlib/releases/tag/v0.11.0). --- docs/examples/house_sales.ipynb | 4 +- docs/examples/titanic.ipynb | 4 +- poetry.lock | 107 +++++++++++++++++- pyproject.toml | 2 +- .../tabular/containers/_example_table.py | 6 +- .../tabular/_house_sales/test_house_sales.py | 4 +- .../tabular/_titanic/test_titanic.py | 4 +- 7 files changed, 115 insertions(+), 16 deletions(-) diff --git a/docs/examples/house_sales.ipynb b/docs/examples/house_sales.ipynb index 6adbfd6..da16887 100644 --- a/docs/examples/house_sales.ipynb +++ b/docs/examples/house_sales.ipynb @@ -74,7 +74,7 @@ "execution_count": null, "outputs": [], "source": [ - "house_sales.schema" + "print(str(house_sales.schema))" ], "metadata": { "collapsed": false @@ -123,7 +123,7 @@ " \"latitude\",\n", " \"longitude\"\n", "])\n", - "house_sales_correlation.correlation_heatmap()" + "house_sales_correlation.plot_correlation_heatmap()" ], "metadata": { "collapsed": false diff --git a/docs/examples/titanic.ipynb b/docs/examples/titanic.ipynb index 280ee96..d61829d 100644 --- a/docs/examples/titanic.ipynb +++ b/docs/examples/titanic.ipynb @@ -74,7 +74,7 @@ "execution_count": null, "outputs": [], "source": [ - "titanic.schema" + "print(str(titanic.schema))" ], "metadata": { "collapsed": false @@ -122,7 +122,7 @@ " \"fare\",\n", " \"survived\"\n", "])\n", - "titanic_correlation.correlation_heatmap()" + "titanic_correlation.plot_correlation_heatmap()" ], "metadata": { "collapsed": false diff --git a/poetry.lock b/poetry.lock index 5786293..c78f355 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2185,6 +2185,42 @@ files = [ dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] +[[package]] +name = "polars" +version = "0.17.6" +description = "Blazingly fast DataFrame library" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "polars-0.17.6-cp37-abi3-macosx_10_7_x86_64.whl", hash = "sha256:03801d9ad4aa1a813d39baa9437683356e29c90f0a2f1d18b17672d28f805313"}, + {file = "polars-0.17.6-cp37-abi3-macosx_11_0_arm64.whl", hash = "sha256:6a4a06fd046cad93b16129a092d1bc55408f2025acf07e5a8f8aceb82657285f"}, + {file = "polars-0.17.6-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:323e9c018d639d489454e06174918ec4c3e4a5b9292058432fd3d3370cef919d"}, + {file = "polars-0.17.6-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1e0c33f1d6ec25fea203ff9091a2cae7d1ad231dedb6b9b22cb52b2799ea6456"}, + {file = "polars-0.17.6-cp37-abi3-win_amd64.whl", hash = "sha256:9136edf4c5463c188e9e84406d3c9821a0b5d4252097e1c3ab0d61df4f3257de"}, + {file = "polars-0.17.6.tar.gz", hash = "sha256:b5b9ab9b894bce257744f314985c4a211dd6e6ae1afdd93a909a5108eb6b4054"}, +] + +[package.dependencies] +pandas = {version = "*", optional = true, markers = "extra == \"pandas\""} +pyarrow = {version = ">=7.0.0", optional = true, markers = "extra == \"pyarrow\" or extra == \"pandas\""} +typing_extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} +xlsx2csv = {version = ">=0.8.0", optional = true, markers = "extra == \"xlsx2csv\""} + +[package.extras] +all = ["polars[connectorx,deltalake,fsspec,matplotlib,numpy,pandas,pyarrow,sqlalchemy,timezone,xlsx2csv,xlsxwriter]"] +connectorx = ["connectorx"] +deltalake = ["deltalake (>=0.8.0)"] +fsspec = ["fsspec"] +matplotlib = ["matplotlib"] +numpy = ["numpy (>=1.16.0)"] +pandas = ["pandas", "pyarrow (>=7.0.0)"] +pyarrow = ["pyarrow (>=7.0.0)"] +sqlalchemy = ["pandas", "sqlalchemy"] +timezone = ["backports.zoneinfo", "tzdata"] +xlsx2csv = ["xlsx2csv (>=0.8.0)"] +xlsxwriter = ["xlsxwriter"] + [[package]] name = "prometheus-client" version = "0.16.0" @@ -2269,6 +2305,44 @@ files = [ [package.extras] tests = ["pytest"] +[[package]] +name = "pyarrow" +version = "11.0.0" +description = "Python library for Apache Arrow" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pyarrow-11.0.0-cp310-cp310-macosx_10_14_x86_64.whl", hash = "sha256:40bb42afa1053c35c749befbe72f6429b7b5f45710e85059cdd534553ebcf4f2"}, + {file = "pyarrow-11.0.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:7c28b5f248e08dea3b3e0c828b91945f431f4202f1a9fe84d1012a761324e1ba"}, + {file = "pyarrow-11.0.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a37bc81f6c9435da3c9c1e767324ac3064ffbe110c4e460660c43e144be4ed85"}, + {file = "pyarrow-11.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ad7c53def8dbbc810282ad308cc46a523ec81e653e60a91c609c2233ae407689"}, + {file = "pyarrow-11.0.0-cp310-cp310-win_amd64.whl", hash = "sha256:25aa11c443b934078bfd60ed63e4e2d42461682b5ac10f67275ea21e60e6042c"}, + {file = "pyarrow-11.0.0-cp311-cp311-macosx_10_14_x86_64.whl", hash = "sha256:e217d001e6389b20a6759392a5ec49d670757af80101ee6b5f2c8ff0172e02ca"}, + {file = "pyarrow-11.0.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ad42bb24fc44c48f74f0d8c72a9af16ba9a01a2ccda5739a517aa860fa7e3d56"}, + {file = "pyarrow-11.0.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2d942c690ff24a08b07cb3df818f542a90e4d359381fbff71b8f2aea5bf58841"}, + {file = "pyarrow-11.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f010ce497ca1b0f17a8243df3048055c0d18dcadbcc70895d5baf8921f753de5"}, + {file = "pyarrow-11.0.0-cp311-cp311-win_amd64.whl", hash = "sha256:2f51dc7ca940fdf17893227edb46b6784d37522ce08d21afc56466898cb213b2"}, + {file = "pyarrow-11.0.0-cp37-cp37m-macosx_10_14_x86_64.whl", hash = "sha256:1cbcfcbb0e74b4d94f0b7dde447b835a01bc1d16510edb8bb7d6224b9bf5bafc"}, + {file = "pyarrow-11.0.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:aaee8f79d2a120bf3e032d6d64ad20b3af6f56241b0ffc38d201aebfee879d00"}, + {file = "pyarrow-11.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:410624da0708c37e6a27eba321a72f29d277091c8f8d23f72c92bada4092eb5e"}, + {file = "pyarrow-11.0.0-cp37-cp37m-win_amd64.whl", hash = "sha256:2d53ba72917fdb71e3584ffc23ee4fcc487218f8ff29dd6df3a34c5c48fe8c06"}, + {file = "pyarrow-11.0.0-cp38-cp38-macosx_10_14_x86_64.whl", hash = "sha256:f12932e5a6feb5c58192209af1d2607d488cb1d404fbc038ac12ada60327fa34"}, + {file = "pyarrow-11.0.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:41a1451dd895c0b2964b83d91019e46f15b5564c7ecd5dcb812dadd3f05acc97"}, + {file = "pyarrow-11.0.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:becc2344be80e5dce4e1b80b7c650d2fc2061b9eb339045035a1baa34d5b8f1c"}, + {file = "pyarrow-11.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8f40be0d7381112a398b93c45a7e69f60261e7b0269cc324e9f739ce272f4f70"}, + {file = "pyarrow-11.0.0-cp38-cp38-win_amd64.whl", hash = "sha256:362a7c881b32dc6b0eccf83411a97acba2774c10edcec715ccaab5ebf3bb0835"}, + {file = "pyarrow-11.0.0-cp39-cp39-macosx_10_14_x86_64.whl", hash = "sha256:ccbf29a0dadfcdd97632b4f7cca20a966bb552853ba254e874c66934931b9841"}, + {file = "pyarrow-11.0.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3e99be85973592051e46412accea31828da324531a060bd4585046a74ba45854"}, + {file = "pyarrow-11.0.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69309be84dcc36422574d19c7d3a30a7ea43804f12552356d1ab2a82a713c418"}, + {file = "pyarrow-11.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:da93340fbf6f4e2a62815064383605b7ffa3e9eeb320ec839995b1660d69f89b"}, + {file = "pyarrow-11.0.0-cp39-cp39-win_amd64.whl", hash = "sha256:caad867121f182d0d3e1a0d36f197df604655d0b466f1bc9bafa903aa95083e4"}, + {file = "pyarrow-11.0.0.tar.gz", hash = "sha256:5461c57dbdb211a632a48facb9b39bbeb8a7905ec95d768078525283caef5f6d"}, +] + +[package.dependencies] +numpy = ">=1.16.6" + [[package]] name = "pycparser" version = "2.21" @@ -2835,14 +2909,14 @@ files = [ [[package]] name = "safe-ds" -version = "0.10.0" +version = "0.11.0" description = "A user-friendly library for Data Science in Python." category = "main" optional = false python-versions = ">=3.10,<4.0" files = [ - {file = "safe_ds-0.10.0-py3-none-any.whl", hash = "sha256:daf7b9b0af1f8472c44191365939acbd118310fbcda447bcf346650f96e82a2e"}, - {file = "safe_ds-0.10.0.tar.gz", hash = "sha256:e83acd6c7923eddf32af4d95a4ce888cc994587b8bd2f7611971bdcc846a01b6"}, + {file = "safe_ds-0.11.0-py3-none-any.whl", hash = "sha256:ddb44b21629285b4c94f5ad30b019b0201359b88a8893e453faa829e2f698559"}, + {file = "safe_ds-0.11.0.tar.gz", hash = "sha256:2f3508a1cc8becec2b85509ea371347e7637500cab38a540b9eba1b3625d5bef"}, ] [package.dependencies] @@ -2850,6 +2924,7 @@ ipython = ">=8.8.0,<9.0.0" matplotlib = ">=3.6.3,<4.0.0" pandas = ">=2.0.0,<3.0.0" pillow = ">=9.5.0,<10.0.0" +polars = {version = ">=0.17.5,<0.18.0", extras = ["pandas", "pyarrow", "xlsx2csv"]} scikit-learn = ">=1.2.0,<2.0.0" seaborn = ">=0.12.2,<0.13.0" @@ -3143,6 +3218,18 @@ files = [ docs = ["myst-parser", "pydata-sphinx-theme", "sphinx"] test = ["argcomplete (>=2.0)", "pre-commit", "pytest", "pytest-mock"] +[[package]] +name = "typing-extensions" +version = "4.5.0" +description = "Backported and Experimental Type Hints for Python 3.7+" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "typing_extensions-4.5.0-py3-none-any.whl", hash = "sha256:fb33085c39dd998ac16d1431ebc293a8b3eedd00fd4a32de0ff79002c19511b4"}, + {file = "typing_extensions-4.5.0.tar.gz", hash = "sha256:5cb5f4a79139d699607b3ef622a1dedafa84e115ab0024e0d9c044a9479ca7cb"}, +] + [[package]] name = "tzdata" version = "2023.3" @@ -3293,7 +3380,19 @@ files = [ {file = "widgetsnbextension-4.0.5.tar.gz", hash = "sha256:003f716d930d385be3fd9de42dd9bf008e30053f73bddde235d14fbeaeff19af"}, ] +[[package]] +name = "xlsx2csv" +version = "0.8.1" +description = "xlsx to csv converter" +category = "main" +optional = false +python-versions = "*" +files = [ + {file = "xlsx2csv-0.8.1-py3-none-any.whl", hash = "sha256:6c36c0295d64f231570479e514d6163ce135af3c431a1705b073230bedaef9f2"}, + {file = "xlsx2csv-0.8.1.tar.gz", hash = "sha256:7ecd6d2bc2426f2e432f4fdac12211e1976d3cbb65f9033e1eda65edda2045e3"}, +] + [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "c1fb503758e1574e49ddbd970fb837e0d5580018fdc78d821eb12966753b6740" +content-hash = "30d70380790c4fc3a9e76279a7a787298fff6df47d6abaf1ae4b97ca24bdc67c" diff --git a/pyproject.toml b/pyproject.toml index dd14bc8..ae25e2d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ packages = [ [tool.poetry.dependencies] python = "^3.10" -safe-ds = ">=0.10,<0.11" +safe-ds = ">=0.11,<0.12" [tool.poetry.group.dev.dependencies] pytest = "^7.2.1" diff --git a/src/safeds_examples/tabular/containers/_example_table.py b/src/safeds_examples/tabular/containers/_example_table.py index 5ede696..4af9600 100644 --- a/src/safeds_examples/tabular/containers/_example_table.py +++ b/src/safeds_examples/tabular/containers/_example_table.py @@ -21,7 +21,7 @@ class ExampleTable(Table): def __init__(self, table: Table, column_descriptions: dict[str, str]) -> None: # Check that all column names in `descriptions` exist in `table` - invalid_column_names = set(column_descriptions.keys()) - set(table.get_column_names()) + invalid_column_names = set(column_descriptions.keys()) - set(table.column_names) if invalid_column_names: raise UnknownColumnNameError(list(invalid_column_names)) @@ -38,7 +38,7 @@ def column_descriptions(self) -> Table: return Table( [ {"Name": column_name, "Description": self.get_column_description(column_name)} - for column_name in self.get_column_names() + for column_name in self.column_names ], ) @@ -61,7 +61,7 @@ def get_column_description(self, column_name: str) -> str: UnknownColumnNameError If no column with the given name exists. """ - if column_name not in self.get_column_names(): + if column_name not in self.column_names: raise UnknownColumnNameError([column_name]) return self._descriptions.get(column_name, "") diff --git a/tests/safeds_examples/tabular/_house_sales/test_house_sales.py b/tests/safeds_examples/tabular/_house_sales/test_house_sales.py index 7827a0d..0e542cd 100644 --- a/tests/safeds_examples/tabular/_house_sales/test_house_sales.py +++ b/tests/safeds_examples/tabular/_house_sales/test_house_sales.py @@ -16,7 +16,7 @@ def test_returns_table(self) -> None: assert isinstance(house_sales, Table) def test_row_count(self, house_sales: Table) -> None: - assert house_sales.count_rows() == 21613 + assert house_sales.n_rows == 21613 def test_schema(self, house_sales: Table) -> None: assert house_sales.schema == Schema( @@ -58,4 +58,4 @@ def test_all_columns_have_descriptions(self) -> None: house_sales = load_house_sales() descriptions = house_sales.column_descriptions - assert set(descriptions.get_column("Name")._data) == set(house_sales.get_column_names()) + assert set(descriptions.get_column("Name")._data) == set(house_sales.column_names) diff --git a/tests/safeds_examples/tabular/_titanic/test_titanic.py b/tests/safeds_examples/tabular/_titanic/test_titanic.py index 249c16a..ad5f694 100644 --- a/tests/safeds_examples/tabular/_titanic/test_titanic.py +++ b/tests/safeds_examples/tabular/_titanic/test_titanic.py @@ -16,7 +16,7 @@ def test_returns_table(self) -> None: assert isinstance(titanic, Table) def test_row_count(self, titanic: Table) -> None: - assert titanic.count_rows() == 1309 + assert titanic.n_rows == 1309 def test_schema(self, titanic: Table) -> None: assert titanic.schema == Schema( @@ -47,4 +47,4 @@ def test_all_columns_have_descriptions(self) -> None: titanic = load_titanic() descriptions = titanic.column_descriptions - assert set(descriptions.get_column("Name")._data) == set(titanic.get_column_names()) + assert set(descriptions.get_column("Name")._data) == set(titanic.column_names)