diff --git a/src/safeds/config/__init__.py b/src/safeds/_config/__init__.py similarity index 100% rename from src/safeds/config/__init__.py rename to src/safeds/_config/__init__.py diff --git a/src/safeds/config/_device.py b/src/safeds/_config/_device.py similarity index 100% rename from src/safeds/config/_device.py rename to src/safeds/_config/_device.py diff --git a/src/safeds/data/image/containers/_image.py b/src/safeds/data/image/containers/_image.py index 3f00430b8..5bd077ab3 100644 --- a/src/safeds/data/image/containers/_image.py +++ b/src/safeds/data/image/containers/_image.py @@ -1,7 +1,7 @@ from __future__ import annotations -import sys import io +import sys import warnings from pathlib import Path from typing import TYPE_CHECKING @@ -12,7 +12,7 @@ from PIL.Image import open as pil_image_open from torch import Tensor -from safeds.config import _get_device +from safeds._config import _get_device if TYPE_CHECKING: from torch.types import Device diff --git a/src/safeds/data/tabular/containers/_table.py b/src/safeds/data/tabular/containers/_table.py index 05b41cf27..744c306a0 100644 --- a/src/safeds/data/tabular/containers/_table.py +++ b/src/safeds/data/tabular/containers/_table.py @@ -337,7 +337,7 @@ def from_rows(rows: list[Row]) -> Table: dataframe: DataFrame = pd.concat(row_array, ignore_index=True) dataframe.columns = column_names_compare - schema = Schema.merge_multiple_schemas([row.schema for row in rows]) + schema = Schema._merge_multiple_schemas([row.schema for row in rows]) return Table._from_pandas_dataframe(dataframe, schema) @@ -1012,7 +1012,7 @@ def add_row(self, row: Row) -> Table: new_df = pd.concat([self._data, row._data]).infer_objects() new_df.columns = self.column_names - schema = Schema.merge_multiple_schemas([self.schema, row.schema]) + schema = Schema._merge_multiple_schemas([self.schema, row.schema]) result = Table._from_pandas_dataframe(new_df, schema) for column in int_columns: diff --git a/src/safeds/data/tabular/typing/_schema.py b/src/safeds/data/tabular/typing/_schema.py index ff0c15d30..3ed0623cd 100644 --- a/src/safeds/data/tabular/typing/_schema.py +++ b/src/safeds/data/tabular/typing/_schema.py @@ -111,7 +111,11 @@ def __sizeof__(self) -> int: ------- Size of this object in bytes. """ - return sum(map(sys.getsizeof, self._schema.keys())) + sum(map(sys.getsizeof, self._schema.values())) + sys.getsizeof(self._schema) + return ( + sum(map(sys.getsizeof, self._schema.keys())) + + sum(map(sys.getsizeof, self._schema.values())) + + sys.getsizeof(self._schema) + ) def __str__(self) -> str: """ @@ -237,7 +241,7 @@ def to_dict(self) -> dict[str, ColumnType]: return dict(self._schema) # defensive copy @staticmethod - def merge_multiple_schemas(schemas: list[Schema]) -> Schema: + def _merge_multiple_schemas(schemas: list[Schema]) -> Schema: """ Merge multiple schemas into one. diff --git a/src/safeds/ml/classical/classification/_support_vector_machine.py b/src/safeds/ml/classical/classification/_support_vector_machine.py index 33eeff0f1..33e01188e 100644 --- a/src/safeds/ml/classical/classification/_support_vector_machine.py +++ b/src/safeds/ml/classical/classification/_support_vector_machine.py @@ -19,7 +19,7 @@ class SupportVectorMachineKernel(ABC): """The abstract base class of the different subclasses supported by the `Kernel`.""" @abstractmethod - def get_sklearn_kernel(self) -> object: + def _get_sklearn_kernel(self) -> object: """ Get the kernel of the given SupportVectorMachine. @@ -85,7 +85,7 @@ def kernel(self) -> SupportVectorMachineKernel | None: class Kernel: class Linear(SupportVectorMachineKernel): - def get_sklearn_kernel(self) -> str: + def _get_sklearn_kernel(self) -> str: """ Get the name of the linear kernel. @@ -102,7 +102,7 @@ def __init__(self, degree: int): raise OutOfBoundsError(degree, name="degree", lower_bound=ClosedBound(1)) self._degree = degree - def get_sklearn_kernel(self) -> str: + def _get_sklearn_kernel(self) -> str: """ Get the name of the polynomial kernel. @@ -114,7 +114,7 @@ def get_sklearn_kernel(self) -> str: return "poly" class Sigmoid(SupportVectorMachineKernel): - def get_sklearn_kernel(self) -> str: + def _get_sklearn_kernel(self) -> str: """ Get the name of the sigmoid kernel. @@ -126,7 +126,7 @@ def get_sklearn_kernel(self) -> str: return "sigmoid" class RadialBasisFunction(SupportVectorMachineKernel): - def get_sklearn_kernel(self) -> str: + def _get_sklearn_kernel(self) -> str: """ Get the name of the radial basis function (RBF) kernel. diff --git a/src/safeds/ml/classical/regression/_support_vector_machine.py b/src/safeds/ml/classical/regression/_support_vector_machine.py index 5bc708b33..7635a7ceb 100644 --- a/src/safeds/ml/classical/regression/_support_vector_machine.py +++ b/src/safeds/ml/classical/regression/_support_vector_machine.py @@ -19,7 +19,7 @@ class SupportVectorMachineKernel(ABC): """The abstract base class of the different subclasses supported by the `Kernel`.""" @abstractmethod - def get_sklearn_kernel(self) -> object: + def _get_sklearn_kernel(self) -> object: """ Get the kernel of the given SupportVectorMachine. @@ -85,7 +85,7 @@ def kernel(self) -> SupportVectorMachineKernel | None: class Kernel: class Linear(SupportVectorMachineKernel): - def get_sklearn_kernel(self) -> str: + def _get_sklearn_kernel(self) -> str: """ Get the name of the linear kernel. @@ -102,7 +102,7 @@ def __init__(self, degree: int): raise OutOfBoundsError(degree, name="degree", lower_bound=ClosedBound(1)) self._degree = degree - def get_sklearn_kernel(self) -> str: + def _get_sklearn_kernel(self) -> str: """ Get the name of the polynomial kernel. @@ -114,7 +114,7 @@ def get_sklearn_kernel(self) -> str: return "poly" class Sigmoid(SupportVectorMachineKernel): - def get_sklearn_kernel(self) -> str: + def _get_sklearn_kernel(self) -> str: """ Get the name of the sigmoid kernel. @@ -126,7 +126,7 @@ def get_sklearn_kernel(self) -> str: return "sigmoid" class RadialBasisFunction(SupportVectorMachineKernel): - def get_sklearn_kernel(self) -> str: + def _get_sklearn_kernel(self) -> str: """ Get the name of the radial basis function (RBF) kernel. diff --git a/tests/safeds/config/__init__.py b/tests/safeds/_config/__init__.py similarity index 100% rename from tests/safeds/config/__init__.py rename to tests/safeds/_config/__init__.py diff --git a/tests/safeds/config/test_device.py b/tests/safeds/_config/test_device.py similarity index 83% rename from tests/safeds/config/test_device.py rename to tests/safeds/_config/test_device.py index a50102f4b..1fecb246e 100644 --- a/tests/safeds/config/test_device.py +++ b/tests/safeds/_config/test_device.py @@ -1,5 +1,5 @@ import torch -from safeds.config import _get_device +from safeds._config import _get_device def test_device() -> None: diff --git a/tests/safeds/data/tabular/typing/test_schema.py b/tests/safeds/data/tabular/typing/test_schema.py index f2a8cebbe..665359b4a 100644 --- a/tests/safeds/data/tabular/typing/test_schema.py +++ b/tests/safeds/data/tabular/typing/test_schema.py @@ -280,7 +280,7 @@ class TestMergeMultipleSchemas: ) def test_should_raise_if_column_names_are_different(self, schemas: list[Schema], error_msg_regex: str) -> None: with pytest.raises(UnknownColumnNameError, match=error_msg_regex): - Schema.merge_multiple_schemas(schemas) + Schema._merge_multiple_schemas(schemas) @pytest.mark.parametrize( ("schemas", "expected"), @@ -470,10 +470,10 @@ def test_should_raise_if_column_names_are_different(self, schemas: list[Schema], ], ) def test_should_return_merged_schema(self, schemas: list[Schema], expected: Schema) -> None: - assert Schema.merge_multiple_schemas(schemas) == expected + assert Schema._merge_multiple_schemas(schemas) == expected schemas.reverse() assert ( - Schema.merge_multiple_schemas(schemas) == expected + Schema._merge_multiple_schemas(schemas) == expected ) # test the reversed list because the first parameter is handled differently diff --git a/tests/safeds/ml/classical/classification/test_support_vector_machine.py b/tests/safeds/ml/classical/classification/test_support_vector_machine.py index 148ba4542..5cbb69445 100644 --- a/tests/safeds/ml/classical/classification/test_support_vector_machine.py +++ b/tests/safeds/ml/classical/classification/test_support_vector_machine.py @@ -41,7 +41,7 @@ def test_should_be_passed_to_sklearn(self, training_set: TaggedTable) -> None: def test_should_get_sklearn_kernel_linear(self) -> None: svm = SupportVectorMachine(c=2, kernel=SupportVectorMachine.Kernel.Linear()) assert isinstance(svm.kernel, SupportVectorMachine.Kernel.Linear) - linear_kernel = svm.kernel.get_sklearn_kernel() + linear_kernel = svm.kernel._get_sklearn_kernel() assert linear_kernel == "linear" @pytest.mark.parametrize("degree", [-1, 0], ids=["minus_one", "zero"]) @@ -52,19 +52,19 @@ def test_should_raise_if_degree_less_than_1(self, degree: int) -> None: def test_should_get_sklearn_kernel_polynomial(self) -> None: svm = SupportVectorMachine(c=2, kernel=SupportVectorMachine.Kernel.Polynomial(degree=2)) assert isinstance(svm.kernel, SupportVectorMachine.Kernel.Polynomial) - poly_kernel = svm.kernel.get_sklearn_kernel() + poly_kernel = svm.kernel._get_sklearn_kernel() assert poly_kernel == "poly" def test_should_get_sklearn_kernel_sigmoid(self) -> None: svm = SupportVectorMachine(c=2, kernel=SupportVectorMachine.Kernel.Sigmoid()) assert isinstance(svm.kernel, SupportVectorMachine.Kernel.Sigmoid) - sigmoid_kernel = svm.kernel.get_sklearn_kernel() + sigmoid_kernel = svm.kernel._get_sklearn_kernel() assert sigmoid_kernel == "sigmoid" def test_should_get_sklearn_kernel_rbf(self) -> None: svm = SupportVectorMachine(c=2, kernel=SupportVectorMachine.Kernel.RadialBasisFunction()) assert isinstance(svm.kernel, SupportVectorMachine.Kernel.RadialBasisFunction) - rbf_kernel = svm.kernel.get_sklearn_kernel() + rbf_kernel = svm.kernel._get_sklearn_kernel() assert rbf_kernel == "rbf" def test_should_get_kernel_name(self) -> None: diff --git a/tests/safeds/ml/classical/regression/test_support_vector_machine.py b/tests/safeds/ml/classical/regression/test_support_vector_machine.py index 82bd86e81..853cf71d1 100644 --- a/tests/safeds/ml/classical/regression/test_support_vector_machine.py +++ b/tests/safeds/ml/classical/regression/test_support_vector_machine.py @@ -41,7 +41,7 @@ def test_should_be_passed_to_sklearn(self, training_set: TaggedTable) -> None: def test_should_get_sklearn_kernel_linear(self) -> None: svm = SupportVectorMachine(c=2, kernel=SupportVectorMachine.Kernel.Linear()) assert isinstance(svm.kernel, SupportVectorMachine.Kernel.Linear) - linear_kernel = svm.kernel.get_sklearn_kernel() + linear_kernel = svm.kernel._get_sklearn_kernel() assert linear_kernel == "linear" @pytest.mark.parametrize("degree", [-1, 0], ids=["minus_one", "zero"]) @@ -52,19 +52,19 @@ def test_should_raise_if_degree_less_than_1(self, degree: int) -> None: def test_should_get_sklearn_kernel_polynomial(self) -> None: svm = SupportVectorMachine(c=2, kernel=SupportVectorMachine.Kernel.Polynomial(degree=2)) assert isinstance(svm.kernel, SupportVectorMachine.Kernel.Polynomial) - poly_kernel = svm.kernel.get_sklearn_kernel() + poly_kernel = svm.kernel._get_sklearn_kernel() assert poly_kernel == "poly" def test_should_get_sklearn_kernel_sigmoid(self) -> None: svm = SupportVectorMachine(c=2, kernel=SupportVectorMachine.Kernel.Sigmoid()) assert isinstance(svm.kernel, SupportVectorMachine.Kernel.Sigmoid) - sigmoid_kernel = svm.kernel.get_sklearn_kernel() + sigmoid_kernel = svm.kernel._get_sklearn_kernel() assert sigmoid_kernel == "sigmoid" def test_should_get_sklearn_kernel_rbf(self) -> None: svm = SupportVectorMachine(c=2, kernel=SupportVectorMachine.Kernel.RadialBasisFunction()) assert isinstance(svm.kernel, SupportVectorMachine.Kernel.RadialBasisFunction) - rbf_kernel = svm.kernel.get_sklearn_kernel() + rbf_kernel = svm.kernel._get_sklearn_kernel() assert rbf_kernel == "rbf" def test_should_get_kernel_name(self) -> None: